[aur-general] [PATCH] initial support for any architecture.

Abhishek Dasgupta abhidg at gmail.com
Wed Mar 11 11:10:08 EDT 2009


I've also written a script, convert-to-any which takes the name of
a package like this:
   convert-to-any community/pitivi
and converts it into an arch-independent package. It also updates the repository
databases accordingly, creating the 'any' folder in the repository if
needed. This
script requires dbscripts. However, this script does not make the repo-any dir
in SVN.

#!/bin/bash
# Converts an existing package into an
# architecture-independent package and updates
# the repositories accordingly.

# -- Abhishek Dasgupta <abhidg at gmail.com>

. "$(dirname $0)/db-functions"
[ "$UID" = "" ] && UID=$(uid)

if [ $# -ne 1 ]; then
	echo "Syntax: $(basename $0) <reponame/pkgname>"
	exit 1
fi

repo=$(echo $1 | sed "s#\(.*\)/.*#\1#g"N
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"; cd "$WORKDIR/build"

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")
cd package; tar czf "$newpkgname" * .PKGINFO
cd ..; 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
repo_unlock

echo -n "Cleaning up..."
cd ../..
cleanup
echo " done."


-- 
Abhishek


More information about the aur-general mailing list