# Makefile.common-addons.gmk # Addons for Fedora CVS Makefile # Author: Till Maas 2007 # # Version : 0.0.68 # Release Date : 2008-01-07 ### Requirements ### # python # sed # curl # wget # grep ### SETUP ### # ## Edit your ~/.cvspkgsrc to include the following # # FAS_USERNAME= # -include /path/to/Makefile.common-addons.gmk ### Configuration ### ## There are some Variables you can use to change the beheaviour of this addons: # ## Password for Bodhi, when not specified, you will be asked for it, when needed # BODHI_PASSWORD= # ## Thise seems not to work: ## Path to a cookie jar that may contain you bodhi cookie: # BODHI_USER_COOKIE_FILE=~/.mozilla/firefox/*.default/cookies.txt # ## Path to a file containing your update notification # UPDATE_FILE=my-update-notification # # ### Usage ### # type make help-addons after setup in a Fedora CVS rpm branch ### TODO ### # - publish updates to updates-testing after creation # - allow editing clog in make commit # - sync with devel target # - refactor bodhi-update targets and variables # - target to output the version of this makefile # - add checks for the branch it is running on # - add short alias targets for long targets # - add rebuild target # - add "add koji notification" target # - add echo cvslookaheadcache url show target ### Files ### # In ~/.bodhi-cookie a cookie jar with a session cookie for bodhi is stored .DEFAULT_GOAL=sources EDITOR?=vim HELP_ADDONS=\nAddon-targets:\n HELP_MISSING=\nOfficial targets missing in help:\n # call strings help=$(shell /usr/bin/printf '%-30s %s\\n' "$(strip $1)" "$(strip $2)") koji-build=$(BUILD_CLIENT) $(SECONDARY_CONFIG) build $(1) $(BUILD_FLAGS) $(TARGET) '$2' # variables, that should be in Makefile.commong SRPMFILE=$(NAME)-$(VERSION)-$(RELEASE).src.rpm # Workaround variables comma = , , = , ## How to add someting to the help menu: # +=$(call help, , ) # Restrictions for helptext: # must not contain commas, use $(comma) instead # must only contain matching parenthesis or braces # leading, trailing whitespace will be stripped # multiple spaces will be merged into one #HELP_MISSING+=$(call help, <++>, <++>) HELP_MISSING+=$(call help, cvsurl, echo '$(CVS_URL)') HELP_MISSING+=$(call help, force-tag, Forces tag as '$(TAG)') HELP_MISSING+=$(call help, prep-, Run prep only for ) HELP_MISSING+=$(call help, upload, Upload the FILES$, adding to the ./sources manifest) #### USER TARGETS #### ## Login to bodhi / get session cookie ## :PARAMETER: points to a cookie jar that contains a bodhi cookie, e.g. from firefox # BODHI_USER_COOKIE_FILE ifneq ($(BODHI_USER_COOKIE_FILE), ) BODHI_USER_COOKIE=--cookie "$(BODHI_USER_COOKIE_FILE)" else BODHI_USER_COOKIE= endif BODHI_COOKIE_FILE=~/.bodhi-cookie BODHI_BASE_URL=https://admin.fedoraproject.org/updates/ BODHI_LOGIN_URL=$(BODHI_BASE_URL) .PHONY:: bodhi-login HELP_ADDONS+=$(call help, bodhi-login, Login to bodhi / get a session cookie) bodhi-curl=curl --silent $(BODHI_USER_COOKIE) --cookie-jar $(BODHI_COOKIE_FILE) --cookie $(BODHI_COOKIE_FILE) bodhi-login=$(bodhi-curl) --form "user_name=$(FAS_USERNAME)" --form "password=$1" --form "login=Login" $(BODHI_LOGIN_URL) >/dev/null BODHI_VALIDATION_STRING=
  • Logout
  • bodhi-checkcookie=$(bodhi-curl) $(BODHI_BASE_URL) | grep '$(BODHI_VALIDATION_STRING)' >/dev/null bodhi-login: # :PARAMETER: ifdef BODHI_PASSWORD @$(bodhi-checkcookie) || $(call bodhi-login, $BODHI_PASSWORD) else @$(bodhi-checkcookie) || $(call bodhi-login,$(shell $(bodhi-checkcookie) || read -p "Please enter your password to Bodhi: " -s; echo $$REPLY)) endif bodhi-update-notes=grep -v "^:" $(UPDATE_FILE) | egrep -v "^(CVE=|BUG=|TYPE=)" bodhi-update-bugs=echo $$(grep "^BUG=" $(UPDATE_FILE) | sed 's/BUG=//') | sed 's/ /+/g' bodhi-update-cves=echo $$(grep "^CVE=" $(UPDATE_FILE) | sed 's/CVE=//') | sed 's/ /+/g' bodhi-update-type=grep "^TYPE=" $(UPDATE_FILE) | sed -e 's/TYPE=//' -e 's/^S.*/security/' -e 's/^B.*/bugfix/' -e 's/^E.*/enhancement/' BODHI-UPDATE-RELEASE=Fedora+7 # :PARAMETER: UPDATE_FILE?=update-notification CVE_FILE=bodhi-cves BUGS_FILE=bodhi-bugs NOTES_FILE=bodhi-notes BODHI_CREATE_RESULT_RE=Set-Cookie: tg_flash="\(.*\)"; Path=/; BODHI_CREATE_RESULT_URL_RE=Location: \(.*\) BODHI_CREATE_RESULT_HTTP_RE=HTTP/1.1 [0-9]\{3\} \(.*\) BODHI_CREATE_RESULT_FILTER_RE=\($(BODHI_CREATE_RESULT_RE)\|$(BODHI_CREATE_RESULT_URL_RE)\|$(BODHI_CREATE_RESULT_HTTP_RE)\) ## Create a new bodhi update NVR=$(NAME)-$(VERSION)-$(RELEASE) BODHI_CREATE_URL=$(BODHI_BASE_URL)/save # for DEBUG #BODHI_CREATE_URL=http://localhost:8080/save python-urlencode=python -c 'import urllib,sys; print(urllib.urlencode([(sys.argv[1], sys.stdin.read() )]))' "$1" .PHONY:: bodhi-create-update HELP_ADDONS+=$(call help, bodhi-create-update, Create a new update in Bodhi) bodhi-create-update: bodhi-login $(UPDATE_FILE) @$(bodhi-update-notes) | sed 's/$$/\r/' > $(NOTES_FILE) @echo "You should now see something like 'Update successfully created' when everthing went fine." @$(bodhi-curl) -i --data "nvr.text=$(NVR)" --data "edited=" --data "nvr.hidden=" --data "release=$(BODHI-UPDATE-RELEASE)" --data "type=$(shell $(bodhi-update-type))" --data "bugs=$(shell $(bodhi-update-bugs))" --data "cves=$(shell $(bodhi-update-cves))" --data "$$($(call python-urlencode,notes) < $(NOTES_FILE))" $(BODHI_CREATE_URL) | grep '$(BODHI_CREATE_RESULT_FILTER_RE)' | sed -e 's#$(BODHI_CREATE_RESULT_RE)#\1#' -e 's#http:#https:#' @rm $(NOTES_FILE) template-write=echo >>$(UPDATE_FILE) HELP_ADDONS+=$(call help, bodhi-prepare-update, Prepare a new update notification) $(UPDATE_FILE) bodhi-prepare-update: clog $(SPECFILE) @test -f $(UPDATE_FILE) && mv $(UPDATE_FILE) $(UPDATE_FILE)\~ || : @grep '#' clog | sed 's/.*#\([0-9]*\).*/\1/' > $(BUGS_FILE) @grep CVE clog | sed 's/.*\(CVE-[0-9]\{4\}-[0-9]\{4\}\).*/\1/' > $(CVE_FILE) @$(template-write) : Bodhi update template, all entries starting with a : are ignored @$(template-write) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @$(template-write) : @$(template-write) : Select a type: S=Security, B=Bugfix, E=Enhancement @$(template-write) : @$(template-write) TYPE=$$((test -s $(CVE_FILE) && echo "S") || ( test -s $(BUGS_FILE) && echo "B") || (echo "E")) @$(template-write) : Select Bug numbers to include or add you own @$(template-write) : You can either use multiple BUG= statements or separate the bug numbers with a space @$(template-write) :BUG= @for bug in $$(cat $(BUGS_FILE)); do $(template-write) BUG=$$bug ; done @$(template-write) : Select CVE numbers to include or add you own @$(template-write) : You can either use multiple CVE= statements or separate the cve numbers with a space @$(template-write) :CVE= @for cve in $$(cat $(CVE_FILE)); do $(template-write) CVE=$$cve ; done @$(template-write) : Now edit the update notification message, everything that does not start with a ":" or @$(template-write) : CVE=, TYPE= or BUG= will be used @cat clog >>$(UPDATE_FILE) $(EDITOR) $(UPDATE_FILE) @rm $(BUGS_FILE) $(CVE_FILE) #bodhi-cookietest: #ifeq ($(shell $(bodhi-checkcookie)), valid) # @echo valid: '>$(BODHI_COOKIE_VALID)<' #else # @echo invalid: '>$(BODHI_COOKIE_VALID)<' #endif ## commit changes .PHONY:: commit HELP_ADDONS+=$(call help, commit, Commit changes to cvs with entries from spec changelog) commit: clog @cvs commit -F clog @rm clog ## show cvsurl of HEAD CVS_HEAD_URL=$(shell echo $(CVS_URL) | sed 's/\#.*/\#HEAD/') .PHONY:: cvsurl-head HELP_ADDONS+=$(call help, cvsurl-head, Show head cvsurl) cvsurl-head: @echo $(CVS_HEAD_URL) ## Help .PHONY:: help-addons HELP_ADDONS+=$(call help, help-addons, Shows the normal and the addon help text) help-addons: help @echo -ne "$(HELP_ADDONS)" @echo -e "Footnotes:\n¹ - there is a detailed help available with make help-topic TOPIC=''" @echo -ne "$(HELP_MISSING)" help-topic: @echo $(HELP_TOPIC_$(TOPIC)) ## Download koji buildlogs # Directory to store logs in KOJI_LOGS_DIR?=koji-logs-$(VERSION)-$(RELEASE) .PHONY:: koji-logs HELP_ADDONS+=$(call help, koji-logs, Download koji buildlogs) koji-logs: @wget --no-verbose --no-host-directories --cut-dirs 6 --directory-prefix=$(KOJI_LOGS_DIR) --continue --recursive $(KOJI_LOGS_URL)/{ppc,i386,x86_64,ppc64,noarch}/{root,build,mockconfig}.log || : ## show path to buildlogs # URL to koji logs KOJI_LOGS_URL=http://koji.fedoraproject.org/packages/$(NAME)/$(VERSION)/$(RELEASE)/data/logs/ .PHONY:: koji-logs-url HELP_ADDONS+=$(call help, koji-logs-url, Show URL to koji buildlogs) koji-logs-url: @echo $(KOJI_LOGS_URL) ## Show unreleased builds # seems to be a bad idea, because it takes very long (03:30 min) .PHONY:: koji-unreleased-builds HELP_ADDONS+=$(call help, koji-unreleased-builds, Shows which builds of yours need to be released) koji-unreleased-builds: $(BUILD_CLIENT) list-tagged --latest dist-fc7-updates-candidate | grep $(FAS_USERNAME) ## Scratch build .PHONY:: scratch-build HELP_ADDONS+=$(call help, scratch-build, Creates a scratch build for all archs) scratch-build: koji-check $(call koji-build,--scratch,$(CVS_URL)) ## Scratch build with archlist # :TODO: make .PHONY work with scratch-build_% HELP_ADDONS+=$(call help, scratch-build_¹, Creates a scratch build for selected arches (comma separated)) HELP_TOPIC_scratch-build=Example: make scratch-build_i386,ppc scratch-build_%: koji-check FORCE $(call koji-build,--scratch --arch-override=$*,$(CVS_URL)) ## Scratch head build .PHONY:: scratch-head-build HELP_ADDONS+=$(call help, scratch-head-build, Creates a scratch build for all archs from cvs HEAD) scratch-head-build: koji-check $(call koji-build,--scratch,$(CVS_HEAD_URL)) ## Scratch head build with archlist # :TODO: make .PHONY work with scratch-build_% HELP_ADDONS+=$(call help, scratch-head-build_, Creates a scratch build for selected arches (comma separated) from cvs HEAD) scratch-head-build_%: koji-check FORCE $(call koji-build,--scratch --arch-override=$*,$(CVS_HEAD_URL)) ## Scratch srpm build .PHONY:: scratch-srpm-build HELP_ADDONS+=$(call help, scratch-srpm-build, Creates a scratch build for all archs from srpm SRPMFILE ($(SRPMFILE))) scratch-srpm-build: koji-check srpm $(call koji-build,--scratch,$(SRPMFILE)) ## Scratch head build with archlist # :TODO: make .PHONY work with scratch-build_% HELP_ADDONS+=$(call help, scratch-srpm-build_, Creates a scratch build for selected arches (comma separated) from srpm SRPMFILE ($(SRPMFILE))) scratch-srpm-build_%: koji-check FORCE $(call koji-build,--scratch --arch-override=$*,$(SRPMFILE)) ### HELPER TARGETS ### .PHONY:: koji.check koji-check: $(COMMON_DIR)/branches @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Please setup Koji, see: http://fedoraproject.org/wiki/Koji/UsingKoji"; exit 1; fi