This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
forked from MassOS-Linux/MassOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage2.sh
executable file
·47 lines (47 loc) · 1.57 KB
/
stage2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
#
# Prepare the environment for building the full MassOS system.
set -e
# Ensure we're running as root.
if [ $EUID -ne 0 ]; then
echo "Error: Must be run as root." >&2
exit 1
fi
# Setup the environment.
export MASSOS=$PWD/massos-rootfs
# Ensure stage1 has been run first.
if [ ! -d $MASSOS ]; then
echo "Error: You must run stage1.sh first!" >&2
exit 1
fi
# Ensure the MassOS environment is owned by root.
chown -R root:root $MASSOS
# Create pseudo-filesystem mount directories.
mkdir -p $MASSOS/{dev,proc,sys,run}
# Initialise /dev/console and /dev/null.
mknod -m 600 $MASSOS/dev/console c 5 1
mknod -m 666 $MASSOS/dev/null c 1 3
# Chroot into the MassOS environment and continue the build.
utils/mass-chroot massos-rootfs /sources/build-system.sh
# Strip executables and libraries to free up space.
printf "Stripping binaries... "
find $MASSOS/usr/{bin,libexec,sbin} -type f -exec strip --strip-all {} ';' &> /dev/null || true
echo "Done!"
printf "Stripping libraries... "
find $MASSOS/usr/lib -type f -name \*.a -exec strip --strip-debug {} ';' &> /dev/null || true
find $MASSOS/usr/lib -type f -name \*.so\* -exec strip --strip-unneeded {} ';' &> /dev/null || true
echo "Done!"
# Finish the MassOS system.
outfile="massos-$(cat utils/massos-release)-rootfs-x86_64.tar"
printf "Creating $outfile... "
cd $MASSOS
tar -cpf ../$outfile *
cd ..
echo "Done!"
echo "Compressing $outfile with XZ (using $(nproc) threads)..."
xz -v --threads=$(nproc) $outfile
echo "Successfully created $outfile.xz."
printf "SHA256: "
sha256sum $outfile.xz | sed "s/ $outfile.xz//"
# Clean up.
rm -rf $MASSOS