]>
git.ipfire.org Git - thirdparty/systemd.git/blob - mkosi.build
4 # This is a build script for OS image generation using mkosi (https://github.com/systemd/mkosi).
5 # Simply invoke "mkosi" in the project directory to build an OS image.
7 # Reset the permissions of the tree. Since Meson keeps the permissions
8 # all the way to the installed files, reset them to one of 0644 or 0755
9 # so the files keep those permissions, otherwise details of what umask
10 # was set at the time the git tree was cloned will leak all the way
11 # through. Also set umask explicitly during the build.
12 if ! mountpoint
-q "$SRCDIR"; then
13 chmod -R u
+w
,go-w
,a
+rX .
17 # On Fedora "ld" is (unfortunately — if you ask me) managed via
18 # "alternatives". Since we'd like to support building images in environments
19 # with only /usr/ around (e.g. mkosi's UsrOnly=1 option), we have the problem
20 # that /usr/bin/ld is a symlink that points to a non-existing file in
21 # /etc/alternative/ in this mode. Let's work around this for now by manually
22 # redirect "ld" to "ld.bfd", i.e. circumventing the /usr/bin/ld symlink.
23 if [ ! -x /usr
/bin
/ld
-a -x /usr
/bin
/ld.bfd
] ; then
25 ln -s /usr
/bin
/ld.bfd
"$HOME"/bin
/ld
26 PATH
="$HOME/bin:$PATH"
29 # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it
30 # as out-of-tree build dir. Otherwise, let's make up our own builddir.
31 [ -z "$BUILDDIR" ] && BUILDDIR
=build
33 # Meson uses Python 3 and requires a locale with an UTF-8 character map.
34 # Not running under UTF-8 makes the `ninja test` step break with a CodecError.
35 # So let's ensure we're running under UTF-8.
37 # If our current locale already is UTF-8, then we don't need to do anything:
38 if [ "$(locale charmap 2> /dev/null)" != "UTF-8" ] ; then
39 # Try using C.UTF-8 locale, if available. This locale is not shipped
40 # by upstream glibc, so it's not available in all distros.
41 # (In particular, it's not available in Arch Linux.)
42 if locale
-a |
grep -q -E "C.UTF-8|C.utf8"; then
43 export LC_CTYPE
=C.UTF-8
44 # Finally, try something like en_US.UTF-8, which should be
45 # available in Arch Linux, but is not present in Debian's
46 # minimal image in our mkosi config.
47 elif locale
-a |
grep -q en_US.utf8
; then
48 export LC_CTYPE
=en_US.UTF-8
50 # If nothing works, fail early.
51 echo "*** Could not find a valid locale that supports UTF-8. ***" >&2
56 if [ ! -f "$BUILDDIR"/build.ninja
] ; then
57 sysvinit_path
=`realpath /etc/init.d`
59 init_path
=`realpath /sbin/init 2>/dev/null`
60 if [ -z "$init_path" ] ; then
63 rootprefix
=${init_path%/lib/systemd/systemd}
64 rootprefix
=/${rootprefix#/}
67 nobody_user
=`id -u -n 65534 2> /dev/null`
68 if [ "$nobody_user" != "" ] ; then
69 # Validate that we can translate forth and back
70 if [ "`id -u $nobody_user`" != 65534 ] ; then
74 if [ "$nobody_user" = "" ] ; then
75 if id
-u nobody
2> /dev
/null
; then
76 # The "nobody" user is defined already for something else, pick the Fedora name
79 # The "nobody" user name is free, use it
84 nobody_group
=`id -g -n 65534 2> /dev/null`
85 if [ "$nobody_group" != "" ] ; then
86 # Validate that we can translate forth and back
87 if [ "`id -g $nobody_group`" != 65534 ] ; then
91 if [ "$nobody_group" = "" ] ; then
92 if id
-u nobody
2> /dev
/null
; then
93 # The "nobody" group is defined already for something else, pick the Fedora name
94 nobody_group
=nfsnobody
96 # The "nobody" group name is free, use it
102 -D "sysvinit-path=$sysvinit_path" \
103 -D "rootprefix=$rootprefix" \
105 -D "nobody-user=$nobody_user" \
106 -D "nobody-group=$nobody_group" \
107 -D translations
=false \
108 -D version-tag
="${VERSION_TAG}"
113 if [ "$WITH_TESTS" = 1 ] ; then
115 getent group
$id > /dev
/null || groupadd
-g $id testgroup
$id
122 # Ubuntu Focal is stuck with meson 0.53.0.
123 if [ "$(meson -v | cut -d . -f 2)" -gt 53 ] ; then
124 meson
install -C "$BUILDDIR" --quiet --no-rebuild --only-changed
126 meson
install -C "$BUILDDIR" --no-rebuild --only-changed
129 mkdir
-p "$DESTDIR"/etc
131 cat > "$DESTDIR"/etc
/issue
<<EOF
132 \S (built from systemd tree)
133 Kernel \r on an \m (\l)
137 # Manually update the boot loader from the one we just built
138 mkdir
-p "$DESTDIR"/boot
/efi
/EFI
/systemd
"$DESTDIR"/boot
/efi
/EFI
/BOOT
139 cp "$DESTDIR"/usr
/lib
/systemd
/boot
/efi
/systemd-bootx64.efi
"$DESTDIR"/boot
/efi
/EFI
/systemd
/systemd-bootx64.efi
140 cp "$DESTDIR"/usr
/lib
/systemd
/boot
/efi
/systemd-bootx64.efi
"$DESTDIR"/boot
/efi
/EFI
/BOOT
/bootx64.efi
142 mkdir
-p "$DESTDIR"/efi
/EFI
/systemd
"$DESTDIR"/efi
/EFI
/BOOT
143 cp "$DESTDIR"/usr
/lib
/systemd
/boot
/efi
/systemd-bootx64.efi
"$DESTDIR"/efi
/EFI
/systemd
/systemd-bootx64.efi
144 cp "$DESTDIR"/usr
/lib
/systemd
/boot
/efi
/systemd-bootx64.efi
"$DESTDIR"/efi
/EFI
/BOOT
/bootx64.efi