-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfinalize.sh
executable file
·61 lines (61 loc) · 2.24 KB
/
finalize.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
# Finalize the MassOS build. Stage 3 will run this in chroot once the Stage 3
# build is finished.
set -e
# Ensure we're running in the MassOS chroot.
if [ $EUID -ne 0 ] || [ ! -d /root/mbs/sources ]; then
echo "This script should not be run manually." >&2
echo "stage3.sh will automatically run it in a chroot environment." >&2
exit 1
fi
# Set up basic environment variables, still necessary here unfortunately.
. /root/mbs/build.env
# Remove leftover junk in /root.
rm -rf /root/.{cache,cargo,cmake}
rm -rf /root/go
# Remove Debian stuff.
# TODO: Find and fix the package(s) causing files to be installed here.
rm -rf /etc/kernel
# Move any misplaced files.
# Emit warnings to remind us to fix the offending packages.
# Be verbose so we can see exactly which files are being relocated.
if [ -d /usr/etc ]; then
echo "WARNING: Relocating files in /usr/etc to /etc." >&2
echo "WARNING: Ensure all MassOS packages use the correct sysconfdir." >&2
cp -rv /usr/etc / >&2
rm -rf /usr/etc
fi
if [ -d /usr/man ]; then
echo "WARNING: Relocating files in /usr/man to /usr/share/man." >&2
echo "WARNING: Ensure all MassOS packages use the correct mandir." >&2
cp -rv /usr/man /usr/share >&2
rm -rf /usr/man
fi
# Compress manual pages.
# Future version of zman will mandate ZMAN_ALLOW_UNSAFE=1 for working on /usr.
ZMAN_ALLOW_UNSAFE=1 zman /usr/share/man
# Remove static documentation to free up space.
rm -rf /usr/share/doc/*
rm -rf /usr/doc
rm -rf /usr/docs
rm -rf /usr/share/gtk-doc/html/*
# Remove libtool archives.
find /usr/{lib,libexec} -name \*.la -delete
# Remove unwanted Python bytecode cache files in /usr/bin.
# TODO: Determine the offending package(s) and fix them in the build system.
rm -rf /usr/bin/__pycache__
# Remove any temporary files.
rm -rf /tmp/*
# As a finishing touch, run ldconfig and other misc commands.
ldconfig
glib-compile-schemas /usr/share/glib-2.0/schemas
gdk-pixbuf-query-loaders --update-cache
gtk-update-icon-cache -q -t -f --include-image-data /usr/share/icons/hicolor
gtk4-update-icon-cache -q -t -f --include-image-data /usr/share/icons/hicolor
update-desktop-database
update-mime-database /usr/share/mime
dconf update
systemd-sysusers
# Last but not least, clean up. Then the build will be ready to go.
rm -rf /root/mbs