2020-05-06 15:40:06 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-06-17 16:20:28 +00:00
|
|
|
wheel_gid=1
|
2020-05-06 15:40:06 +00:00
|
|
|
phys_gid=3
|
2020-09-06 14:10:27 +00:00
|
|
|
utmp_gid=5
|
2020-05-06 15:40:06 +00:00
|
|
|
window_uid=13
|
|
|
|
window_gid=13
|
|
|
|
|
2020-09-20 19:34:14 +00:00
|
|
|
CP="cp"
|
|
|
|
|
2022-04-16 15:18:59 +00:00
|
|
|
# cp on macOS and BSD systems do not support the --preserve= option.
|
2020-09-20 19:34:14 +00:00
|
|
|
# gcp comes with coreutils, which is already a dependency.
|
2020-10-17 20:25:13 +00:00
|
|
|
OS="$(uname -s)"
|
|
|
|
if [ "$OS" = "Darwin" ] || echo "$OS" | grep -qe 'BSD$'; then
|
|
|
|
CP="gcp"
|
2020-09-20 19:34:14 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
die() {
|
|
|
|
echo "die: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2021-04-20 00:51:04 +00:00
|
|
|
[ -z "$SERENITY_SOURCE_DIR" ] && die "SERENITY_SOURCE_DIR is not set"
|
|
|
|
[ -d "$SERENITY_SOURCE_DIR/Base" ] || die "$SERENITY_SOURCE_DIR/Base doesn't exist"
|
2020-05-06 15:40:06 +00:00
|
|
|
|
|
|
|
umask 0022
|
|
|
|
|
2020-06-04 22:38:42 +00:00
|
|
|
printf "installing base system... "
|
2021-07-30 16:22:40 +00:00
|
|
|
if ! command -v rsync >/dev/null; then
|
|
|
|
die "Please install rsync."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if rsync --chown 2>&1 | grep "missing argument" >/dev/null; then
|
2022-07-06 12:25:48 +00:00
|
|
|
rsync -aH --chown=0:0 --inplace --update "$SERENITY_SOURCE_DIR"/Base/ mnt/
|
|
|
|
rsync -aH --chown=0:0 --inplace --update Root/ mnt/
|
2021-04-23 18:55:42 +00:00
|
|
|
else
|
2022-07-06 12:25:48 +00:00
|
|
|
rsync -aH --inplace --update "$SERENITY_SOURCE_DIR"/Base/ mnt/
|
|
|
|
rsync -aH --inplace --update Root/ mnt/
|
2021-07-13 05:48:21 +00:00
|
|
|
chown -R 0:0 mnt/
|
2021-04-23 18:55:42 +00:00
|
|
|
fi
|
2021-07-13 14:43:45 +00:00
|
|
|
|
2022-10-02 17:55:22 +00:00
|
|
|
SERENITY_ARCH="${SERENITY_ARCH:-x86_64}"
|
2022-04-08 21:28:25 +00:00
|
|
|
LLVM_VERSION="${LLVM_VERSION:-14.0.1}"
|
2021-07-31 13:54:48 +00:00
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
if [ "$SERENITY_TOOLCHAIN" = "Clang" ]; then
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
TOOLCHAIN_DIR="$SERENITY_SOURCE_DIR"/Toolchain/Local/clang/
|
2022-04-16 15:18:59 +00:00
|
|
|
$CP --preserve=timestamps "$TOOLCHAIN_DIR"/lib/"$SERENITY_ARCH"-pc-serenity/* mnt/usr/lib
|
2021-11-13 12:25:00 +00:00
|
|
|
mkdir -p mnt/usr/include/"$SERENITY_ARCH"-pc-serenity
|
2022-04-16 15:18:59 +00:00
|
|
|
$CP --preserve=timestamps -r "$TOOLCHAIN_DIR"/include/c++ mnt/usr/include
|
|
|
|
$CP --preserve=timestamps -r "$TOOLCHAIN_DIR"/include/"$SERENITY_ARCH"-pc-serenity/c++ mnt/usr/include/"$SERENITY_ARCH"-pc-serenity
|
2023-01-24 21:22:19 +00:00
|
|
|
else
|
|
|
|
$CP --preserve=timestamps -r "$SERENITY_SOURCE_DIR"/Toolchain/Local/"$SERENITY_ARCH"/"$SERENITY_ARCH"-pc-serenity/lib/* mnt/usr/lib
|
2022-04-16 15:18:59 +00:00
|
|
|
$CP --preserve=timestamps -r "$SERENITY_SOURCE_DIR"/Toolchain/Local/"$SERENITY_ARCH"/"$SERENITY_ARCH"-pc-serenity/include/c++ mnt/usr/include
|
2021-07-31 13:54:48 +00:00
|
|
|
fi
|
|
|
|
|
2020-06-04 22:39:53 +00:00
|
|
|
# If umask was 027 or similar when the repo was cloned,
|
|
|
|
# file permissions in Base/ are too restrictive. Restore
|
|
|
|
# the permissions needed in the image.
|
2021-04-20 00:51:04 +00:00
|
|
|
chmod -R g+rX,o+rX "$SERENITY_SOURCE_DIR"/Base/* mnt/
|
2020-06-04 22:38:42 +00:00
|
|
|
|
2021-04-29 19:40:59 +00:00
|
|
|
chmod 660 mnt/etc/WindowServer.ini
|
|
|
|
chown $window_uid:$window_gid mnt/etc/WindowServer.ini
|
2020-06-04 22:38:42 +00:00
|
|
|
echo "/bin/sh" > mnt/etc/shells
|
|
|
|
|
2021-06-15 13:12:50 +00:00
|
|
|
if [ -f mnt/bin/su ]; then
|
|
|
|
chown 0:$wheel_gid mnt/bin/su
|
|
|
|
chmod 4750 mnt/bin/su
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/passwd ]; then
|
|
|
|
chown 0:$wheel_gid mnt/bin/passwd
|
|
|
|
chmod 4755 mnt/bin/passwd
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/ping ]; then
|
|
|
|
chown 0:$wheel_gid mnt/bin/ping
|
|
|
|
chmod 4755 mnt/bin/ping
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/traceroute ]; then
|
|
|
|
chown 0:$wheel_gid mnt/bin/traceroute
|
|
|
|
chmod 4755 mnt/bin/traceroute
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/keymap ]; then
|
|
|
|
chown 0:$phys_gid mnt/bin/keymap
|
|
|
|
chmod 4750 mnt/bin/keymap
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/shutdown ]; then
|
|
|
|
chown 0:$phys_gid mnt/bin/shutdown
|
|
|
|
chmod 4750 mnt/bin/shutdown
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/reboot ]; then
|
|
|
|
chown 0:$phys_gid mnt/bin/reboot
|
|
|
|
chmod 4750 mnt/bin/reboot
|
|
|
|
fi
|
|
|
|
if [ -f mnt/bin/pls ]; then
|
|
|
|
chown 0:$wheel_gid mnt/bin/pls
|
|
|
|
chmod 4750 mnt/bin/pls
|
|
|
|
fi
|
2022-10-01 04:40:28 +00:00
|
|
|
if [ -f mnt/bin/Escalator ]; then
|
|
|
|
chown 0:$wheel_gid mnt/bin/Escalator
|
|
|
|
chmod 4750 mnt/bin/Escalator
|
|
|
|
fi
|
2021-06-15 13:12:50 +00:00
|
|
|
if [ -f mnt/bin/utmpupdate ]; then
|
|
|
|
chown 0:$utmp_gid mnt/bin/utmpupdate
|
|
|
|
chmod 2755 mnt/bin/utmpupdate
|
|
|
|
fi
|
2022-01-20 13:15:19 +00:00
|
|
|
if [ -f mnt/bin/timezone ]; then
|
|
|
|
chown 0:$phys_gid mnt/bin/timezone
|
|
|
|
chmod 4750 mnt/bin/timezone
|
|
|
|
fi
|
2021-10-22 09:02:11 +00:00
|
|
|
if [ -f mnt/usr/Tests/Kernel/TestMemoryDeviceMmap ]; then
|
|
|
|
chown 0:0 mnt/usr/Tests/Kernel/TestMemoryDeviceMmap
|
|
|
|
chmod 4755 mnt/usr/Tests/Kernel/TestMemoryDeviceMmap
|
|
|
|
fi
|
2021-10-27 22:44:35 +00:00
|
|
|
if [ -f mnt/usr/Tests/Kernel/TestProcFSWrite ]; then
|
|
|
|
chown 0:0 mnt/usr/Tests/Kernel/TestProcFSWrite
|
|
|
|
chmod 4755 mnt/usr/Tests/Kernel/TestProcFSWrite
|
|
|
|
fi
|
2021-06-15 13:12:50 +00:00
|
|
|
|
2023-01-30 12:50:28 +00:00
|
|
|
if [ -f mnt/res/kernel.map ]; then
|
|
|
|
chmod 0400 mnt/res/kernel.map
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f mnt/boot/Kernel ]; then
|
|
|
|
chmod 0400 mnt/boot/Kernel
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f mnt/boot/Kernel.debug ]; then
|
|
|
|
chmod 0400 mnt/boot/Kernel.debug
|
|
|
|
fi
|
|
|
|
|
2023-04-27 19:01:05 +00:00
|
|
|
if [ -f mnt/bin/network-settings ]; then
|
|
|
|
chown 0:0 mnt/bin/network-settings
|
|
|
|
chmod 500 mnt/bin/network-settings
|
|
|
|
fi
|
|
|
|
|
2021-01-09 16:44:44 +00:00
|
|
|
chmod 600 mnt/etc/shadow
|
2021-02-13 10:22:48 +00:00
|
|
|
chmod 755 mnt/res/devel/templates/*.postcreate
|
2020-06-04 22:38:42 +00:00
|
|
|
echo "done"
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
printf "creating initial filesystem structure... "
|
2023-03-04 12:38:33 +00:00
|
|
|
for dir in bin etc proc mnt tmp boot mod var/run usr/local usr/bin; do
|
2020-05-06 15:40:06 +00:00
|
|
|
mkdir -p mnt/$dir
|
|
|
|
done
|
|
|
|
chmod 700 mnt/boot
|
|
|
|
chmod 700 mnt/mod
|
|
|
|
chmod 1777 mnt/tmp
|
|
|
|
echo "done"
|
|
|
|
|
2020-09-06 14:10:27 +00:00
|
|
|
printf "creating utmp file... "
|
2022-07-10 20:36:36 +00:00
|
|
|
echo "{}" > mnt/var/run/utmp
|
2020-09-06 14:10:27 +00:00
|
|
|
chown 0:$utmp_gid mnt/var/run/utmp
|
|
|
|
chmod 664 mnt/var/run/utmp
|
|
|
|
echo "done"
|
|
|
|
|
2020-12-25 17:26:38 +00:00
|
|
|
printf "setting up device nodes folder... "
|
2020-05-06 15:40:06 +00:00
|
|
|
mkdir -p mnt/dev
|
2021-01-16 17:37:03 +00:00
|
|
|
echo "done"
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2021-03-13 10:02:34 +00:00
|
|
|
printf "setting up sysfs folder... "
|
|
|
|
mkdir -p mnt/sys
|
|
|
|
echo "done"
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
printf "installing users... "
|
|
|
|
mkdir -p mnt/root
|
|
|
|
mkdir -p mnt/home/anon
|
|
|
|
mkdir -p mnt/home/anon/Desktop
|
|
|
|
mkdir -p mnt/home/anon/Downloads
|
|
|
|
mkdir -p mnt/home/nona
|
2022-12-10 19:23:36 +00:00
|
|
|
# FIXME: Handle these test copies using CMake install rules
|
|
|
|
rm -fr mnt/home/anon/Tests/js-tests mnt/home/anon/Tests/web-tests mnt/home/anon/Tests/cpp-tests
|
2022-03-20 18:38:55 +00:00
|
|
|
mkdir -p mnt/home/anon/Tests/cpp-tests/
|
2021-04-20 00:51:04 +00:00
|
|
|
cp "$SERENITY_SOURCE_DIR"/README.md mnt/home/anon/
|
2022-03-20 18:41:37 +00:00
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Libraries/LibJS/Tests mnt/home/anon/Tests/js-tests
|
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Libraries/LibWeb/Tests mnt/home/anon/Tests/web-tests
|
2022-05-14 14:09:24 +00:00
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Libraries/LibCodeComprehension/Cpp/Tests mnt/home/anon/Tests/cpp-tests/comprehension
|
2022-03-20 18:38:55 +00:00
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Libraries/LibCpp/Tests/parser mnt/home/anon/Tests/cpp-tests/parser
|
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Libraries/LibCpp/Tests/preprocessor mnt/home/anon/Tests/cpp-tests/preprocessor
|
2022-03-20 18:41:37 +00:00
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Libraries/LibJS/Tests/test-common.js mnt/home/anon/Tests/wasm-tests
|
|
|
|
cp -r "$SERENITY_SOURCE_DIR"/Userland/Applications/Spreadsheet/Tests mnt/home/anon/Tests/spreadsheet-tests
|
2021-08-22 07:11:17 +00:00
|
|
|
|
|
|
|
if [ -n "$SERENITY_COPY_SOURCE" ] ; then
|
|
|
|
printf "\ncopying Serenity's source... "
|
|
|
|
rm -fr mnt/home/anon/Source/serenity
|
|
|
|
mkdir -p mnt/home/anon/Source/serenity
|
|
|
|
git clone --depth=1 file://"$SERENITY_SOURCE_DIR" mnt/home/anon/Source/serenity
|
|
|
|
rm -fr mnt/home/anon/Source/serenity/.git
|
|
|
|
fi
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
chmod 700 mnt/root
|
|
|
|
chmod 700 mnt/home/anon
|
|
|
|
chmod 700 mnt/home/nona
|
|
|
|
chown -R 100:100 mnt/home/anon
|
2023-05-20 09:03:08 +00:00
|
|
|
chown -R 200:100 mnt/home/nona
|
2020-05-06 15:40:06 +00:00
|
|
|
echo "done"
|
|
|
|
|
2021-05-27 06:52:46 +00:00
|
|
|
printf "adding some desktop icons... "
|
2023-05-09 04:05:36 +00:00
|
|
|
ln -sf /bin/Browser mnt/home/anon/Desktop/Ladybird
|
2021-05-06 11:43:00 +00:00
|
|
|
ln -sf /bin/TextEditor mnt/home/anon/Desktop/Text\ Editor
|
2021-04-23 18:55:42 +00:00
|
|
|
ln -sf /bin/Help mnt/home/anon/Desktop/
|
|
|
|
ln -sf /home/anon mnt/home/anon/Desktop/Home
|
2021-05-27 06:52:46 +00:00
|
|
|
chown -R 100:100 mnt/home/anon/Desktop
|
2021-01-21 21:56:28 +00:00
|
|
|
echo "done"
|
2020-12-27 13:51:08 +00:00
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
printf "installing shortcuts... "
|
2021-04-23 18:55:42 +00:00
|
|
|
ln -sf Shell mnt/bin/sh
|
|
|
|
ln -sf test mnt/bin/[
|
2023-03-04 12:38:33 +00:00
|
|
|
ln -sf less mnt/bin/more
|
|
|
|
ln -sf /bin/env mnt/usr/bin/env
|
2020-05-06 15:40:06 +00:00
|
|
|
echo "done"
|
|
|
|
|
2020-09-12 18:37:12 +00:00
|
|
|
printf "installing 'checksum' variants... "
|
2021-04-23 18:55:42 +00:00
|
|
|
ln -sf checksum mnt/bin/md5sum
|
|
|
|
ln -sf checksum mnt/bin/sha1sum
|
|
|
|
ln -sf checksum mnt/bin/sha256sum
|
|
|
|
ln -sf checksum mnt/bin/sha512sum
|
2020-09-12 18:37:12 +00:00
|
|
|
echo "done"
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
# Run local sync script, if it exists
|
2021-04-20 00:51:04 +00:00
|
|
|
if [ -f "${SERENITY_SOURCE_DIR}/sync-local.sh" ]; then
|
|
|
|
sh "${SERENITY_SOURCE_DIR}/sync-local.sh"
|
2020-05-06 15:40:06 +00:00
|
|
|
fi
|