]>
git.ipfire.org Git - thirdparty/systemd.git/blob - mkosi.build
2 # SPDX-License-Identifier: LGPL-2.1-or-later
5 # This is a build script for OS image generation using mkosi (https://github.com/systemd/mkosi).
6 # Simply invoke "mkosi" in the project directory to build an OS image.
8 # On Fedora "ld" is (unfortunately — if you ask me) managed via
9 # "alternatives". Since we'd like to support building images in environments
10 # with only /usr/ around (e.g. mkosi's UsrOnly=1 option), we have the problem
11 # that /usr/bin/ld is a symlink that points to a non-existing file in
12 # /etc/alternative/ in this mode. Let's work around this for now by manually
13 # redirect "ld" to "ld.bfd", i.e. circumventing the /usr/bin/ld symlink.
14 if [ ! -x /usr
/bin
/ld
] && [ -x /usr
/bin
/ld.bfd
]; then
16 ln -s /usr
/bin
/ld.bfd
"$HOME"/bin
/ld
17 PATH
="$HOME/bin:$PATH"
20 # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it
21 # as out-of-tree build dir. Otherwise, let's make up our own builddir.
22 [ -z "$BUILDDIR" ] && BUILDDIR
=build
24 # Meson uses Python 3 and requires a locale with an UTF-8 character map.
25 # Not running under UTF-8 makes the `ninja test` step break with a CodecError.
26 # So let's ensure we're running under UTF-8.
28 # If our current locale already is UTF-8, then we don't need to do anything:
29 if [ "$(locale charmap 2>/dev/null)" != "UTF-8" ] ; then
30 # Try using C.UTF-8 locale, if available. This locale is not shipped
31 # by upstream glibc, so it's not available in all distros.
32 # (In particular, it's not available in Arch Linux.)
33 if locale
-a |
grep -q -E "C.UTF-8|C.utf8"; then
34 export LC_CTYPE
=C.UTF-8
35 # Finally, try something like en_US.UTF-8, which should be
36 # available in Arch Linux, but is not present in Debian's
37 # minimal image in our mkosi config.
38 elif locale
-a |
grep -q en_US.utf8
; then
39 export LC_CTYPE
=en_US.UTF-8
41 # If nothing works, fail early.
42 echo "*** Could not find a valid locale that supports UTF-8. ***" >&2
47 if [ ! -f "$BUILDDIR"/build.ninja
] ; then
48 sysvinit_path
=$
(realpath
/etc
/init.d
)
50 init_path
=$
(realpath
/sbin
/init
2>/dev
/null
)
51 if [ -z "$init_path" ] ; then
54 rootprefix
=${init_path%/lib/systemd/systemd}
55 rootprefix
=/${rootprefix#/}
59 -D "sysvinit-path=$sysvinit_path" \
60 -D "rootprefix=$rootprefix" \
62 -D translations
=false \
63 -D version-tag
="${VERSION_TAG}"
68 if [ "$WITH_TESTS" = 1 ] ; then
70 getent group
$id >/dev
/null || groupadd
-g $id testgroup
$id
77 # Ubuntu Focal is stuck with meson 0.53.0.
78 if [ "$(meson -v | cut -d . -f 2)" -gt 53 ] ; then
79 meson
install -C "$BUILDDIR" --quiet --no-rebuild --only-changed
81 meson
install -C "$BUILDDIR" --no-rebuild --only-changed
84 mkdir
-p "$DESTDIR"/etc
86 cat >"$DESTDIR"/etc
/issue
<<EOF
87 \S (built from systemd tree)
88 Kernel \r on an \m (\l)
92 if [ -n "$IMAGE_ID" ] ; then
93 mkdir
-p "$DESTDIR"/usr
/lib
96 -e "\$aIMAGE_ID=$IMAGE_ID" <"/usr/lib/os-release" >"${DESTDIR}/usr/lib/os-release"
98 OSRELEASEFILE
="$DESTDIR"/usr
/lib
/os-release
100 OSRELEASEFILE
=/usr
/lib
/os-release
104 if [ -n "$IMAGE_VERSION" ] ; then
105 mkdir
-p "$DESTDIR"/usr
/lib
107 -e '/^IMAGE_VERSION=/!p' \
108 -e "\$aIMAGE_VERSION=$IMAGE_VERSION" <$OSRELEASEFILE >"/tmp/os-release.tmp"
110 cat /tmp
/os-release.tmp
> "$DESTDIR"/usr
/lib
/os-release
111 rm /tmp
/os-release.tmp