diff --git a/Makefile.common b/Makefile.common index 3f06d46..9baa6c9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -276,7 +276,9 @@ $(TOPLVL)/repo: @echo "Creating local RPM repository $(TOPLVL)/repo" mkdir $(TOPLVL)/repo -#help repoadd: Creates a local Yum repository in the $(TOPLVL)/repo directory. +#help repoadd: Adds locally-built RPMs for this package to the local RPM +#help repository. If this repository does not yet exist, it is created and +#help enabled. repoadd: results/build.log $(TOPLVL)/repo @if [ -z "`grep '^Wrote: .*$(shell basename $(SRPMFILE))$$' results/build.log`" ]; then \ echo "You have not yet succesfully built this release yet"; exit 1; \ @@ -291,11 +293,10 @@ repoadd: results/build.log $(TOPLVL)/repo fi for r in $(LATEST_RPMS); do echo "+$$r"; echo $$(basename $$r) >> .repo-index; cp $$r $(TOPLVL)/repo; done ( cd $(TOPLVL)/repo ; if type createrepo_c 1>/dev/null 2>&1; then createrepo_c .; else createrepo .; fi ); - @cp $(TOPLVL)/projects/common/image-creator/yum.conf $(TOPLVL)/repo/.yum.conf - @printf "\n\n[local]\nname=Local\nfailovermethod=priority\nenabled=1\ngpgcheck=0\n" >> $(TOPLVL)/repo/.yum.conf - @printf "baseurl=file://$$(realpath $(TOPLVL))/repo/\n\n" >> $(TOPLVL)/repo/.yum.conf + $(call localrepoenable,${PM_CONF},${MOCK_CONF}) -#help repodel: Removes package from local Yum repository. +#help repodel: Removes RPMs from the local RPM repository that were +#help previously added by 'make repoadd' for this package. repodel: @if [ -f .repo-index ]; then \ echo "Cleaning old rpms:"; \ @@ -306,6 +307,13 @@ repodel: rm .repo-index; \ fi +#help repoenable: Enables the local RPM repository for use with Yum/DNF and +#help Mock. If this repository does not yet exist, it is created. +repoenable: $(TOPLVL)/repo ; $(call localrepoenable,${PM_CONF},${MOCK_CONF}) + +#help repodisable: Disables the local RPM repository. +repodisable: localrepodisable ; + loop-up: $(loopup) diff --git a/Makefile.config b/Makefile.config index e5b66a8..2077438 100644 --- a/Makefile.config +++ b/Makefile.config @@ -54,6 +54,13 @@ AUTOSPEC_CONF = $(TOPLVL)/projects/common/autospec.conf # in "pkg-mapping" for cloning/pulling package repos. USE_PACKAGE_MAPPING = yes +# Package manager config file. Default to the in-tree copy. +PM_CONF = $(TOPLVL)/projects/common/image-creator/yum.conf + +# Mock configuration file. Default to the in-tree copy. +MOCK_CONF = $(TOPLVL)/projects/common/koji-client-files/clear.cfg + + # Include any site local configuration variables. These variables may override # the definitions given above. -include $(TOPLVL)/projects/common/Makefile.config.site_local diff --git a/Makefile.functions b/Makefile.functions index e89cd40..616ef99 100644 --- a/Makefile.functions +++ b/Makefile.functions @@ -62,6 +62,27 @@ define remotepkgname $(if $(USE_PACKAGE_MAPPING),$$(awk -v P="$(1)" '$$1 == P { res=$$2 } END { print res ? res : P }' $(TOPLVL)/projects/common/pkg-mapping),$(1)) endef +# Enables the local RPM repo by installing package manager and Mock configs. +# First argument is the path to the package manager config, and the second +# argument is the path to the mock config. Each of these config files is +# augmented for local repo support. +define localrepoenable + @cp $(1) $(TOPLVL)/repo/.yum.conf + @printf "\n\n[local]\nname=Local\nfailovermethod=priority\nenabled=1\ngpgcheck=0\n" >> $(TOPLVL)/repo/.yum.conf + @printf "baseurl=file://$$(realpath $(TOPLVL))/repo/\n\n" >> $(TOPLVL)/repo/.yum.conf + @cp $(2) $(TOPLVL)/repo/.clear.cfg + @printf "\n\n[localrepo]\nname=Local repo\nfailovermethod=priority\nenabled=1\ngpgcheck=0\n" >> $(TOPLVL)/repo/.clear.cfg + @printf "baseurl=file://$$(realpath $(TOPLVL))/repo/\n\n" >> $(TOPLVL)/repo/.clear.cfg + @sed -i '/^"""/d; $$a"""' $(TOPLVL)/repo/.clear.cfg +endef + +# Disables the local RPM repo by removing the installed package manager and +# Mock configuration files. +localrepodisable: + @rm -f $(TOPLVL)/repo/.yum.conf + @rm -f $(TOPLVL)/repo/.clear.cfg + + .PHONY: help ##### Code # Make sure that HELPSPACE has exactly HELPLEN spaces in it diff --git a/Makefile.toplevel b/Makefile.toplevel index 43fa2fd..7d4b943 100644 --- a/Makefile.toplevel +++ b/Makefile.toplevel @@ -211,5 +211,17 @@ autospecnew: exit 1; \ fi +$(TOPLVL)/repo: + @echo "Creating local RPM repository $(TOPLVL)/repo" + mkdir $(TOPLVL)/repo + +#help repoenable: Enables the local RPM repository for use with Yum/DNF and +#help Mock. If this repository does not yet exist, it is created. +repoenable: $(TOPLVL)/repo ; $(call localrepoenable,${PM_CONF},${MOCK_CONF}) + +#help repodisable: Disables the local RPM repository. +repodisable: localrepodisable ; + + # Define site local toplevel targets in a separate makefile -include $(TOPLVL)/projects/common/Makefile.toplevel.site_local