[pacman-dev] [PATCH v4] Add makepkg-template

Florian Pritz bluewind at xinu.at
Mon May 6 14:45:39 EDT 2013


On 06.05.2013 06:50, Allan McRae wrote:
>> +# Help line for buildscript filename
>> +AC_ARG_WITH(template-dir,
>> +	AS_HELP_STRING([--with-template-dir=name], [set the template dir used by makepkg-template]),
>> +	[TEMPLATE_DIR=$withval], [TEMPLATE_DIR=/usr/share/makepkg-template])
>> +
> 
> Do we want that to be --with-makepkg-template-dir?  I am always worried
> about too generic configure names and future conflicts.

Fixed in latest patch.

>> +Template files can contain any code allowed in a PKGBUILD. You can think of
>> +them like external files included with "." or "source", but they will be
>> +inlined into the PKGBUILD by 'makepkg-template' so you do not depend on the
>> +template file if you wish to build the package.
> 
> template file when building the package
> 

Fixed.

>> +
>> +Markers are bash comments in the form of:
>> +
>> +	# template start; key=value; key2=value2; ...
>> +
>> +and
>> +
>> +	# template end;
>> +
>> +Currently used keys are: name (mandatory) and version. Values are limited to
>> +alphanumerics, "@", "+", ".", "-" and "_".
> 
> That is a limit for the values for the name.   Version is quite
> differently limited.

Right, versions are limited to "0-9."

Changed it to:
> Currently used keys are: name (mandatory) and version. Template names are limited to
> alphanumerics, "@", "+", ".", "-" and "_". Versions are limited to numbers and ".".


> 
>> +For initial creation there is a one line shortcut which doesn't need an end:
> 
> short-cut  (needs a hyphen I think)

I guess both should be valid. Changed to short-cut anyway.

> does not  (abbreviations are bad for understandability, especially for
> non-native speakers)

Interesting to hear. I always liked abbreviations more.

> need an end statement/comment/marker?

marker. Fixed.

> 
>> +
>> +	# template input; key=value;
>> +
>> +If you use this 'makepkg-template' will replace it with start and end markers
> 
> Using this short-cut will result in 'makepkg-template' replacing it with...
> 
>> +and the template code on the first run.
>> +
>> +Template files should be stored in one directory and filenames should be
>> +"$template_name-$version.template" with a symlink "$template_name.template"
>> +pointing to the most recent template.
>> +
> No new paragraph
> 
>> +If the version is not set in the marker, 'makepkg-template' will automatically
>> +use the most recent version of the template, otherwise the specified version
>> +will be used.
>> +
> 
> No new paragraph

All above fixed.

>> +This allows for easier verification of untrused PKGBUILDs if the template is
> 
> trusted
> 

That duplication of "trusted" is not intentional, right?

>> +trusted. You verify the non-template code and then use a command similar to
>> +this:
>> +
>> +	diff -u <(makepkg-template -o -) PKGBUILD
>> +
>> +Template files may also contain markers leading to nested templates in the
>> +resulting PKGBUILD. If you use markers in a template, please set the version
>> +you used/tested with in the start/input marker so other people can properly
>> +recreate from templates.
>> +
>> +Options
>> +-------
>> +
>> +*-p, \--input* <buildscript>::
>> +	Read the package script `buildscript` instead of the `PKGBUILD` default.
>> +
>> +*-o, \--output* <buildscript>::
>> +	Write the updated file to `buildscript` instead of overwriting the input file.
>> +
>> +*-n, \--newest*::
>> +	Always use the newest available template file.
>> +
>> +*\--template-dir* <dir>::
>> +	Change the dir where we are looking for template files.
>> +
>> +Example PKGBUILD
>> +----------------
>> +
>> +	pkgname=perl-config-simple
>> +	pkgver=4.58
>> +	pkgrel=1
>> +	pkgdesc="simple configuration file class"
>> +	arch=(any)
>> +	license=(PerlArtistic GPL)
>> +	depends=('perl')
>> +	source=("http://search.cpan.org/CPAN/authors/id/S/SH/SHERZODR/Config-Simple-${pkgver}.tar.gz")
>> +	md5sums=(f014aec54f0a1e2e880d317180fce502)
>> +	_distname="Config-Simple"
>> +
>> +	# template start; name=perl-module; version=1.0;
>> +	options=(!emptydirs)
> 
> options+=
> 

Fixed.

>> +	_distdir="${_distname}-${pkgver}"
>> +	url="https://metacpan.org/release/${_distname}"
>> +
>> +	build() {
>> +		export PERL_MM_USE_DEFAULT=1 PERL5LIB=""                 \
>> +		  PERL_AUTOINSTALL=--skipdeps                            \
>> +		  PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'"     \
>> +		  PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'" \
> 
> Do you really require $pkgdir to be used during build...  Not a great
> practise given who know what it is set to in split-packages  (well, I
> know...  but the point stands!)
> 

I just copied all that from an automatically generated PKGBUILD by
genpkg (script from Justin to create perl packages). I've cleaned it up
now and also did everything Eric posted.

>> +		  MODULEBUILDRC=/dev/null
>> +
>> +		cd "$srcdir/$_distdir"
>> +		/usr/bin/perl Makefile.PL
> 
> Why full path?
> 
>> +		make
>> +	}
>> +
>> +	check() {
>> +		export PERL_MM_USE_DEFAULT=1 PERL5LIB=""
>> +		cd "$srcdir/$_distdir"
>> +		make test
>> +	}
>> +
>> +	package() {
>> +		cd "$srcdir/$_distdir"
>> +		make DESTDIR="$pkgdir" install
>> +		find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
>> +	}
>> +	# template end;
>> +
>> +
>> +
>> +See Also
>> +--------
>> +linkman:makepkg[8], linkman:PKGBUILD[5]
>> +
>> +include::footer.txt[]
>> diff --git a/scripts/.gitignore b/scripts/.gitignore
>> index 9e403bf..26e088b 100644
>> --- a/scripts/.gitignore
>> +++ b/scripts/.gitignore
>> @@ -1,4 +1,5 @@
>>  makepkg
>> +makepkg-template
>>  pacman-db-upgrade
>>  pacman-key
>>  pacman-optimize
>> diff --git a/scripts/Makefile.am b/scripts/Makefile.am
>> index 784b180..1f3bae2 100644
>> --- a/scripts/Makefile.am
>> +++ b/scripts/Makefile.am
>> @@ -5,6 +5,7 @@ SUBDIRS = po
>>  
>>  bin_SCRIPTS = \
>>  	$(OURSCRIPTS) \
>> +	makepkg-template \
>>  	repo-remove \
>>  	repo-elephant
>>  
>> @@ -18,6 +19,7 @@ OURSCRIPTS = \
>>  
>>  EXTRA_DIST = \
>>  	makepkg.sh.in \
>> +	makepkg-template.pl.in \
>>  	pacman-db-upgrade.sh.in \
>>  	pacman-key.sh.in \
>>  	pacman-optimize.sh.in \
>> @@ -54,6 +56,7 @@ edit = sed \
>>  	-e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
>>  	-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
>>  	-e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
>> +	-e 's|@TEMPLATE_DIR[@]|$(TEMPLATE_DIR)|g' \
>>  	-e 's|@DEBUGSUFFIX[@]|$(DEBUGSUFFIX)|g' \
>>  	-e "s|@INODECMD[@]|$(INODECMD)|g" \
>>  	-e 's|@SIZECMD[@]|$(SIZECMD)|g' \
>> @@ -76,6 +79,14 @@ makepkg: \
>>  	$(srcdir)/makepkg.sh.in \
>>  	$(srcdir)/library/parseopts.sh
>>  
>> +makepkg-template: \
>> +	$(srcdir)/makepkg-template.pl.in \
>> +	Makefile
>> +
>> +	$(AM_V_at)$(RM) -f makepkg-template
>> +	$(AM_V_GEN)$(edit) $< > $@
>> +	$(AM_V_at)chmod +x,a-w $@
>> +
>>  pacman-db-upgrade: \
>>  	$(srcdir)/pacman-db-upgrade.sh.in \
>>  	$(srcdir)/library/output_format.sh
>> diff --git a/scripts/makepkg-template.pl.in b/scripts/makepkg-template.pl.in
>> new file mode 100755
> 
> I can comment on the perl.  Just a query if this is written in a certain
> version of perl?  Or would it be quite compatible with an older perl 5.x
> release?   In not we should add an autoconf check.

We should be compatible with >=5.10.1 according to the manpage for
given/when. I've added a check to configure.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/pacman-dev/attachments/20130506/04ba1cef/attachment.asc>


More information about the pacman-dev mailing list