When repo-add is passed a source package, add it to the desc file. Signed-off-by: Allan McRae <al...@archlinux.org> ---
This patch is crap... but I want to know if an idea like this would even be considered before I make it suck less and implement the pacman side. The idea is "pacman -B/--build <pkg>" would download the source package file (if provided in the repo) and build the package. Of course this could be extended (e.g. -w to only download, -e allows editing the PKGBUILD prior to building, -u builds an entire update, -d builds a package but not its deps, --nopatch disables patching the build files with the patch found in /etc/pacman.d/build/$pkgbase). Is this the mindless ramblings of a lunatic, or something that would be of interest? scripts/repo-add.sh.in | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 5159ea2..80e512b 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -187,6 +187,40 @@ db_remove_delta() { return 1 } # end db_remove_delta +# write a source entry +# arg1 - path to source package file +db_write_source() { + sourcefile="$1" + + pkgbase=${1%-*-*} + + local line + while read -r line; do + # TODO - suck less (leading whitespace, variable usage, split packages...) + [[ ${line} = pkgname=* ]] && declare "$line" + [[ ${line} = pkgver=* ]] && declare "$line" + [[ ${line} = pkgrel=* ]] && declare "$line" + done< <(bsdtar -xOqf "$sourcefile" "$pkgbase/@BUILDSCRIPT@") + + # ensure needed variables were found + if [[ -z $pkgname || -z $pkgver || -z $pkgrel ]]; then + error "$(gettext "Invalid source package file '%s'.")" "$sourcefile" + return 1 + fi + + if [[ ! -f $tmpdir/tree/$pkgname-$pkgver-$pkgrel/desc ]]; then + error "$(gettext "No database entry for package '%s'.")" "$pkgname-$pkgver-$pkgrel" + return 1 + fi + + format_entry "SOURCE" "${1##*/}" >> $tmpdir/tree/$pkgname-$pkgver-$pkgrel/desc + + # TODO - will want some security here... checksum/signature + + return 0 +} + + check_gpg() { if ! type -p gpg >/dev/null; then error "$(gettext "Cannot find the gpg binary! Is GnuPG installed?")" @@ -497,6 +531,16 @@ add() { fi fi + if [[ $1 == *.src.tar?(.*) ]]; then + sourcefile=$1 + msg "$(gettext "Adding source '%s'")" "$sourcefile" + if db_write_source "$sourcefile"; then + return 0 + else + return 1 + fi + fi + pkgfile=$1 if ! bsdtar -tqf "$pkgfile" .PKGINFO >/dev/null 2>&1; then error "$(gettext "'%s' is not a package file, skipping")" "$pkgfile" -- 1.7.10