Skip to content

Instantly share code, notes, and snippets.

@bbidulock
Created May 26, 2015 21:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbidulock/82ab6f5347f021136054 to your computer and use it in GitHub Desktop.
Save bbidulock/82ab6f5347f021136054 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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