[arch-general] [PATCH 0/3] Three smelly patches for commitpkg
First two patches are somewhat trivial. The third one adds support for uploading packages to multiple architectures. Let me explain the rationale behind the last patch. My workflow goes something like this: 1) sudo makechrootpkg -c -r /opt/arch/stable-i686 2) sudo makechrootpkg -c -r /opt/arch/stable-x86_64 3) scp *pkg* aur.archlinux.org:staging/community 4) source PKGBUILD; svn commit -m "$pkgname $pkgver-$pkgrel random message" 5) archrelease community-i686 6) archrelease community-x86_64 7) ssh aur.archlinux.org /arch/db-community As you can see, I'm doing all steps manually (which is time-consuming and prone to errors). Unless I'm missing an existing way to upload packages to both architectures using commitpkg (via its communitypkg symlink), the third patch can help automate steps 3-6 above. I uploaded one package (that needed updating) using the modified commitpkg and it worked as expected. However, more testing is needed, especially with split packages. Please let me know what you think. :)
--- commitpkg | 46 +++++++++++++++++++++++----------------------- 1 files changed, 23 insertions(+), 23 deletions(-) diff --git a/commitpkg b/commitpkg index 0d13c6d..15f6981 100755 --- a/commitpkg +++ b/commitpkg @@ -2,7 +2,7 @@ # Source makepkg.conf; fail if it is not found if [ -r "/etc/makepkg.conf" ]; then - source "/etc/makepkg.conf" + source "/etc/makepkg.conf" else echo "/etc/makepkg.conf not found!" exit 1 @@ -10,7 +10,7 @@ fi # Source user-specific makepkg.conf overrides if [ -r ~/.makepkg.conf ]; then - source ~/.makepkg.conf + source ~/.makepkg.conf fi cmd=$(basename $0) @@ -47,49 +47,49 @@ for _pkgname in ${pkgname[@]}; do fi fi -# set up repo-specific opts depending on how we were called + # set up repo-specific opts depending on how we were called server="gerolde.archlinux.org" if [ "$cmd" == "extrapkg" ]; then - repo="extra" + repo="extra" elif [ "$cmd" == "corepkg" ]; then - repo="core" + repo="core" elif [ "$cmd" == "testingpkg" ]; then - repo="testing" + repo="testing" elif [ "$cmd" == "communitypkg" ]; then - repo="community" - server="aur.archlinux.org" + repo="community" + server="aur.archlinux.org" elif [ "$cmd" == "community-testingpkg" ]; then - repo="community-testing" - server="aur.archlinux.org" + repo="community-testing" + server="aur.archlinux.org" else - if [ $# -eq 0 ]; then + if [ $# -eq 0 ]; then echo "usage: commitpkg <reponame> [-l limit] [commit message]" exit 1 - fi - repo="$1" - shift + fi + repo="$1" + shift fi -# see if any limit options were passed, we'll send them to SCP + # see if any limit options were passed, we'll send them to SCP unset scpopts if [ "$1" = "-l" ]; then - scpopts="$1 $2" - shift 2 + scpopts="$1 $2" + shift 2 fi -# combine what we know into a variable + # combine what we know into a variable uploadto="staging/${repo}/$(basename ${pkgfile})" scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then - echo "File got corrupted during upload, cancelled." - exit 1 + echo "File got corrupted during upload, cancelled." + exit 1 else - echo "File integrity okay." + echo "File integrity okay." fi if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 + echo "Cancelled" + exit 1 fi echo "===> Uploaded $pkgfile" done -- 1.6.4.4
--- commitpkg | 60 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 30 insertions(+), 30 deletions(-) diff --git a/commitpkg b/commitpkg index 15f6981..d7b4b6c 100755 --- a/commitpkg +++ b/commitpkg @@ -28,6 +28,36 @@ fi source PKGBUILD pkgbase=${pkgbase:-${pkgname[0]}} +# set up repo-specific opts depending on how we were called +server="gerolde.archlinux.org" +if [ "$cmd" == "extrapkg" ]; then + repo="extra" +elif [ "$cmd" == "corepkg" ]; then + repo="core" +elif [ "$cmd" == "testingpkg" ]; then + repo="testing" +elif [ "$cmd" == "communitypkg" ]; then + repo="community" + server="aur.archlinux.org" +elif [ "$cmd" == "community-testingpkg" ]; then + repo="community-testing" + server="aur.archlinux.org" +else + if [ $# -eq 0 ]; then + echo "usage: commitpkg <reponame> [-l limit] [commit message]" + exit 1 + fi + repo="$1" + shift +fi + +# see if any limit options were passed, we'll send them to SCP +unset scpopts +if [ "$1" = "-l" ]; then + scpopts="$1 $2" + shift 2 +fi + for _pkgname in ${pkgname[@]}; do pkgfile=${_pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} anypkgfile=${_pkgname}-${pkgver}-${pkgrel}-any${PKGEXT} @@ -47,36 +77,6 @@ for _pkgname in ${pkgname[@]}; do fi fi - # set up repo-specific opts depending on how we were called - server="gerolde.archlinux.org" - if [ "$cmd" == "extrapkg" ]; then - repo="extra" - elif [ "$cmd" == "corepkg" ]; then - repo="core" - elif [ "$cmd" == "testingpkg" ]; then - repo="testing" - elif [ "$cmd" == "communitypkg" ]; then - repo="community" - server="aur.archlinux.org" - elif [ "$cmd" == "community-testingpkg" ]; then - repo="community-testing" - server="aur.archlinux.org" - else - if [ $# -eq 0 ]; then - echo "usage: commitpkg <reponame> [-l limit] [commit message]" - exit 1 - fi - repo="$1" - shift - fi - - # see if any limit options were passed, we'll send them to SCP - unset scpopts - if [ "$1" = "-l" ]; then - scpopts="$1 $2" - shift 2 - fi - # combine what we know into a variable uploadto="staging/${repo}/$(basename ${pkgfile})" scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" -- 1.6.4.4
Now commitpkg will go through each architecture defined in the PKGBUILD and if all packages are present, it will upload them and run archrelease for that architecture. --- commitpkg | 98 ++++++++++++++++++++++++++++-------------------------------- 1 files changed, 46 insertions(+), 52 deletions(-) diff --git a/commitpkg b/commitpkg index d7b4b6c..a8bff51 100755 --- a/commitpkg +++ b/commitpkg @@ -20,11 +20,6 @@ if [ ! -f PKGBUILD ]; then exit 1 fi -if [ -z "$CARCH" ]; then - echo "CARCH must be set to a recognized value!" - exit 1 -fi - source PKGBUILD pkgbase=${pkgbase:-${pkgname[0]}} @@ -58,68 +53,67 @@ if [ "$1" = "-l" ]; then shift 2 fi -for _pkgname in ${pkgname[@]}; do - pkgfile=${_pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} - anypkgfile=${_pkgname}-${pkgver}-${pkgrel}-any${PKGEXT} +for CARCH in ${arch[@]}; do + echo "===> Uploading to $repo-$CARCH" + for _pkgname in ${pkgname[@]}; do + pkgfile=${_pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} - if [ ! -f $pkgfile ]; then - if [ -f $PKGDEST/$pkgfile ]; then + if [ ! -f $pkgfile -a -f $PKGDEST/$pkgfile ]; then pkgfile=$PKGDEST/$pkgfile - elif [ -f $anypkgfile ]; then - pkgfile=$anypkgfile - CARCH=any - elif [ -f $PKGDEST/$anypkgfile ]; then - pkgfile=$PKGDEST/$anypkgfile - CARCH=any - else + elif [ ! -f $pkgfile ]; then echo "File $pkgfile doesn't exist" + # skip to next architecture + continue 2 + fi + + # combine what we know into a variable + uploadto="staging/${repo}/$(basename ${pkgfile})" + # don't re-upload the same package (useful for -any sub packages) + if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then + scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" + fi + if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then + echo "File got corrupted during upload, cancelled." exit 1 + else + echo "File integrity okay." fi - fi - # combine what we know into a variable - uploadto="staging/${repo}/$(basename ${pkgfile})" - scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" - if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then - echo "File got corrupted during upload, cancelled." - exit 1 + if [ $? -ne 0 ]; then + echo "Cancelled" + exit 1 + fi + echo "===> Uploaded $pkgfile" + done + + if [ "$1" != "" ]; then + svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel + $1" > /dev/null + if [ $? -ne 0 ]; then + echo "Cancelled" + exit 1 + fi + echo "===> Commited with message: + upgpkg: $pkgbase $pkgver-$pkgrel + $1" else - echo "File integrity okay." + svn commit + if [ $? -ne 0 ]; then + echo "Cancelled" + exit 1 + fi + echo "===> Commited" fi + archrelease $repo-$CARCH if [ $? -ne 0 ]; then echo "Cancelled" exit 1 fi - echo "===> Uploaded $pkgfile" + echo "===> Tagged for $repo-$CARCH" done -if [ "$1" != "" ]; then - svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel - $1" > /dev/null - if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 - fi - echo "===> Commited with \"upgpkg: $pkgbase $pkgver-$pkgrel - $1\" message" -else - svn commit - if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 - fi - echo "===> Commited" -fi - -archrelease $repo-$CARCH -if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 -fi -echo "===> Tagged for $repo-$CARCH" - -if [ "$CARCH" == "any" ]; then +if [ "${arch[*]}" == "any" ]; then if [ -d ../repos/${repo}-i686 -a -d ../repos/${repo}-x86_64 ]; then pushd .. svn rm $repo-i686 -- 1.6.4.4
participants (1)
-
Evangelos Foutras