[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debian/rules and "git rev-list" in a subshell - Automatically retrieve upstream GIT repository using ISO date to package source tarball



On Sat, Nov 06, 2010 at 02:09:08PM +0100, Danai SAE-HAN (?????????) wrote:
> Hi list

Hi Danai SAE-HAN

> 
> I'm revisiting one of my first Debian packages, "cjk".
> In debian/rules I have created a "get-orig-source" target that clones
> the upstream GIT repository and rolls it back up to the ISO date that
> is found in the Debian package version in debian/changelog (then
> converted to UNIX timestamp).
> 
> But a particular line in my old debian/rules doesn't seem to work
> anymore, and I can't find why not.  I have an ugly hack around it, but
> I'm trying to understand why my original code fails.
> At the end of the mail you will find the complete code in
> debian/rules.  Here's a minimal example:
> 
> upstream_version := cjk-4.8.2+git20090105
> unixdate := 1231196400
> 
> get-orig-source:
> 	git clone git://git.sv.gnu.org/cjk.git cjk-$(upstream_version)
> 	cd cjk-$(upstream_version) && git reset --hard $(shell cd
> cjk-$(upstream_version) && git rev-list --all -n 1
> --before=$(unixdate))
> 
> In other words, I clone the GIT repository, and then want to revert it
> to a somewhat older version, based on the UNIX timestamp.  I open a
> subshell to get the hash of the latest GIT commit before the UNIX
> timestamp.
> 
> I don't see anything wrong with the line above, but now I just get an
> empty string after "--hard".  My /bin/sh is linked to `dash'.

Could you try linking /bin/sh to /bin/bash again and test your old code again?
My guess ist you use a bashism here which in not supported in dash (found myself
such a case yesterday).

> 
> The weird thing is that I can make it work with an ugly hack using `xargs':
> 
> 	cd cjk-$(upstream_version) && echo `git rev-list --all -n 1
> --before=$(unixdate)` | xargs git reset --hard
> 
> 
> Do you have any idea why the first command doesn't work as I expect?
> Your input is most welcome.
> 
> 
> Here is a more elaborate piece of the code:
> 
> SHELL = /bin/sh
> 
> # Stuff for get-orig-source.
> upstream_version := $(shell dpkg-parsechangelog | sed -ne 's/^Version:
> \(.*\)-.*/\1/p')
> isodate := $(shell dpkg-parsechangelog | sed -ne
> 's/^Version.*git\(.*\)-.*/\1/p')
> unixdate := $(shell date -d $(isodate) +%s)
> # Add 24 hours to the Unix time.
> unixdate := $(shell expr $(unixdate) + 86400 )
> 
> 
> get-orig-source:
> 	# Cleaning
> 	rm -rf cjk-$(upstream_version)
> 	rm -f ../cjk_$(upstream_version).orig.tar.gz
> 
> 	# Download the latest GIT version and downgrade it to $(isodate).
> 	git clone git://git.sv.gnu.org/cjk.git cjk-$(upstream_version)
> 
> #	cd cjk-$(upstream_version) && git reset --hard $(shell cd
> cjk-$(upstream_version) && git rev-list --all -n 1
> --before=$(unixdate))
> #unixdate = 1231196400
> #hash of GIT commit = 1d3f869e61dc5139d16596075a9e2c4e9a2f503f
> # Ugly hack with "xargs" that works.
> 	cd cjk-$(upstream_version) && echo `git rev-list --all -n 1
> --before=$(unixdate)` | xargs git reset --hard
> 
> 	# Make a pristine package.
> # --no-name/-n is important because it won't save the timestamp in the
> # 5th to 8th byte of the gzip.
> 	cd cjk-$(upstream_version) && git archive --format=tar
> --prefix=cjk-$(upstream_version)/ master | gzip -9 --no-name >
> ../../tarballs/cjk_$(upstream_version).orig.tar.gz
> 
> 	# Clean again, because we use svn-buildpackage afterwards.
> 	rm -rf cjk-$(upstream_version)
> 
> 
> 
> BR
> 
> 
> -- 
> Danai

Kind regards
Harald Jenny

> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: [🔎] AANLkTikWqNr5vEbRFgNNLiPsBPd6PcO1uGjEq0s-qvJe@mail.gmail.com">http://lists.debian.org/[🔎] AANLkTikWqNr5vEbRFgNNLiPsBPd6PcO1uGjEq0s-qvJe@mail.gmail.com


Reply to: