Graças às dicas na resposta do warl0ck eu escrevi este script fakepkg
:
#!/bin/bash
set -e
OLDDIR=$PWD
NEWDIR=$(mktemp -dt fakepack.XXX)
cd $NEWDIR
yaourt -G $1
cd $1
#TODO this can probably be retrieved from the pacman desc file
while true; do
read -p "Edit PKGBUILD? [yn]" -n1 yn
case $yn in
[Yy]* ) $EDITOR PKGBUILD; break;;
[Nn]* ) echo; break;;
* ) echo ;;
esac
done
. PKGBUILD
srcdir=$NEWDIR/$1/src
# In case you are wondering: this tries to compensate for packages not using
# a simple src/packagename-pkgver/ structure. It will probably still break...
PKSUB=$(eval "echo $(grep -o '\${\?srcdir.*pkgver}\?' PKGBUILD | head -n1 )")
SRC=${PKSUB##$NEWDIR/$1/}
echo "Putting the $1 source to $SRC"
PKG=$pkgname-$pkgver
# SRC="src/$PKG/"
FILES="/var/lib/pacman/local/$PKG-$pkgrel/files"
if [ ! -f $FILES ]; then
echo "$FILES not found, is $1 actually installed?"
exit 1
fi
#TODO use existing sources or skip this entirely
# but it's the easiest way to later use makepkg -R
echo "Reloading source"
makepkg -o
echo "Collecting $1 files"
mkdir -p $SRC/files/
while IFS= read -r line; do
if [ -f "/$line" ]; then
mkdir -p $SRC/files/$(dirname $line)
rsync -a /$line $SRC/files/$line
fi
done < $FILES
echo "Creating fake Makefile"
echo 'install:' > $SRC/Makefile
echo ' mv files/* $(DESTDIR)' >> $SRC/Makefile
rm -f $SRC/GNUmakefile
echo "Creating package"
makepkg -R
mv *.xz $OLDDIR
cd $OLDDIR
rm -rf $NEWDIR
Execute fakepkg packagename
, adapte PKGBUILD
se necessário e espere por um package---.pak.tar.xz
em seu diretório atual.
Há muito espaço para melhorias, claro, por exemplo modificando automaticamente PKGBUILD
de acordo com a instalação desc
e não baixando a fonte inteira. Mas por enquanto funciona bem o suficiente.