diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-08-08 16:03:11 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-08-08 16:03:11 +0200 |
commit | 830c4d84d13712974ffd392cdcc58b038c0dcfd9 (patch) | |
tree | 43ebdbef0d019de1d6dfda8a1f4a98dc94284375 | |
parent | 8a377f398ef5a01f8b52695597152c49d7a64f96 (diff) |
Source PKGBUILD in subshells
This patch sources a PKGBUILD in a subshells instead of directly.
This way we don't polute our scope or overwrite our vars which might lead to unexpected behavior.
-rwxr-xr-x | db-move | 48 | ||||
-rwxr-xr-x | db-remove | 22 | ||||
-rwxr-xr-x | db-update | 42 | ||||
-rwxr-xr-x | misc-scripts/make-sourceball | 15 | ||||
-rwxr-xr-x | misc-scripts/sourceballs-cleanup | 3 |
5 files changed, 68 insertions, 62 deletions
@@ -11,20 +11,20 @@ fi packagebase="$1" repofrom="$2" repoto="$3" -_arch="$4" -if [ "${_arch}" == 'any' ]; then - _tarches=('i686' 'x86_64') +arch="$4" +if [ "${arch}" == 'any' ]; then + tarches=('i686' 'x86_64') else - _tarches=("${_arch}") + tarches=("${arch}") fi ftppath_from="$FTP_BASE/$repofrom/os/" ftppath_to="$FTP_BASE/$repoto/os/" -svnrepo_from="$repofrom-$_arch" -svnrepo_to="$repoto-$_arch" +svnrepo_from="$repofrom-$arch" +svnrepo_to="$repoto-$arch" -repo_lock $repoto $_arch || exit 1 -repo_lock $repofrom $_arch || exit 1 +repo_lock $repoto $arch || exit 1 +repo_lock $repofrom $arch || exit 1 cd "$WORKDIR" /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null @@ -32,7 +32,9 @@ cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo_from" ]; then - . "$packagebase/repos/$svnrepo_from/PKGBUILD" + pkgname=($(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) + pkgver=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) echo -n "Moving $packagebase from $repofrom to $repoto..." if [ -d "$packagebase/repos/$svnrepo_to" ]; then @@ -41,28 +43,28 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then fi /usr/bin/svn mv -q -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to" - /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($_arch)" + /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($arch)" - _pkgfiles='' + pkgfiles='' for i in ${pkgname[@]}; do - for _tarch in ${_tarches[@]}; do - _pkgpath=$(getpkgfile "$ftppath_from/${_tarch}/"$i-$pkgver-$pkgrel-$_arch$PKGEXT) - _pkgfile=$(basename "${_pkgpath}") + for tarch in ${tarches[@]}; do + pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) + pkgfile=$(basename "${pkgpath}") # copy package to pool if needed # TODO: can be removed once every package has been moved to the package pool - if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/$_pkgfile ]; then - cp $_pkgpath $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/ + if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/${arch}/$pkgfile ]; then + cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host)/${arch}/ fi - ln -s "../../../$(get_pkgpool_for_host)/${_arch}/${_pkgfile}" $ftppath_to/${_tarch}/ + ln -s "../../../$(get_pkgpool_for_host)/${arch}/${pkgfile}" $ftppath_to/${tarch}/ done - _pkgfiles="${_pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/${_pkgfile}" + pkgfiles="${pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${arch}/${pkgfile}" done - for _tarch in ${_tarches[@]}; do - /usr/bin/repo-add -q "$ftppath_to/${_tarch}/$repoto$DBEXT" ${_pkgfiles} >/dev/null || die "Error in repo-add $_pkgfiles" - /usr/bin/repo-remove -q "$ftppath_from/${_tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" + for tarch in ${tarches[@]}; do + /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${pkgfiles} >/dev/null || die "Error in repo-add $pkgfiles" + /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" done echo 'done' @@ -70,5 +72,5 @@ else die "Error: $packagebase is not in repo $repofrom" fi -repo_unlock $repoto $_arch || exit 1 -repo_unlock $repofrom $_arch || exit 1 +repo_unlock $repoto $arch || exit 1 +repo_unlock $repofrom $arch || exit 1 @@ -10,12 +10,12 @@ fi packagebase="$1" reponame="$2" -_arch="$3" +arch="$3" ftppath="$FTP_BASE/$reponame/os" -svnrepo="$reponame-$_arch" +svnrepo="$reponame-$arch" -repo_lock $reponame $_arch || exit 1 +repo_lock $reponame $arch || exit 1 echo -n "Removing $packagebase from $reponame..." cd "$WORKDIR" @@ -24,7 +24,7 @@ cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo" ]; then - . "$packagebase/repos/$svnrepo/PKGBUILD" + pkgname=($(. "$packagebase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo" /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un)" else @@ -33,23 +33,23 @@ fi cd "$WORKDIR" -if [ "$_arch" == "any" ]; then +if [ "$arch" == "any" ]; then arches="i686 x86_64" else - arches="$_arch" + arches="$arch" fi # copy the db file into our working area -for arch in $arches; do - if [ ! -f "$ftppath/$arch/$reponame$DBEXT" ]; then - die "No database found at '$ftppath/$arch', nothing more to do" +for tarch in $arches; do + if [ ! -f "$ftppath/$tarch/$reponame$DBEXT" ]; then + die "No database found at '$ftppath/$tarch', nothing more to do" fi - /usr/bin/repo-remove -q "$ftppath/$arch/$reponame$DBEXT" ${pkgname[@]} >/dev/null + /usr/bin/repo-remove -q "$ftppath/$tarch/$reponame$DBEXT" ${pkgname[@]} >/dev/null done echo 'done' -repo_unlock $reponame $_arch || exit 1 +repo_unlock $reponame $arch || exit 1 # vim: set ts=4 sw=4 noet ft=sh: @@ -62,23 +62,24 @@ if [ -n "$ANYPKGS" ]; then cd checkout to_add_any="" for pkg in $ANYPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $pkg)" - _pkgbase="$(getpkgbase $pkg)" + pkgfile=$(basename $pkg) + pkgname="$(getpkgname $pkg)" + pkgbase="$(getpkgbase $pkg)" svnrepo="$reponame-any" if ! check_pkg_arch "$pkg" "any"; then - echo " ERROR: $_pkgfile is not architecture independent!" + echo " ERROR: $pkgfile is not architecture independent!" else - /usr/bin/svn up -q $_pkgbase - if [ -d "$_pkgbase/repos/$svnrepo" ]; then - . "$_pkgbase/repos/$svnrepo/PKGBUILD" - if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-any"; then + /usr/bin/svn up -q $pkgbase + if [ -d "$pkgbase/repos/$svnrepo" ]; then + pkgver=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgrel}) + if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-any"; then to_add_any="$to_add_any $pkg" else - echo " WARNING: $_pkgfile does not match PKGBUILD in $svnrepo" + echo " WARNING: $pkgfile does not match PKGBUILD in $svnrepo" fi else - echo " WARNING: Package $_pkgbase not found in $svnrepo" + echo " WARNING: Package $pkgbase not found in $svnrepo" fi fi done @@ -132,23 +133,24 @@ for current_arch in ${ARCHES[@]}; do if [ -n "$ADDPKGS" ]; then for pkg in $ADDPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $pkg)" - _pkgbase="$(getpkgbase $pkg)" + pkgfile=$(basename $pkg) + pkgname="$(getpkgname $pkg)" + pkgbase="$(getpkgbase $pkg)" if ! check_pkg_arch "$pkg" "$current_arch"; then - echo " ERROR: $_pkgfile was built for the wrong architecture" + echo " ERROR: $pkgfile was built for the wrong architecture" else - /usr/bin/svn up -q $_pkgbase - if [ -d "$_pkgbase/repos/$svnrepo" ]; then - . "$_pkgbase/repos/$svnrepo/PKGBUILD" - if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-$current_arch"; then + /usr/bin/svn up -q $pkgbase + if [ -d "$pkgbase/repos/$svnrepo" ]; then + pkgver=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgrel}) + if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-$current_arch"; then to_add="$to_add $pkg" else - echo " WARNING: $_pkgfile does not match PKGBUILD in $svnrepo" + echo " WARNING: $pkgfile does not match PKGBUILD in $svnrepo" fi else - echo " WARNING: Package $_pkgbase not found in $svnrepo" + echo " WARNING: Package $pkgbase not found in $svnrepo" fi fi done diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index 6e57385..8e26eec 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -17,7 +17,7 @@ fi packagename="$1" reponame="$2" -_arch="$3" +arch="$3" srcpath="$FTP_BASE/sources/" logpath="/var/log/sourceballs/" @@ -27,7 +27,8 @@ script_lock create_srcpackage() { if [ -d "$1" ]; then pushd "$1" >/dev/null - . "PKGBUILD" + pkgver=$(. PKGBUILD; echo ${pkgver}) + pkgrel=$(. PKGBUILD; echo ${pkgrel}) if ! [ $FORCE == 1 ] && ! chk_license ${license[@]} ; then #Removed so as not to clutter failed.txt #echo -e "\t$packagename license (${license[@]}) does not require source tarballs" >&2 @@ -40,7 +41,7 @@ create_srcpackage() { if ! /usr/bin/makepkg --allsource --ignorearch >"$logfile" 2>&1; then popd >/dev/null /bin/gzip -f -9 "$logfile" - die "\tFailed to download source for $packagename-$pkgver-$pkgrel ($reponame-$_arch)" + die "\tFailed to download source for $packagename-$pkgver-$pkgrel ($reponame-$arch)" fi /bin/rm -f "$logfile"{,.gz} @@ -63,15 +64,15 @@ cd "$WORKDIR" if [[ "$reponame" = "community" || "$reponame" = "community-testing" ]]; then if /usr/bin/svn export -q "$SVNREPOCOMMUNITY/$packagename" $packagename; then - create_srcpackage "$packagename/repos/$reponame-$_arch" + create_srcpackage "$packagename/repos/$reponame-$arch" else - die "\tPackage '$packagename' does not exist in repo '$reponame-$_arch'" + die "\tPackage '$packagename' does not exist in repo '$reponame-$arch'" fi else if /usr/bin/svn export -q "$SVNREPO/$packagename" $packagename; then - create_srcpackage "$packagename/repos/$reponame-$_arch" + create_srcpackage "$packagename/repos/$reponame-$arch" else - die "\tPackage '$packagename' does not exist in repo '$reponame-$_arch'" + die "\tPackage '$packagename' does not exist in repo '$reponame-$arch'" fi fi diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index e058c38..e407989 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -14,7 +14,8 @@ remove_old() { PKGVERS="" for repo in *; do cd "$repo" - . "PKGBUILD" + pkgver=$(. PKGBUILD; echo ${pkgver}) + pkgrel=$(. PKGBUILD; echo ${pkgrel}) PKGVERS="$PKGVERS $pkgver-$pkgrel" cd .. done |