mirror of
https://src.koozali.org/smeserver/common.git
synced 2024-12-22 21:07:00 +01:00
recreate archive + tidy CVS stuff
This commit is contained in:
parent
86dac5f491
commit
9fbbedec84
302
Makefile.common
302
Makefile.common
@ -110,14 +110,8 @@ EXT := $(shell cat $(NAME).spec | grep -e '^[S|s]ource' | head -n 1 | sed 's/Sou
|
||||
#endif
|
||||
ARCHIVEFILE := $(shell cat $(NAME).spec | grep -e '^[S|s]ource' | sed -r 's/^[S|s]ource[0-9]?:\s?//' | sed -e 's/{//g' -e 's/}//g' -e "s/%name/$(NAME)/g" -e "s/%version/$(VERSION)/g" | xargs basename)
|
||||
|
||||
# default target: just make sure we've got the sources
|
||||
all: sources
|
||||
|
||||
# user specific configuration
|
||||
CVS_EXTRAS_RC := $(shell if test -f $(HOME)/.cvspkgsrc ; then echo $(HOME)/.cvspkgsrc ; fi)
|
||||
ifdef CVS_EXTRAS_RC
|
||||
include $(CVS_EXTRAS_RC)
|
||||
endif
|
||||
# default target:
|
||||
all:
|
||||
|
||||
# The repository and the clients we use for the files
|
||||
REPOSITORY ?= http://buildsys.contribs.org/source
|
||||
@ -153,15 +147,7 @@ TAG_RELEASE := $(shell echo $(RELEASE) | sed s/\\\./_/g)
|
||||
# simpler tagging using GIT
|
||||
TAG?=$(TAG_VERSION)-$(TAG_RELEASE)
|
||||
|
||||
# where to cvs export temporarily
|
||||
TMPCVS := $(WORKDIR)/cvs-$(TAG)
|
||||
|
||||
# source file basenames
|
||||
SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print $$2 }')
|
||||
# full path to source files
|
||||
FULLSOURCEFILES := $(addprefix $(SOURCEDIR)/,$(SOURCEFILES))
|
||||
|
||||
# retrieve the stored md5 sum for a source download
|
||||
#TODO remove was CVS specific # retrieve the stored md5 sum for a source download
|
||||
define get_sources_md5
|
||||
$(shell cat sources 2>/dev/null | while read m f ; do if test "$$f" = "$@" ; then echo $$m ; break ; fi ; done)
|
||||
endef
|
||||
@ -173,101 +159,15 @@ ARCHES = noarch i386 i586 i686 x86_64 aarch64 # ia64 s390 s390x ppc ppc64 pserie
|
||||
PREP_ARCHES = $(addprefix prep-,$(ARCHES))
|
||||
|
||||
## list all our bogus targets
|
||||
.PHONY :: $(ARCHES) clog commit sources uploadsource upload export check build build-check plague koji build chain-build test-srpm srpm tag tagbuild force-tag verrel new clean patch prep compile install install-short compile-short FORCE local scratch-build scratch-build-%
|
||||
.PHONY :: $(ARCHES) $(ARCHIVEFILE) clog commit sources uploadsource upload check build build-check plague koji build chain-build test-srpm srpm tag tagbuild force-tag verrel new clean patch prep compile install install-short compile-short FORCE local scratch-build scratch-build-%
|
||||
|
||||
# The TARGETS define is meant for local module targets that should be
|
||||
# made in addition to the SOURCEFILES whenever needed
|
||||
TARGETS ?= $(ARCHIVEFILE)
|
||||
#TARGETS ?=
|
||||
|
||||
# default target - retrieve the sources and make the module specific targets
|
||||
sources: $(SOURCEFILES) $(TARGETS)
|
||||
|
||||
# Retrieve the sources we do not have in CVS
|
||||
$(SOURCEFILES): #FORCE
|
||||
@mkdir -p $(SOURCEDIR)
|
||||
@echo "Downloading $@..."
|
||||
@for i in `find ../ -maxdepth 2 -name "$@"`; do \
|
||||
if test "$$(md5sum $$i | awk '{print $$1}')" = "$(get_sources_md5)" ; then \
|
||||
echo "Copying from $$i" ; \
|
||||
ln $$i $@ ; \
|
||||
break ; \
|
||||
fi ; \
|
||||
done
|
||||
@if [ -z "$(CLIENT)" ]; then echo "Can't download, need curl or wget installed." ; exit 1; fi
|
||||
@if [ ! -e "$@" ] ; then $(CLIENT) $(REPOSITORY)/$(get_sources_md5)/$@ ; fi
|
||||
@if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
|
||||
@if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \
|
||||
echo "md5sum of the downloaded $@ does not match the one from 'sources' file" ; \
|
||||
echo "Local copy: $$(md5sum $@)" ; \
|
||||
echo "In sources: $$(grep $@ sources)" ; \
|
||||
exit 1 ; \
|
||||
else \
|
||||
ls -l $@ ; \
|
||||
fi
|
||||
|
||||
# Support for uploading stuff into the repository.
|
||||
ifdef FILES
|
||||
|
||||
upload-file = echo -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "file=@$$f" $(UPLOAD_REPOSITORY)
|
||||
|
||||
define upload-request
|
||||
echo "Checking : $$b on $(UPLOAD_REPOSITORY)..." ; \
|
||||
if test -f "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f"; then \
|
||||
echo "This file ($$m) is already uploaded" ; \
|
||||
else \
|
||||
echo "Uploading: $$b to $(UPLOAD_REPOSITORY)..." ; \
|
||||
mkdir -p "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}" || exit 1 ; \
|
||||
ln -f "$$f" "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f" 2> /dev/null || cp -f "$$f" "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f" || exit 1 ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# Upload the FILES, adding to the ./sources manifest
|
||||
upload: $(FILES)
|
||||
@if ! test -f ./sources ; then touch ./sources ; fi
|
||||
@if ! test -f ./.cvsignore ; then touch ./.cvsignore ; fi
|
||||
@for f in $(FILES); do \
|
||||
if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
|
||||
b="$$(basename $$f)" ; \
|
||||
m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
|
||||
if test "$$m" = "$$(grep $$b sources)" ; then \
|
||||
echo "ERROR: file $$f is already listed in the sources file..." ; \
|
||||
exit 1 ; \
|
||||
fi ; \
|
||||
chmod +r $$f ; \
|
||||
echo ; $(upload-request) ; echo ; \
|
||||
if test -z "$$(egrep ""[[:space:]]$$b$$"" sources)" ; then \
|
||||
echo "$$m" >> sources ; \
|
||||
else \
|
||||
egrep -v "[[:space:]]$$b$$" sources > sources.new ; \
|
||||
echo "$$m" >> sources.new ; \
|
||||
mv sources.new sources ; \
|
||||
fi ; \
|
||||
if test -z "$$(egrep ""^$$b$$"" .cvsignore)" ; then \
|
||||
echo $$b >> .cvsignore ; \
|
||||
fi \
|
||||
done
|
||||
@if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
|
||||
@echo "Source upload succeeded. Don't forget to commit the new ./sources file"
|
||||
@cvs update sources .cvsignore
|
||||
|
||||
# Upload FILES and recreate the ./sources file to include only these FILES
|
||||
new-source new-sources: $(FILES)
|
||||
@rm -f sources && touch sources
|
||||
@rm -f .cvsignore && touch .cvsignore
|
||||
@for f in $(FILES); do \
|
||||
if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
|
||||
b="$$(basename $$f)" ; \
|
||||
m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
|
||||
chmod +r $$f ; \
|
||||
echo ; $(upload-request) ; echo ; \
|
||||
echo "$$m" >> sources ; \
|
||||
echo "$$b" >> .cvsignore ; \
|
||||
done
|
||||
@if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
|
||||
@echo "Source upload succeeded. Don't forget to commit the new ./sources file"
|
||||
@cvs update sources .cvsignore
|
||||
endif
|
||||
# default target - retrieve/rebuild the sources and make the module specific targets
|
||||
sources: $(TARGETS)
|
||||
|
||||
# allow overriding buildarch so you can do, say, an i386 build on x86_64
|
||||
ifndef BUILDARCH
|
||||
@ -287,7 +187,7 @@ lint:
|
||||
$(ARCHES) : sources $(TARGETS)
|
||||
$(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log ; exit $${PIPESTATUS[0]}
|
||||
|
||||
# empty target to force checking of md5sums in FULLSOURCEFILES
|
||||
# empty target to force checking
|
||||
FORCE:
|
||||
|
||||
# build whatever's appropriate for the local architecture
|
||||
@ -318,24 +218,11 @@ compile-short: sources $(TARGETS)
|
||||
install-short: sources $(TARGETS)
|
||||
$(RPM_WITH_DIRS) --nodeps --short-circuit -bi $(SPECFILE)
|
||||
|
||||
#TODO remove was CVS specific
|
||||
CVS_ROOT := $(shell if [ -f CVS/Root ] ; then cat CVS/Root ; fi)
|
||||
CVS_REPOSITORY := $(shell if [ -f CVS/Repository ] ; then cat CVS/Repository ; fi)
|
||||
GIT_REPOSITORY := $(shell basename `git rev-parse --show-toplevel`)
|
||||
#CVS_URL := cvs://shell.koozali.org/cvs/smecontribs?$(CVS_REPOSITORY)\#$(TAG)
|
||||
GIT_URL := git+https://src.koozali.org/$(GIT_ORG)/$(GIT_REPOSITORY)\#$(TAG)
|
||||
|
||||
## create a clean exported copy in $(TMPCVS)
|
||||
export:: sources
|
||||
@mkdir -p $(WORKDIR)
|
||||
/bin/rm -rf $(TMPCVS)
|
||||
@if test -z "$(TAG)" ; then echo "Must specify a tag to check out" ; exit 1; fi
|
||||
@mkdir -p $(TMPCVS)
|
||||
@cd $(TMPCVS) && \
|
||||
cvs -Q -d $(CVS_ROOT) export -r$(TAG) -d $(NAME) $(CVS_REPOSITORY) && \
|
||||
cvs -Q -d $(CVS_ROOT) export -rHEAD common
|
||||
@if [ -n "$(FULLSOURCEFILES)" ]; then ln -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) 2> /dev/null || cp -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) ; fi
|
||||
@echo "Exported $(TMPCVS)/$(NAME)"
|
||||
|
||||
## build a test-srpm and see if it will -bp on all arches
|
||||
# XXX: I am not sure exactly what this is supposed to really do, since the
|
||||
# query format returns (none) most of the time, and that is not
|
||||
@ -363,8 +250,8 @@ endif
|
||||
|
||||
# Create the .tar.gz or whatever file
|
||||
$(ARCHIVEFILE):
|
||||
$(info "Making archive file ${ARCHIVEFILE}")
|
||||
mkdir -p "${TEMPDIR}/${TREEPATH}" ;\
|
||||
$(info create or update ${ARCHIVEFILE} archive)
|
||||
@mkdir -p "${TEMPDIR}/${TREEPATH}" ;\
|
||||
if [ -d ${CODEDIR} ] ; then cp -R "${CODEDIR}" "${TEMPDIR}/${TREEPATH}" ; fi ; \
|
||||
if [ -e createlinks ] ; then cp createlinks "${TEMPDIR}/${TREEPATH}/." ; fi ; \
|
||||
if [ -d additional ] ; then cp -r additional/* "${TEMPDIR}/${TREEPATH}/." ; fi ; \
|
||||
@ -500,15 +387,15 @@ new:
|
||||
clean ::
|
||||
@echo "Running the %clean script of the rpmbuild..."
|
||||
-@$(RPM_WITH_DIRS) --clean --nodeps $(SPECFILE)
|
||||
@for F in $(FULLSOURCEFILES); do \
|
||||
if test -e $$F ; then \
|
||||
echo "Deleting $$F" ; /bin/rm -f $$F ; \
|
||||
fi; \
|
||||
done
|
||||
@if test -d $(TMPCVS); then \
|
||||
echo "Deleting CVS dir $(TMPCVS)" ; \
|
||||
/bin/rm -rf $(TMPCVS); \
|
||||
fi
|
||||
#@for F in $(FULLSOURCEFILES); do \
|
||||
# if test -e $$F ; then \
|
||||
# echo "Deleting $$F" ; /bin/rm -f $$F ; \
|
||||
# fi; \
|
||||
# done
|
||||
#@if test -d $(TMPCVS); then \
|
||||
# echo "Deleting CVS dir $(TMPCVS)" ; \
|
||||
# /bin/rm -rf $(TMPCVS); \
|
||||
#fi
|
||||
@if test -e $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; then \
|
||||
echo "Deleting $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm" ; \
|
||||
/bin/rm -f $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; \
|
||||
@ -535,7 +422,7 @@ patch:
|
||||
(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) > $(PATCHFILE) || true
|
||||
@if ! test -s $(PATCHFILE); then echo "Patch is empty!"; exit 1; fi
|
||||
@echo "Created $(PATCHFILE)"
|
||||
@grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
|
||||
#@grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
|
||||
|
||||
# Recreates the patch file of specified suffix from the current working sources
|
||||
# but keeping any comments at the top of file intact, and backing up the old copy
|
||||
@ -566,9 +453,7 @@ help:
|
||||
@echo "Usage: make <target>"
|
||||
@echo "Available targets are:"
|
||||
@echo " help Show this text"
|
||||
@echo " sources Download source files [default]"
|
||||
@echo " upload FILES=<files> Add <files> to CVS"
|
||||
@echo " new-sources FILES=<files> Replace sources in CVS with <files>"
|
||||
@echo " sources Download/build source files"
|
||||
@echo " <arch> Local test rpmbuild binary"
|
||||
@echo " local Local test rpmbuild binary"
|
||||
@echo " prep Local test rpmbuild prep"
|
||||
@ -577,7 +462,6 @@ help:
|
||||
@echo " compile-short Local test rpmbuild short-circuit compile"
|
||||
@echo " install-short Local test rpmbuild short-circuit install"
|
||||
@echo " lint Run rpmlint against local build output"
|
||||
@echo " export Create clean export in \"cvs-$(TAG)\""
|
||||
@echo " check Check test srpm preps on all archs"
|
||||
@echo " srpm Create a srpm"
|
||||
@echo " tag Tag sources as \"$(TAG)\""
|
||||
@ -602,7 +486,7 @@ help:
|
||||
@echo " commit Commit and push to GIT using the clog file as the log message"
|
||||
@echo " commitonly Commit to GIT using the clog file as the log message"
|
||||
@echo " push Push to GIT after a git commit or make commitonly"
|
||||
@echo " clean Remove srcs ($(SOURCEFILES)), export dir (cvs-$(TAG)) and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
|
||||
@echo " clean Remove srcs and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
|
||||
@echo " patch SUFFIX=<suff> Create and add a gendiff patch file"
|
||||
@echo " rediff SUFFIX=<suff> Recreates a gendiff patch file, retaining comments"
|
||||
@echo " unused-patches Print list of patches not referenced by name in specfile"
|
||||
@ -619,145 +503,3 @@ unused-patches:
|
||||
unused-fedora-patches:
|
||||
@for f in *.patch; do if [ -e $$f ]; then (egrep -q "^Patch[[:digit:]]+:[[:space:]]+$$f" $(SPECFILE) || echo "Unused: $$f") && egrep -q "^ApplyPatch[[:space:]]+$$f" $(SPECFILE) || echo "Unapplied: $$f"; fi; done
|
||||
|
||||
##################### EXPERIMENTAL ##########################
|
||||
# this stuff is very experimental in nature and should not be
|
||||
# relied upon until these targets are moved above this line
|
||||
|
||||
# This section contains some hacks that instrument
|
||||
# download-from-upstream support. You'll have to talk to gafton, he
|
||||
# knows how this shit works.
|
||||
|
||||
# Add to the list of hardcoded upstream files the contents of the
|
||||
# ./upstream file
|
||||
UPSTREAM_FILES += $(shell if test -f ./upstream ; then cat ./upstream ; fi)
|
||||
# extensions for signature files we need to retrieve for verification
|
||||
# Warning: if you update the set of defaults, please make sure to
|
||||
# update/add to the checking rules further down
|
||||
UPSTREAM_CHECKS ?= sign asc sig md5
|
||||
|
||||
# check the signatures for the downloaded upstream stuff
|
||||
UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
|
||||
|
||||
# Download a file from a particular host.
|
||||
# First argument contains the url base, the second the filename,
|
||||
# third extra curl options
|
||||
define download-host-file
|
||||
if test ! -e "$(2)" ; then \
|
||||
echo -n "URL: $(1)/$(2) ..." ; \
|
||||
$(CURL) --silent --head $(1)/$(2) && \
|
||||
{ \
|
||||
echo "OK, downloading..." ; \
|
||||
$(CURL) $(3) $(1)/$(2) ; \
|
||||
} || \
|
||||
echo "not found" ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# Download a file, trying each mirror in sequence. Also check for
|
||||
# signatures, if available
|
||||
# First argument contains the file name. We read the list of mirrors
|
||||
# from the ./mirrors file
|
||||
define download-file
|
||||
$(foreach h, $(shell cat mirrors),
|
||||
$(call download-host-file,$(h),$(1))
|
||||
if test -e $(1) ; then \
|
||||
$(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
|
||||
fi
|
||||
)
|
||||
if test ! -e $(1) ; then \
|
||||
echo "ERROR: Could not download file: $(1)" ; \
|
||||
exit -1 ; \
|
||||
else \
|
||||
echo "File $(1) available for local use" ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# Download all the UPSTREAM files
|
||||
define download-files
|
||||
$(foreach f, $(UPSTREAM_FILES),
|
||||
$(call download-file,$(f))
|
||||
echo
|
||||
)
|
||||
endef
|
||||
|
||||
# Make sure the signature files we download are properly added
|
||||
define cvs-add-upstream-sigs
|
||||
for s in $(UPSTREAM_CHECK_FILES) ; do \
|
||||
if test -f "$$s" ; then \
|
||||
if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
|
||||
cvs -Q add "$$s" ; \
|
||||
fi ; \
|
||||
fi ; \
|
||||
done
|
||||
endef
|
||||
|
||||
download : upstream mirrors
|
||||
@$(download-files)
|
||||
$(MAKE) download-checks
|
||||
|
||||
download-checks :: import-upstream-gpg
|
||||
download-checks :: $(UPSTREAM_CHECK_FILES)
|
||||
|
||||
# how to check for a gpg signature, given a separate signature file
|
||||
define check-upstream-gpg-sig
|
||||
echo -n "Checking GPG signature on $* from $@ : "
|
||||
if ! test -f $@ ; then \
|
||||
echo "ERROR" ; echo "GPG signature file $@ not found" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
|
||||
echo "FAILED" ; \
|
||||
exit 1 ; \
|
||||
else \
|
||||
echo "OK" ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# how to check for a md5sum, given a separate .md5 file
|
||||
define check-upstream-md5sum
|
||||
echo -n "Checking md5sum on $* from $@ : "
|
||||
if ! test -f $@ ; then \
|
||||
echo "ERROR" ; echo "md5sum file $@ not found" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
|
||||
echo "FAILED" ; \
|
||||
exit 1 ; \
|
||||
else \
|
||||
echo "OK" ; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# and now the rules, specific to each extension
|
||||
$(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
|
||||
@$(check-upstream-gpg-sig)
|
||||
$(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
|
||||
@$(check-upstream-gpg-sig)
|
||||
$(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
|
||||
@$(check-upstream-gpg-sig)
|
||||
$(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
|
||||
@$(check-upstream-md5sum)
|
||||
|
||||
# We keep all the relevant GPG keys in the upstream-key.gpg so we can
|
||||
# check the signatures...
|
||||
import-upstream-gpg : upstream-key.gpg FORCE
|
||||
mkdir -p $(HOME)/.gnupg
|
||||
gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
|
||||
|
||||
# A handy target to download the latest and greatest from upstream and
|
||||
# check it into the lookaside cache.
|
||||
# new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
|
||||
# rebase uses the standard "make upload"
|
||||
new-base : clean download
|
||||
$(MAKE) new-source FILES="$(UPSTREAM_FILES)"
|
||||
@$(cvs-add-upstream-sigs)
|
||||
@echo "Don't forget to do a 'cvs commit' for your new sources file."
|
||||
|
||||
rebase : clean download
|
||||
$(MAKE) upload FILES="$(UPSTREAM_FILES)"
|
||||
@$(cvs-add-upstream-sigs)
|
||||
@echo "Don't forget to do a 'cvs commit' for your new sources file."
|
||||
|
||||
# there is more stuff to clean, now that we have upstream files
|
||||
clean ::
|
||||
@rm -fv $(UPSTREAM_FILES)
|
||||
|
Loading…
Reference in New Issue
Block a user