1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-11-14 07:27:10 +01:00
build/pkg/rootfs/build
David Oberhollenzer 51a2c5ea17 Fix permissions for root user home directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-09-15 20:25:27 +02:00

107 lines
2.8 KiB
Text
Executable file

DEPENDS=$(cat_file_merge "ROOTFS" | sort -u)
copy_rootfs_files() {
local pkgdir="$1"
local fname
local dname
cut -d' ' -f1 "$pkgdir/rootfs_files.txt" | while read fname; do
if [ ! -e "./$fname" ]; then
dname=$(dirname $fname)
if [ -d "$pkgdir/$fname" ] && [ ! -L "$pkgdir/$fname" ]
then
mkdir -p "./$fname"
else
[ "$dname" == "." ] || mkdir -p "./$dname";
cp -d "$pkgdir/$fname" "./$fname"
fi
fi
done
}
build() {
local SOURCE="$1"
local DEPLOY="$2"
# setup skeleton
mkdir -pv ${PKGBUILDDIR}/{bin,dev,sys,proc,tmp,run,boot,usr,mnt,share}
mkdir -pv ${PKGBUILDDIR}/cfg/{preserve,overlay}
mkdir -pv ${PKGBUILDDIR}/etc/{profile.d,skel}
mkdir -pv ${PKGBUILDDIR}/var/lib
mkdir -pv ${PKGBUILDDIR}/lib/libexec
cp -r "$SCRIPTDIR/pkg/$PKGNAME/etc" "$PKGBUILDDIR"
cp -r "$SCRIPTDIR/pkg/$PKGNAME/lib" "$PKGBUILDDIR"
cp "$SCRIPTDIR/pkg/$PKGNAME/rootfs_files.txt" "$DEPLOY/pseudo"
# version info
local fname=$(echo "${OS_NAME}-release" | tr '[:upper:]' '[:lower:]')
echo $OS_RELEASE > $PKGBUILDDIR/etc/$fname
echo "etc/$fname m 644 0 0" >> "$DEPLOY/pseudo"
# local config files
fname=$(file_path_override "resolv.conf")
if [ ! -z "$fname" ]; then
cp "$fname" "./etc/resolv.conf"
echo "etc/resolv.conf m 644 0 0" >> "$DEPLOY/pseudo"
fi
# gather rootfs dependencies
dependencies | tsort | tac | \
grep -v "$PKGNAME" > "$PKGBUILDDIR/etc/packages"
echo "etc/packages m 644 0 0" >> "$DEPLOY/pseudo"
while read pkgname; do
fname="$PKGDEPLOYDIR/$pkgname/rootfs_files.txt"
[ -e "$fname" ] || continue;
copy_rootfs_files "$PKGDEPLOYDIR/$pkgname"
cat "$fname" >> "$DEPLOY/pseudo"
done < "$PKGBUILDDIR/etc/packages"
# setup root home directory
cp -r "$PKGBUILDDIR/etc/skel" "$PKGBUILDDIR/usr/root"
echo "usr/root m 700 0 0" >> "$DEPLOY/pseudo"
find "./usr/root" -exec stat {} --printf="%n m %a 0 0\\n" \; | \
sed 's#^./##g' | tail -n +2 >> "$DEPLOY/pseudo"
# move configuration to preserve directory
mv "$PKGBUILDDIR/etc" "$PKGBUILDDIR/cfg/preserve/etc"
mv "$PKGBUILDDIR/usr" "$PKGBUILDDIR/cfg/preserve/usr"
mv "$PKGBUILDDIR/var/lib" "$PKGBUILDDIR/cfg/preserve/var_lib"
rm -rf "$PKGBUILDDIR/var"
mkdir -p ${PKGBUILDDIR}/{etc,var,usr}
sed -i 's#etc/#cfg/preserve/etc/#g' "$DEPLOY/pseudo"
sed -i 's#var/lib/#cfg/preserve/var_lib/#g' "$DEPLOY/pseudo"
sed -i 's#usr/#cfg/preserve/usr/#g' "$DEPLOY/pseudo"
# don't add stuff for the boot partition to the squashfs image
mv ${PKGBUILDDIR}/boot/* "$DEPLOY"
grep -v "^boot/" "$DEPLOY/pseudo" > "$DEPLOY/pseudo.temp"
mv "$DEPLOY/pseudo.temp" "$DEPLOY/pseudo"
echo "boot m 750 0 0" >> "$DEPLOY/pseudo"
}
deploy() {
local SOURCE="$1"
local DEPLOY="$2"
mksquashfs "$PKGBUILDDIR" "$DEPLOY/rootfs.img" -comp xz \
-no-progress -no-xattrs -pf "$DEPLOY/pseudo"
rm "$DEPLOY/pseudo"
}
check_update() {
return
}