mirror of
https://github.com/pygos/build.git
synced 2024-11-22 11:09:46 +01:00
90b2586ea4
Every package now has or generates a rootfs_files.txt containing a list of files that should be packed into the rootfs, their permissions and their owner. This gives us fine grained controll over the owners and permissions of the rootfs files (by generating a squashfs pseudo file). In subsequent steps, this allows us to remove the deploy/devdeploy split and actually simplifiy most of the build scripts. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
91 lines
2.3 KiB
Text
Executable file
91 lines
2.3 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" ]; 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"
|
|
|
|
# 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 750 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"
|
|
}
|
|
|
|
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
|
|
}
|