From 2c0ac7367b317e641ff0a0f228087ba3befc9eff Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Wed, 11 Mar 2009 09:27:06 -0700 Subject: Add convert-to-any script Converts an arch-specific package to the "any" arch [Aaron: converted cd to pushd/popd] Signed-off-by: Aaron Griffin --- convert-to-any | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 convert-to-any (limited to 'convert-to-any') diff --git a/convert-to-any b/convert-to-any new file mode 100644 index 0000000..b8d298c --- /dev/null +++ b/convert-to-any @@ -0,0 +1,108 @@ +#!/bin/bash +# Converts an existing package into an +# architecture-independent package and updates +# the repositories accordingly. + +# -- Abhishek Dasgupta + +. "$(dirname $0)/db-functions" +[ "$UID" = "" ] && UID=$(uid) + +if [ $# -ne 1 ]; then + echo "Syntax: $(basename $0) " + exit 1 +fi + +repo=$(echo $1 | sed "s#\(.*\)/.*#\1#g") +pkg=$(echo $1 | sed "s#.*/\(.*\)#\1#g") + +if [ -f "$(dirname $0)/config" ]; then + . "$(dirname $0)/config" +else + TMPDIR=/srv/tmp + FTP_BASE=/srv/ftp +fi + +if [ -f /etc/makepkg.conf ]; then + . /etc/makepkg.conf +else + echo "W: /etc/makepkg.conf does not exist." + DB_COMPRESSION=gz + PKGEXT=".pkg.tar.gz" +fi + +repo_lock $repo any +WORKDIR="$TMPDIR/convert-to-any.$pkg.$UID" +ftppath="$FTP_BASE/$repo/os" + +cleanup() { + trap '' 0 2 + # unlock + repo_unlock $repo any + rm -rf "$WORKDIR" + [ "$1" ] && exit $1 +} + +ctrl_c() { + echo "Interrupted" >&2 + cleanup 0 +} + +die() { + echo "$*" >&2 + cleanup 1 +} + +# Enter the temporary build directory +# and convert the i686 package into an +# architecture-independent package. +mkdir -p "$WORKDIR/build" +pushd "$WORKDIR/build" >/dev/null + +oldpkgname=$ftppath/i686/$pkg* +if [ -f "$oldpkgname" ]; then + cp "$oldpkgname" . +else + die "E: Package $oldpkgname not found in $ftppath/i686" +fi + +for architecture in i686 x86_64; do + if [ -f "$ftppath/$architecture/$repo.db.tar.$DB_COMPRESSION" ]; then + cp $ftppath/$architecture/$repo.db.tar.$DB_COMPRESSION \ + $repo-$architecture.db.tar.$DB_COMPRESSION + else + touch $repo-$architecture.db.tar.$DB_COMPRESSION + fi +done + +if [ ! -d "$ftppath/any" ]; then mkdir -p "$ftppath/any"; fi + +# Conversion of i686 package into "any" package. +echo -n "Extracting $pkg..." +mkdir -p package +tar zxf $pkg*i686$PKGEXT -C package +echo " done." + +sed -i "s/arch = i686/arch = any/g" package/.PKGINFO +newpkgname=$(ls $pkg*i686$PKGEXT | sed "s/i686/any/g") +pushd package >/dev/null +tar czf "$newpkgname" * .PKGINFO +popd >/dev/null +mv "package/$newpkgname" . +echo "Created $newpkgname." + +# New package is ready, move it into place and update db. +mv "$newpkgname" "$ftppath/any/" +for architecture in i686 x86_64; do + # rm -f $ftppath/$architecture/$pkg*$PKGEXT + ln -s "$ftppath/any/$newpkgname" "$ftppath/$architecture/$newpkgname" + repo-remove -q $repo-$architecture.db.tar.$DB_COMPRESSION $pkg + repo-add -q $repo-$architecture.db.tar.$DB_COMPRESSION $newpkgname + mv $repo-$architecture.db.tar.$DB_COMPRESSION "$ftppath/os/$architecture" + echo "Updated $repo-$architecture for $pkg." +done + +echo -n "Cleaning up..." +popd >/dev/null +cleanup +echo " done." -- cgit v1.2.3-24-g4f1b