Created
May 26, 2015 21:13
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: you also need to do the following after the script has run and the git repo looks the way that you want it:
That's all.