Skip to content

Instantly share code, notes, and snippets.

@bbidulock bbidulock/mkaur4
Created May 26, 2015

Embed
What would you like to do?
My script for migrating AUR3 to AUR4 (I keep a copy of all src and bin packages in a .backup subdirectory).
#!/bin/bash
if [ ! -d .git ] ; then
if [ ! -f PKGBUILD ] ; then
echo "ERROR: need PKGBUILD to do anything!" >&2
exit 1
fi
echo "--> initializing git repository"
git init
echo "--> rebuilding .SRCINFO file"
mksrcinfo
if [ -f .SRCINFO ] ; then
echo "--> adding .SRCINFO"
git add .SRCINFO
else
echo "ERROR: no .SRCINFO generated" >&2
exit 1
fi
pkgbase=$(cat .SRCINFO|grep '^pkgbase = '|awk '{print$3;}')
if [ -z "$pkgbase" ] ; then
echo "ERROR: no pkgbase" >&2
exit 1
else
echo "--> pkgbase is $pkgbase"
fi
echo "--> adding PKGBUILD"
git add PKGBUILD
ifiles=$(cat .SRCINFO|grep '^[[:space:]]*install = '|awk '{print$3;}')
echo "--> install files: $ifiles"
cfiles=$(cat .SRCINFO|grep '^[[:space:]]*changelog = '|awk '{print$3;}')
echo "--> changelog files: $cfiles"
sfiles=$(cat .SRCINFO|grep '^[[:space:]]*source = '|awk '{print$3;}')
echo "--> source files: $sfiles"
for f in $ifiles $cfiles $sfiles; do
echo "--> checking $f"
if [ -f $f ] ; then
echo "--> adding $f"
git add $f
else
echo "WARNING: file $f does not exist"
fi
done
echo "--> commiting initial version"
git commit -m 'initial version'
echo "--> adding aur4 as remote aur"
git remote add --tags aur ssh+git://aur4.archlinux.org/${pkgbase}.git/
if [ -d .backup ]; then
echo "--> processing .backup directory"
srcfiles=$(ls -rt .backup/${pkgbase}-*.src.tar.gz)
for f in $srcfiles ; do
if [ -f $f ] ; then
echo "--> processing $f"
echo " --> untarring $f"
tar --strip-components=1 -xvf $f
echo " --> making .SRCINFO for $f"
mksrcinfo
files=$(tar -tf $f|sed 's,.*/,,')
echo " --> adding .SRCINFO $files"
git add .SRCINFO $files
v=$(echo "$f"|sed "s,\.backup/$pkgbase-,,;s,\.src.tar.gz,,")
d=$(stat -c '%y' "$f"|awk '{print$1" "$2;}'|sed 's,\..*$,,')
echo " --> commiting version $v"
git commit -m "version $v" --date="$d"
fi
done
fi
fi
@bbidulock

This comment has been minimized.

Copy link
Owner Author

commented Jun 1, 2015

Note: you also need to do the following after the script has run and the git repo looks the way that you want it:

$> git push -u aur master

That's all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.