[pacman-dev] [PATCH 4/4] repo-add: add source package information to sync db

Allan McRae allan at archlinux.org
Fri Mar 28 22:19:58 EDT 2014


On 29/03/14 02:15, Andrew Gregory wrote:
> On 03/27/14 at 05:27pm, Allan McRae wrote:
>> When using the -S/--source option, add source package information to the
>> sync db if one is found alongside the package file. This could be potentially
>> used by a libalpm frontend to build package from source or provide a simple
>> replacement to the Arch Build System.
>>
>> Signed-off-by: Allan McRae <allan at archlinux.org>
>> ---
>>  doc/repo-add.8.txt     |  4 +++
>>  scripts/repo-add.sh.in | 74 ++++++++++++++++++++++++++++++++++++++++++++++++--
>>  2 files changed, 76 insertions(+), 2 deletions(-)
> 
> I am concerned that adding source package support to db's/front-ends
> will make things extremely difficult should we ever decide to replace
> makepkg and the PKGBUILD format, as has been discussed on a couple
> occasions.  If we could specify in the source package itself what
> should be used to build it, front-ends could behave more intelligently
> in the event of a transition.  Perhaps we could go ahead and add
> a minimal .SRCINFO with build tool, pkgname, and pkgver information.

I think this change is entirely independent of any future PKGBUILD
format change and .SRCINFO file.

The .SRCINFO file would be stored inside the source tarball, much like
the .PKGINFO file is inside the package tarball.  This patch just allows
frontends to locate the source tarball for a given package.

If a new PKGBUILD format was developed, I expect makepkg to become a
wrapper that detects the format and calls the old and new packaging scripts.

>> diff --git a/doc/repo-add.8.txt b/doc/repo-add.8.txt
>> index d44a8a7..fd7aafb 100644
>> --- a/doc/repo-add.8.txt
>> +++ b/doc/repo-add.8.txt
>> @@ -82,6 +82,10 @@ repo-add Options
>>  	Remove old package files from the disk when updating their entry in the
>>  	database.
>>  
>> +*-S, \--source*::
>> +	Add information about source package files to the database if found next to
>> +	the package file.
>> +
>>  Example
>>  -------
>>  
>> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
>> index 4325dbf..b9175e4 100644
>> --- a/scripts/repo-add.sh.in
>> +++ b/scripts/repo-add.sh.in
>> @@ -30,6 +30,7 @@ declare -r confdir='@sysconfdir@'
>>  
>>  QUIET=0
>>  DELTA=0
>> +SOURCE=0
>>  ONLYADDNEW=0
>>  RMEXISTING=0
>>  WITHFILES=0
>> @@ -61,6 +62,7 @@ Multiple packages to add can be specified on the command line.\n")"
>>  		printf -- "$(gettext "  -n, --new         only add packages that are not already in the database\n")"
>>  		printf -- "$(gettext "  -R, --remove      remove package file from disk when updating database entry\n")"
>>  		printf -- "$(gettext "  -f, --files       update database's file list\n")"
>> +		printf -- "$(gettext "  -S, --source      add source package information to the database\n")"
>>  	elif [[ $cmd == "repo-remove" ]] ; then
>>  		printf -- "$(gettext "Usage: repo-remove [options] <path-to-db> <packagename|delta> ...\n")"
>>  		printf -- "\n"
>> @@ -124,6 +126,31 @@ find_pkgentry() {
>>  	return 1
>>  }
>>  
>> +find_sourcepkg() {
>> +	local -a files
>> +
>> +	for i in $@; do
>> +		if [[ ${i##*.} != "sig" ]]; then
>> +			files+=("$i")
>> +		fi
>> +	done
>> +
>> +    case ${#files[@]} in
>> +      0|1)
>> +        if [[ ! -f $1 ]]; then
> 
> Won't this test the first element in the original, unfiltered, array
> rather than the file that will actually be echo'd?
> 

Good catch!  Missed updating that when I filtered out the signature files.

>> +          warning "$(gettext "No source package found")"
>> +          return 1
>> +        fi
>> +        ;;
>> +      *)
>> +        warning "$(gettext "Cannot determine source package - multiple matches found:")"
>> +        msg2 '%s' "$@"
>> +        return 1
>> +        ;;
>> +    esac
>> +    echo "$files"
> 
> Mixed tabs/spaces.
> 

Fixed.

>> +}
>> +
>>  # Get the package name from the delta filename
>>  get_delta_pkgname() {
>>  	local tmp
>> @@ -193,6 +220,37 @@ db_remove_delta() {
>>  	return 1
>>  } # end db_remove_delta
>>  
>> +# write source entry
>> +db_write_source() {
>> +	local sourcepkg pgpsigsize pgpsig czise md5sum sha256sum
>> +
>> +	sourcepkg=$1
>> +
>> +	if [[ -f "$sourcepkg.sig" ]]; then
>> +		pgpsigsize=$(@SIZECMD@ -L "$sourcepkg.sig")
>> +		if (( pgpsigsize > 16384 )); then
>> +			error "$(gettext "Invalid package signature file '%s'.")" "$sourcepkg.sig"
>> +			return 1
>> +		fi
>> +		local pgpsig=$(openssl base64 -in "$sourcepkg.sig" | tr -d '\n')
>> +	fi
>> +
>> +	csize=$(@SIZECMD@ -L "$sourcepkg")
>> +
>> +	md5sum=$(openssl dgst -md5 "$sourcepkg")
>> +	md5sum=${md5sum##* }
>> +	sha256sum=$(openssl dgst -sha256 "$sourcepkg")
>> +	sha256sum=${sha256sum##* }
>> +
>> +	{
>> +		format_entry "FILENAME"  "${sourcepkg##*/}"
>> +		format_entry "CSIZE"     "$csize"
>> +		format_entry "MD5SUM"    "$md5sum"
>> +		format_entry "SHA256SUM" "$sha256sum"
>> +		format_entry "PGPSIG"    "$pgpsig"
>> +	} >"$tmpdir/tree/$pkgname-$pkgver/source"
>> +}
>> +
>>  check_gpg() {
>>  	if ! type -p gpg >/dev/null; then
>>  		error "$(gettext "Cannot find the gpg binary! Is GnuPG installed?")"
>> @@ -264,8 +322,8 @@ db_write_entry() {
>>  	local pkgfile=$1
>>  	local -a _groups _licenses _replaces _depends _conflicts _provides \
>>  		_optdepends _makedepends _checkdepends
>> -	local pkgname pkgbase pkgver pkgdesc csize size url arch builddate packager \
>> -		md5sum sha256sum pgpsig pgpsigsize
>> +	local pkgname pkgbase pkgver basever pkgdesc csize size url arch builddate \
>> +	packager md5sum sha256sum pgpsig pgpsigsize
>>  
>>  	# read info from the zipped package
>>  	local line var val
>> @@ -398,6 +456,17 @@ db_write_entry() {
>>  		bsdtar --exclude='^.*' -tf "$pkgfile" >>"$files_path"
>>  	fi
>>  
>> +	# create a source file
>> +	if (( SOURCE )); then
>> +		msg2 "$(gettext "Creating '%s' db entry...")" 'source'
>> +		local sourcefile
>> +
>> +		if sourcefile=$(find_sourcepkg \
>> +					"${pkgbase:-$pkgname}-${basever:-$pkgver}.src.tar"*); then
> 
> This ties us to makepkg's current naming scheme for source packages
> whereas the actual package can have any arbitrary file name.  If we
> add the .SRCINFO file, could we use it to allow source packages to be
> passed as normal arguments instead of having repo-add go looking for
> them?
> 

I'd expect the .SRCINFO file to be put inside the source tarball and so
the file name would stay the same.

>> +			db_write_source "$sourcefile"
>> +		fi
>> +	fi
>> +
>>  	# create a delta file
>>  	if (( DELTA )); then
>>  		if [[ -n $oldfilename ]]; then
>> @@ -624,6 +693,7 @@ while (( $# )); do
>>  		-n|--new) ONLYADDNEW=1;;
>>  		-R|--remove) RMEXISTING=1;;
>>  		-f|--files) WITHFILES=1;;
>> +		-S|--source) SOURCE=1;;
>>  		--nocolor) USE_COLOR='n';;
>>  		-s|--sign)
>>  			check_gpg
>> -- 
>> 1.9.1
> 
> 
> 



More information about the pacman-dev mailing list