PKGBUILDs/scripts/rfs-pacman

37 lines
777 B
Bash
Executable file

#!/bin/bash
# rfs-pacman
# simplified rootfs manipulation with pacman.
##
# current directory
PWD=`pwd`
# does this directory have etc/pacman.conf?
if [ -f $PWD/etc/pacman.conf ]; then
SHORT=`echo $PWD | sed 's/.*\///'`
ARCH=`grep 'Architecture =' etc/pacman.conf | sed 's/Architecture = //'`
echo "Calling pacman:"
echo " -root: $PWD"
echo " -arch: $ARCH"
SEDPWD=`echo $PWD | sed 's/\\//\\\\\//g'`
sed "s/\/etc\/pacman.d/$SEDPWD\/etc\/pacman.d/" \
$PWD/etc/pacman.conf > etc/pacman.conf.rfs
pacman \
-r $PWD \
-b $PWD/var/lib/pacman \
--arch $ARCH \
--cachedir $PWD/var/cache/pacman/pkg \
--config $PWD/etc/pacman.conf.rfs \
--logfile $PWD/../$SHORT.pacman.log \
$@
rm $PWD/etc/pacman.conf.rfs
else
echo "'$PWD' doesn't appear to be a rootfs."
fi