[Build-common-hackers] Bug#576507: Please merge functionality for repackaging tarballs

Reinhard Tartler siretart at tauware.de
Mon Apr 5 08:44:32 UTC 2010


Package: devscripts
Version: 2.10.61
Severity: wishlist

In CDBS 1/rules/upstream-tarball.mk targets for repackaging tarballs are
included. I believe that this functionality is better suited for
descripts than a packaging helper scripts. Please consider merging
something like that in the devscripts package.

get-orig-source:
	@@dh_testdir
	@@mkdir -p "$(DEB_UPSTREAM_WORKDIR)"

	@if [ ! -s "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" ] ; then \
		if [ -f "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" ] ; then \
			rm "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" ; \
		fi ; \
		echo "Downloading $(cdbs_upstream_received_tarball) from $(DEB_UPSTREAM_URL)/$(cdbs_upstream_tarball) ..." ; \
		wget -nv -T10 -t3 -O "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" "$(DEB_UPSTREAM_URL)/$(cdbs_upstream_tarball)" ; \
	else \
		echo "Upstream source tarball have been already downloaded: $(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" ; \
	fi

	@md5current=`md5sum "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" | sed -e 's/ .*//'`; \
	if [ -n "$(DEB_UPSTREAM_TARBALL_MD5)" ] ; then \
		if [ "$$md5current" != "$(DEB_UPSTREAM_TARBALL_MD5)" ] ; then \
			echo "Expecting upstream tarball md5sum $(DEB_UPSTREAM_TARBALL_MD5), but $$md5current found" ; \
			echo "Upstream tarball md5sum is NOT trusted! Possible upstream tarball forge!" ; \
			echo "Purging downloaded file. Try new download." ; \
			rm -f "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" ; \
			false ; \
		else \
			echo "Upstream tarball is trusted!" ; \
		fi; \
	else \
		echo "Upstream tarball NOT trusted (current md5sum is $$md5current)!" ; \
	fi

# TODO: Rewrite using make variables like cdbs_upstream_unpack_cmd and
# DEB_UPSTREAM_SUPPORTED_COMPRESSIONS (recent dpkg supports bz2)
# TODO: Add .orig suffix to top folder inside tarball when only
# recompressing (when $uncompress set and ...REPACKAGE_EXCLUDE unset)
	@untar="tar -x -C"; \
	case "$(cdbs_upstream_received_tarball)" in \
	    *.tar.gz)  unpack="gunzip -c";; \
	    *.tar.bz2) unpack="bunzip2 -c"; grep -q '3.0 (quilt)' debian/source/format || uncompress="bunzip2";; \
	    *.tar.Z)   unpack="uncompress -c"; uncompress="uncompress";; \
	    *.zip)     unpack="unzip -q";      uncompress="false";       untar="-d"; nopipe="true";; \
	    *.tar)     unpack="cat";           uncompress="true";; \
	    *) echo "Unknown extension for upstream tarball $(cdbs_upstream_received_tarball)"; false;; \
	esac && \
	if [ -n "$(strip $(DEB_UPSTREAM_REPACKAGE_EXCLUDES))" ] || [ "$$uncompress" = "false" ]; then \
		echo "Repackaging tarball ..." && \
		mkdir -p "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)" && \
		if [ -n "$$nopipe" ]; then \
			$$unpack "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" \
				$$untar "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)"; \
		else \
			$$unpack "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" \
				| $$untar "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)"; \
		fi && \
		if [ -n "$(cdbs_upstream_findargs_files)" ]; then \
			(set -e; cd "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(DEB_UPSTREAM_TARBALL_SRCDIR)" && find $(cdbs_upstream_findargs_files) -delete); \
		fi && \
		if [ -n "$(cdbs_upstream_findargs_dirs)" ]; then \
			(set -e; cd "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(DEB_UPSTREAM_TARBALL_SRCDIR)" && find $(cdbs_upstream_findargs_dirs) -exec rm -rf '{}' +;) \
		fi && \
		if [ "$(DEB_UPSTREAM_TARBALL_SRCDIR)" != "$(cdbs_upstream_local_srcdir)" ]; then \
			mv -T "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(DEB_UPSTREAM_TARBALL_SRCDIR)" "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(cdbs_upstream_local_srcdir)"; \
		fi && \
		GZIP=-9 tar -b1 -czf "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_local_basename).orig.tar.gz" -C "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)" "$(cdbs_upstream_local_srcdir)" && \
		echo "Cleaning up" && \
		rm -rf "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)"; \
	elif [ -n "$$uncompress" ]; then \
		echo "Recompressing tarball ..." && \
		$$uncompress "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)"; \
		gzip -9 "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_local_basename).orig.tar"; \
	fi

fail-source-not-repackaged:
	$(cdbs_python_exclude_check)
	@if find $(cdbs_upstream_findargs_files) $(and $(cdbs_upstream_findargs_files),$(cdbs_upstream_findargs_dirs),-o) $(cdbs_upstream_findargs_dirs) | grep '.*'; then \
		echo; \
		echo 'ERROR: Source contains the files/paths listed above'; \
		echo '       which was intended to not be distributed with the source.'; \
		echo '       Please repackage source with these items stripped!'; \
		echo '       (set DEB_UPSTREAM_REPACKAGE_EXCLUDES and use get-orig-source target)'; \
		exit 1; \
	fi





More information about the Build-common-hackers mailing list