]>
git.ipfire.org Git - thirdparty/systemd.git/blob - mkosi.build
4 # This file is part of systemd.
6 # Copyright 2016 Lennart Poettering
8 # systemd is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 2.1 of the License, or
11 # (at your option) any later version.
13 # systemd is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 # This is a build script for OS image generation using mkosi (https://github.com/systemd/mkosi).
22 # Simply invoke "mkosi" in the project directory to build an OS image.
24 # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it
25 # as out-of-tree build dir. Otherwise, let's make up our own builddir.
26 [ -z "$BUILDDIR" ] && BUILDDIR
=build
28 # Meson uses Python 3 and requires a locale with an UTF-8 character map.
29 # Not running under UTF-8 makes the `ninja test` step break with a CodecError.
30 # So let's ensure we're running under UTF-8.
32 # If our current locale already is UTF-8, then we don't need to do anything:
33 if [ "$(locale charmap)" != "UTF-8" ] ; then
34 # Try using C.UTF-8 locale, if available. This locale is not shipped
35 # by upstream glibc, so it's not available in all distros.
36 # (In particular, it's not available in Arch Linux.)
37 export LC_CTYPE
=C.UTF-8
38 if [ "$(locale charmap)" != "UTF-8" ] ; then
39 # Finally, try something like en_US.UTF-8, which should be
40 # available in Arch Linux, but is not present in Debian's
41 # minimal image in our mkosi config.
42 export LC_CTYPE
=en_US.UTF-8
43 if [ "$(locale charmap)" != "UTF-8" ] ; then
44 # If nothing works, fail early.
45 echo "*** Could not find a valid locale that supports UTF-8. ***" >&2
51 if [ ! -f "$BUILDDIR"/build.ninja
] ; then
52 sysvinit_path
=`realpath /etc/init.d`
54 nobody_user
=`id -u -n 65534 2> /dev/null`
55 if [ "$nobody_user" != "" ] ; then
56 # Validate that we can translate forth and back
57 if [ "`id -u $nobody_user`" != 65534 ] ; then
61 if [ "$nobody_user" = "" ] ; then
62 if id
-u nobody
2> /dev
/null
; then
63 # The "nobody" user is defined already for something else, pick the Fedora name
66 # The "nobody" user name is free, use it
71 nobody_group
=`id -g -n 65534 2> /dev/null`
72 if [ "$nobody_group" != "" ] ; then
73 # Validate that we can translate forth and back
74 if [ "`id -g $nobody_group`" != 65534 ] ; then
78 if [ "$nobody_group" = "" ] ; then
79 if id
-u nobody
2> /dev
/null
; then
80 # The "nobody" group is defined already for something else, pick the Fedora name
81 nobody_group
=nfsnobody
83 # The "nobody" group name is free, use it
88 meson
"$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D default-hierarchy
=unified
-D man
=false
-D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group"
91 ninja
-C "$BUILDDIR" all
92 [ "$WITH_TESTS" = 0 ] || ninja
-C "$BUILDDIR" test ||
( RET
="$?" ; cat "$BUILDDIR"/meson-logs
/testlog.txt
; exit "$RET" )
93 ninja
-C "$BUILDDIR" install
95 mkdir
-p "$DESTDIR"/etc
97 cat > "$DESTDIR"/etc
/issue
<<EOF
98 \S (built from systemd tree)
99 Kernel \r on an \m (\l)