Re: Writing get-orig-source targets to conform with policy
Bas Wijnen wrote:
> On Sun, Feb 17, 2008 at 02:39:03PM +0900, Emmet Hikory wrote:
> > More generally, consider the following get-orig-source:
> >
> > MEDIATOMB_VERSION = $(shell uscan --dehs --force-download --destdir . \
> > --package mediatomb --upstream-version 0 \
> > --watchfile $(dir $(_))/watch --no-symlink | \
> > grep upstream-version | sed 's/<.*>\(.*\)<.*>/\1/g')
> > CURRENT_VERSION ?= $(MEDIATOMB_VERSION)
> > get-orig-source:
> > tar -xzf mediatomb-$(CURRENT_VERSION).tar.gz
> > rm mediatomb-$(CURRENT_VERSION)/tombupnp/upnp/src/inc/upnp_md5.h
> > rm mediatomb-$(CURRENT_VERSION)/tombupnp/upnp/src/uuid/upnp_md5.c
> > tar czf mediatomb-$(CURRENT_VERSION)-dfsg.orig.tar.gz \
> > mediatomb-$(CURRENT_VERSION)
> > rm -r mediatomb-$(CURRENT_VERSION) mediatomb-$(CURRENT_VERSION).tar.gz
> >
> > The above requires trimming the watch file to only report one
> > upstream source, and may be run without root (or fakeroot). The use
> > of CURRENT_VERSION vs. MEDIATOMB_VERSION is to cause MEDIATOMB_VERSION
> > definition to only be executed once, at runtime. $(CURRENT VERSION)
> > is defined when the get-orig-source rule is called, and it calls
> > uscan. After this, as it is already set, the previous value is used
> > (the reason for ?=), and the call to uscan is not repeated. It works
> > for me from any directory, although it would benefit from others
> > review.
>
> The code you wrote here works for executing get-orig-source. However,
> it also runs uscan when trying to build any other target. To avoid such
> problems, I think it makes sense to use an external script. It can do
> exactly what you wrote though. :-)
It doesn't run uscan for me when I call debian/rules clean. My
understanding of makefile variable definitions is that the use of :=
determines the variable at parse time, and = determines the variable
at runtime. By setting MEDIATOMB_VERSION with =, it will run uscan
when the value is accessed. By setting CURRENT_VERSION with ?= it
sets the value only once, at time of first use. Arguably, one might
be able to set MEDIATOMB_VERSION with ?= to achieve the same effect,
but I tend to be cautious.
Anyway, my output verifing that it doesn't run uscan for clean is as follows:
$ stat debian/watch
File: `debian/watch'
Size: 246 Blocks: 8 IO Block: 4096 regular file
Device: 806h/2054d Inode: 22904871 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ persia) Gid: ( 1000/ persia)
Access: 2008-02-17 18:09:00.000000000 +0900
Modify: 2008-02-17 18:09:00.000000000 +0900
Change: 2008-02-17 18:09:00.000000000 +0900
$ fakeroot debian/rules clean
dh_testdir
dh_testroot
[ ! -f Makefile ] || /usr/bin/make clean distclean
dh_clean
[ ! -f build-stamp ] || rm build-stamp
[ ! -f configure-stamp ] || rm configure-stamp
dh_testdir
QUILT_PATCHES=debian/patches quilt pop -a -R || test $? = 2
No patch removed
[ ! -f acx_pthread.m4 ] || mv acx_pthread.m4 acinclude.m4
[ ! -f patch-stamp ] || rm patch-stamp
1$ stat debian/watch File: `debian/watch'
Size: 246 Blocks: 8 IO Block: 4096 regular file
Device: 806h/2054d Inode: 22904871 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ persia) Gid: ( 1000/ persia)
Access: 2008-02-17 18:09:00.000000000 +0900
Modify: 2008-02-17 18:09:00.000000000 +0900
Change: 2008-02-17 18:09:00.000000000 +0900
Note that the access time is not changed (and no, I've not mounted
with noatime). Further, there is no resulting
mediatomb_0.10.0.dfsg1.orig.tar.gz generated in the package directory.
--
Emmet HIKORY
Reply to: