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