]>
Commit | Line | Data |
---|---|---|
7629744a | 1 | #!/bin/sh |
2 | set -ex | |
1b0ff615 LP |
3 | |
4 | # This file is part of systemd. | |
5 | # | |
6 | # Copyright 2016 Lennart Poettering | |
7 | # | |
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. | |
12 | # | |
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. | |
17 | # | |
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/>. | |
20 | ||
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. | |
23 | ||
b454cfb0 FB |
24 | # Reset the permissions of the tree. Since Meson keeps the permissions |
25 | # all the way to the installed files, reset them to one of 0644 or 0755 | |
26 | # so the files keep those permissions, otherwise details of what umask | |
27 | # was set at the time the git tree was cloned will leak all the way | |
28 | # through. Also set umask explicitly during the build. | |
29 | chmod -R u+w,go-w,a+rX . | |
30 | umask 022 | |
31 | ||
70e760e3 LP |
32 | # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it |
33 | # as out-of-tree build dir. Otherwise, let's make up our own builddir. | |
34 | [ -z "$BUILDDIR" ] && BUILDDIR=build | |
35 | ||
2ea09665 FB |
36 | # Meson uses Python 3 and requires a locale with an UTF-8 character map. |
37 | # Not running under UTF-8 makes the `ninja test` step break with a CodecError. | |
38 | # So let's ensure we're running under UTF-8. | |
39 | # | |
40 | # If our current locale already is UTF-8, then we don't need to do anything: | |
41 | if [ "$(locale charmap)" != "UTF-8" ] ; then | |
42 | # Try using C.UTF-8 locale, if available. This locale is not shipped | |
43 | # by upstream glibc, so it's not available in all distros. | |
44 | # (In particular, it's not available in Arch Linux.) | |
45 | export LC_CTYPE=C.UTF-8 | |
46 | if [ "$(locale charmap)" != "UTF-8" ] ; then | |
47 | # Finally, try something like en_US.UTF-8, which should be | |
48 | # available in Arch Linux, but is not present in Debian's | |
49 | # minimal image in our mkosi config. | |
50 | export LC_CTYPE=en_US.UTF-8 | |
51 | if [ "$(locale charmap)" != "UTF-8" ] ; then | |
52 | # If nothing works, fail early. | |
53 | echo "*** Could not find a valid locale that supports UTF-8. ***" >&2 | |
54 | exit 1 | |
55 | fi | |
56 | fi | |
57 | fi | |
9400405b | 58 | |
c81a2569 LP |
59 | if [ ! -f "$BUILDDIR"/build.ninja ] ; then |
60 | sysvinit_path=`realpath /etc/init.d` | |
8da0592c | 61 | |
c81a2569 LP |
62 | nobody_user=`id -u -n 65534 2> /dev/null` |
63 | if [ "$nobody_user" != "" ] ; then | |
64 | # Validate that we can translate forth and back | |
65 | if [ "`id -u $nobody_user`" != 65534 ] ; then | |
66 | nobody_user="" | |
67 | fi | |
c82ce4f2 | 68 | fi |
c81a2569 LP |
69 | if [ "$nobody_user" = "" ] ; then |
70 | if id -u nobody 2> /dev/null ; then | |
71 | # The "nobody" user is defined already for something else, pick the Fedora name | |
72 | nobody_user=nfsnobody | |
73 | else | |
74 | # The "nobody" user name is free, use it | |
75 | nobody_user=nobody | |
76 | fi | |
c82ce4f2 | 77 | fi |
c82ce4f2 | 78 | |
c81a2569 LP |
79 | nobody_group=`id -g -n 65534 2> /dev/null` |
80 | if [ "$nobody_group" != "" ] ; then | |
81 | # Validate that we can translate forth and back | |
82 | if [ "`id -g $nobody_group`" != 65534 ] ; then | |
83 | nobody_group="" | |
84 | fi | |
c82ce4f2 | 85 | fi |
c81a2569 LP |
86 | if [ "$nobody_group" = "" ] ; then |
87 | if id -u nobody 2> /dev/null ; then | |
88 | # The "nobody" group is defined already for something else, pick the Fedora name | |
89 | nobody_group=nfsnobody | |
90 | else | |
91 | # The "nobody" group name is free, use it | |
92 | nobody_group=nobody | |
93 | fi | |
c82ce4f2 | 94 | fi |
c81a2569 LP |
95 | |
96 | meson "$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D default-hierarchy=unified -D man=false -D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group" | |
c82ce4f2 LP |
97 | fi |
98 | ||
70e760e3 | 99 | ninja -C "$BUILDDIR" all |
2ba6e738 | 100 | [ "$WITH_TESTS" = 0 ] || ninja -C "$BUILDDIR" test || ( RET="$?" ; cat "$BUILDDIR"/meson-logs/testlog.txt ; exit "$RET" ) |
70e760e3 | 101 | ninja -C "$BUILDDIR" install |
6344a7eb | 102 | |
70e760e3 | 103 | mkdir -p "$DESTDIR"/etc |
6344a7eb | 104 | |
70e760e3 | 105 | cat > "$DESTDIR"/etc/issue <<EOF |
6344a7eb LP |
106 | \S (built from systemd tree) |
107 | Kernel \r on an \m (\l) | |
108 | ||
109 | EOF |