[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

Danai SAE-HAN (韓達耐) wrote:
> 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))

Make expands your $(shell) before the git clone, so there is no
directory for it to operate on. That's why the build log contains:

cd: 1: can't cd to cjk-cjk-4.8.2+git20090105
git clone git://git.sv.gnu.org/cjk.git cjk-cjk-4.8.2+git20090105
Cloning into cjk-cjk-4.8.2+git20090105...

One way to work around this is to split the git clone off into
a dependant target. Make will then only run the subshell after
it has satisfied dependencies:

get-orig-source: clone
	cd cjk-$(upstream_version) && git reset --hard $(shell cd cjk-$(upstream_version) && git rev-list --all -n 1 --before=$(unixdate))

	git clone git://git.sv.gnu.org/cjk.git cjk-$(upstream_version)

Another way is to just avoid $(shell). As a bonus you don't need to cd
again inside the subshell, since it runs after the first cd.

	cd cjk-$(upstream_version) && git reset --hard `git rev-list --all -n 1 --before=$(unixdate)`

see shy jo

Attachment: signature.asc
Description: Digital signature

Reply to: