2018-02-20 21:30:34 +01:00
|
|
|
DEPENDS=$(cat_file_merge "ROOTFS" | sort -u)
|
2018-01-24 12:52:41 +01:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
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" ]; then
|
|
|
|
mkdir -p "./$fname"
|
|
|
|
else
|
|
|
|
[ "$dname" == "." ] || mkdir -p "./$dname";
|
|
|
|
cp -d "$pkgdir/$fname" "./$fname"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-01-16 17:44:43 +01:00
|
|
|
build() {
|
|
|
|
local SOURCE="$1"
|
2018-02-16 23:22:04 +01:00
|
|
|
local DEPLOY="$2"
|
2018-01-16 17:44:43 +01:00
|
|
|
|
|
|
|
# setup skeleton
|
2018-06-16 17:46:17 +02:00
|
|
|
mkdir -pv ${PKGBUILDDIR}/{bin,dev,sys,proc,tmp,run,boot,usr,mnt,share}
|
2018-02-16 23:22:04 +01:00
|
|
|
mkdir -pv ${PKGBUILDDIR}/cfg/{preserve,overlay}
|
2018-06-16 17:46:17 +02:00
|
|
|
mkdir -pv ${PKGBUILDDIR}/etc/{profile.d,skel}
|
|
|
|
mkdir -pv ${PKGBUILDDIR}/var/lib
|
|
|
|
mkdir -pv ${PKGBUILDDIR}/lib/libexec
|
2018-01-16 17:44:43 +01:00
|
|
|
|
2018-02-16 23:22:04 +01:00
|
|
|
cp -r "$SCRIPTDIR/pkg/$PKGNAME/etc" "$PKGBUILDDIR"
|
2018-02-17 14:47:42 +01:00
|
|
|
cp -r "$SCRIPTDIR/pkg/$PKGNAME/lib" "$PKGBUILDDIR"
|
2018-06-16 17:46:17 +02:00
|
|
|
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
|
2018-02-05 14:04:27 +01:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
echo "etc/$fname m 644 0 0" >> "$DEPLOY/pseudo"
|
|
|
|
|
|
|
|
# gather rootfs dependencies
|
2018-02-16 23:22:04 +01:00
|
|
|
dependencies | tsort | tac | \
|
|
|
|
grep -v "$PKGNAME" > "$PKGBUILDDIR/etc/packages"
|
2018-01-16 17:44:43 +01:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
echo "etc/packages m 644 0 0" >> "$DEPLOY/pseudo"
|
|
|
|
|
2018-01-16 17:44:43 +01:00
|
|
|
while read pkgname; do
|
2018-06-16 17:46:17 +02:00
|
|
|
fname="$PKGDEPLOYDIR/$pkgname/rootfs_files.txt"
|
|
|
|
[ -e "$fname" ] || continue;
|
2018-01-16 17:44:43 +01:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
copy_rootfs_files "$PKGDEPLOYDIR/$pkgname"
|
|
|
|
cat "$fname" >> "$DEPLOY/pseudo"
|
2018-02-16 23:22:04 +01:00
|
|
|
done < "$PKGBUILDDIR/etc/packages"
|
2018-01-18 14:23:48 +01:00
|
|
|
|
2018-02-09 13:05:48 +01:00
|
|
|
# setup root home directory
|
2018-06-16 17:46:17 +02:00
|
|
|
cp -r "$PKGBUILDDIR/etc/skel" "$PKGBUILDDIR/usr/root"
|
|
|
|
|
|
|
|
echo "usr/root m 750 0 0" >> "$DEPLOY/pseudo"
|
2018-02-09 13:05:48 +01:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
find "./usr/root" -exec stat {} --printf="%n m %a 0 0\\n" \; | \
|
|
|
|
sed 's#^./##g' | tail -n +2 >> "$DEPLOY/pseudo"
|
2018-01-18 14:23:48 +01:00
|
|
|
|
2018-04-19 07:23:15 +02:00
|
|
|
# move configuration to preserve directory
|
2018-06-16 17:46:17 +02:00
|
|
|
mv "$PKGBUILDDIR/etc" "$PKGBUILDDIR/cfg/preserve/etc"
|
|
|
|
mv "$PKGBUILDDIR/usr" "$PKGBUILDDIR/cfg/preserve/usr"
|
2018-04-19 07:23:15 +02:00
|
|
|
mv "$PKGBUILDDIR/var/lib" "$PKGBUILDDIR/cfg/preserve/var_lib"
|
|
|
|
rm -rf "$PKGBUILDDIR/var"
|
2018-01-23 16:34:33 +01:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
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"
|
2018-01-16 17:44:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
deploy() {
|
|
|
|
local SOURCE="$1"
|
2018-02-16 23:22:04 +01:00
|
|
|
local DEPLOY="$2"
|
2018-01-16 17:44:43 +01:00
|
|
|
|
2018-02-22 19:51:44 +01:00
|
|
|
mksquashfs "$PKGBUILDDIR" "$DEPLOY/rootfs.img" -comp xz \
|
2018-06-16 17:46:17 +02:00
|
|
|
-no-progress -no-xattrs -pf "$DEPLOY/pseudo"
|
2018-04-20 13:12:57 +02:00
|
|
|
|
2018-06-16 17:46:17 +02:00
|
|
|
rm "$DEPLOY/pseudo"
|
2018-01-16 17:44:43 +01:00
|
|
|
}
|
2018-05-06 17:23:31 +02:00
|
|
|
|
|
|
|
check_update() {
|
|
|
|
return
|
2018-06-16 17:46:17 +02:00
|
|
|
}
|