2018-02-20 21:30:34 +01:00
|
|
|
DEPENDS=$(cat_file_merge "ROOTFS" | sort -u)
|
2018-01-24 12:52:41 +01:00
|
|
|
|
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-02-16 23:22:04 +01:00
|
|
|
mkdir -pv ${PKGBUILDDIR}/{bin,lib,etc,dev,sys,proc,tmp,var,run}
|
2018-04-20 09:15:20 +02:00
|
|
|
mkdir -pv ${PKGBUILDDIR}/{boot,usr,mnt}
|
2018-02-16 23:22:04 +01:00
|
|
|
mkdir -pv ${PKGBUILDDIR}/cfg/{preserve,overlay}
|
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-02-05 14:04:27 +01:00
|
|
|
|
2018-01-16 17:44:43 +01:00
|
|
|
# install packages to rootfs
|
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
|
|
|
|
|
|
|
while read pkgname; do
|
|
|
|
if [ ! -e "$PKGDEPLOYDIR/$pkgname" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2018-02-16 23:22:04 +01:00
|
|
|
cp -ru --remove-destination ${PKGDEPLOYDIR}/${pkgname}/* \
|
|
|
|
"$PKGBUILDDIR"
|
|
|
|
done < "$PKGBUILDDIR/etc/packages"
|
2018-01-18 14:23:48 +01:00
|
|
|
|
2018-02-14 13:07:23 +01:00
|
|
|
# version info
|
|
|
|
local fname=$(echo "${OS_NAME}-release" | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
2018-02-16 23:22:04 +01:00
|
|
|
echo $OS_RELEASE > $PKGBUILDDIR/etc/$fname
|
2018-02-14 13:07:23 +01:00
|
|
|
|
2018-04-20 13:12:57 +02:00
|
|
|
# remove write flag from all static files/directories
|
|
|
|
find $PKGBUILDDIR/{bin,lib,share} -type f -exec chmod a-w {} \;
|
|
|
|
find $PKGBUILDDIR/{bin,lib,share} -type d -exec chmod a-w {} \;
|
|
|
|
|
2018-02-09 13:05:48 +01:00
|
|
|
# setup root home directory
|
2018-04-19 07:23:15 +02:00
|
|
|
mkdir -p "$PKGBUILDDIR/cfg/preserve/usr"
|
2018-02-09 13:05:48 +01:00
|
|
|
|
2018-04-19 07:23:15 +02:00
|
|
|
cp -r "$PKGBUILDDIR/etc/skel" "$PKGBUILDDIR/cfg/preserve/usr/root"
|
|
|
|
chmod 750 "$PKGBUILDDIR/cfg/preserve/usr/root"
|
2018-01-18 14:23:48 +01:00
|
|
|
|
2018-04-19 07:23:15 +02:00
|
|
|
# move configuration to preserve directory
|
|
|
|
mv "$PKGBUILDDIR/etc" "$PKGBUILDDIR/cfg/preserve"
|
|
|
|
mv "$PKGBUILDDIR/var/lib" "$PKGBUILDDIR/cfg/preserve/var_lib"
|
|
|
|
rm -rf "$PKGBUILDDIR/var"
|
2018-01-23 16:34:33 +01:00
|
|
|
|
2018-04-19 07:23:15 +02:00
|
|
|
mkdir -p ${PKGBUILDDIR}/{etc,var}
|
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-02-16 23:22:04 +01:00
|
|
|
-all-root -no-progress -no-xattrs
|
2018-04-20 13:12:57 +02:00
|
|
|
|
|
|
|
# add write flag again, so we can remove the build directory
|
|
|
|
find $PKGBUILDDIR/{bin,lib,share} -type d -exec chmod u+w {} \;
|
|
|
|
find $PKGBUILDDIR/{bin,lib,share} -type f -exec chmod u+w {} \;
|
2018-01-16 17:44:43 +01:00
|
|
|
}
|