gitlab-ci: re-enable mali400/450 and t820 jobs
[mesa.git] / .gitlab-ci / create-rootfs.sh
1 #!/bin/bash
2
3 set -ex
4
5 apt-get -y install --no-install-recommends \
6 ca-certificates \
7 initramfs-tools \
8 libpng16-16 \
9 strace \
10 libsensors5 \
11 libexpat1 \
12 libdrm2 \
13 libdrm-nouveau2 \
14 firmware-qcom-media \
15 wget \
16 xz-utils
17 passwd root -d
18 chsh -s /bin/sh
19
20 cat > /init <<EOF
21 #!/bin/sh
22 export PS1=lava-shell:
23 exec sh
24 EOF
25 chmod +x /init
26
27 mkdir -p /lib/firmware/rtl_nic
28 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rtl_nic/rtl8153a-3.fw -O /lib/firmware/rtl_nic/rtl8153a-3.fw
29
30 #######################################################################
31 # Strip the image to a small minimal system without removing the debian
32 # toolchain.
33
34 # xz compress firmware so it doesn't waste RAM at runtime. Except db820c's
35 # GPU firmware, due to using a precompiled kernel without compression support.
36 find /lib/firmware -type f -print0 | \
37 grep -vz a530 | \
38 xargs -0r -P4 -n4 xz -T1 -C crc32
39 ln -s /lib/firmware/qcom/a530* /lib/firmware/
40
41 # Copy timezone file and remove tzdata package
42 rm -rf /etc/localtime
43 cp /usr/share/zoneinfo/Etc/UTC /etc/localtime
44
45 UNNEEDED_PACKAGES="libfdisk1
46 tzdata
47 diffutils"
48
49 export DEBIAN_FRONTEND=noninteractive
50
51 # Removing unused packages
52 for PACKAGE in ${UNNEEDED_PACKAGES}
53 do
54 echo ${PACKAGE}
55 if ! apt-get remove --purge --yes "${PACKAGE}"
56 then
57 echo "WARNING: ${PACKAGE} isn't installed"
58 fi
59 done
60
61 apt-get autoremove --yes || true
62
63 # Dropping logs
64 rm -rf /var/log/*
65
66 # Dropping documentation, localization, i18n files, etc
67 rm -rf /usr/share/doc/*
68 rm -rf /usr/share/locale/*
69 rm -rf /usr/share/man
70 rm -rf /usr/share/i18n/*
71 rm -rf /usr/share/info/*
72 rm -rf /usr/share/lintian/*
73 rm -rf /usr/share/common-licenses/*
74 rm -rf /usr/share/mime/*
75
76 # Dropping reportbug scripts
77 rm -rf /usr/share/bug
78
79 # Drop udev hwdb not required on a stripped system
80 rm -rf /lib/udev/hwdb.bin /lib/udev/hwdb.d/*
81
82 # Drop all gconv conversions && binaries
83 rm -rf usr/bin/iconv
84 rm -rf usr/sbin/iconvconfig
85 rm -rf usr/lib/*/gconv/
86
87 # Remove libusb database
88 rm -rf usr/sbin/update-usbids
89 rm -rf var/lib/usbutils/usb.ids
90 rm -rf usr/share/misc/usb.ids
91
92 #######################################################################
93 # Crush into a minimal production image to be deployed via some type of image
94 # updating system.
95 # IMPORTANT: The Debian system is not longer functional at this point,
96 # for example, apt and dpkg will stop working
97
98 UNNEEDED_PACKAGES="apt libapt-pkg5.0 "\
99 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
100 "perl-base "\
101 "debconf libdebconfclient0 "\
102 "e2fsprogs e2fslibs libfdisk1 "\
103 "insserv "\
104 "udev "\
105 "init-system-helpers "\
106 "bash "\
107 "cpio "\
108 "xz-utils "\
109 "passwd "\
110 "libsemanage1 libsemanage-common "\
111 "libsepol1 "\
112 "gpgv "\
113 "hostname "\
114 "adduser "\
115 "debian-archive-keyring "\
116
117 # Removing unneeded packages
118 for PACKAGE in ${UNNEEDED_PACKAGES}
119 do
120 echo "Forcing removal of ${PACKAGE}"
121 if ! dpkg --purge --force-remove-essential --force-depends "${PACKAGE}"
122 then
123 echo "WARNING: ${PACKAGE} isn't installed"
124 fi
125 done
126
127 # Show what's left package-wise before dropping dpkg itself
128 COLUMNS=300 dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
129
130 # Drop dpkg
131 dpkg --purge --force-remove-essential --force-depends dpkg
132
133 # No apt or dpkg, no need for its configuration archives
134 rm -rf etc/apt
135 rm -rf etc/dpkg
136
137 # Drop directories not part of ostree
138 # Note that /var needs to exist as ostree bind mounts the deployment /var over
139 # it
140 rm -rf var/* opt srv share
141
142 # ca-certificates are in /etc drop the source
143 rm -rf usr/share/ca-certificates
144
145 # No bash, no need for completions
146 rm -rf usr/share/bash-completion
147
148 # No zsh, no need for comletions
149 rm -rf usr/share/zsh/vendor-completions
150
151 # drop gcc-6 python helpers
152 rm -rf usr/share/gcc-6
153
154 # Drop sysvinit leftovers
155 rm -rf etc/init.d
156 rm -rf etc/rc[0-6S].d
157
158 # Drop upstart helpers
159 rm -rf etc/init
160
161 # Various xtables helpers
162 rm -rf usr/lib/xtables
163
164 # Drop all locales
165 # TODO: only remaining locale is actually "C". Should we really remove it?
166 rm -rf usr/lib/locale/*
167
168 # partition helpers
169 rm usr/sbin/*fdisk
170
171 # local compiler
172 rm usr/bin/localedef
173
174 # Systemd dns resolver
175 find usr etc -name '*systemd-resolve*' -prune -exec rm -r {} \;
176
177 # Systemd network configuration
178 find usr etc -name '*networkd*' -prune -exec rm -r {} \;
179
180 # systemd ntp client
181 find usr etc -name '*timesyncd*' -prune -exec rm -r {} \;
182
183 # systemd hw database manager
184 find usr etc -name '*systemd-hwdb*' -prune -exec rm -r {} \;
185
186 # No need for fuse
187 find usr etc -name '*fuse*' -prune -exec rm -r {} \;
188
189 # lsb init function leftovers
190 rm -rf usr/lib/lsb
191
192 # Only needed when adding libraries
193 rm usr/sbin/ldconfig*
194
195 # Games, unused
196 rmdir usr/games
197
198 # Remove pam module to authenticate against a DB
199 # plus libdb-5.3.so that is only used by this pam module
200 rm usr/lib/*/security/pam_userdb.so
201 rm usr/lib/*/libdb-5.3.so
202
203 # remove NSS support for nis, nisplus and hesiod
204 rm usr/lib/*/libnss_hesiod*
205 rm usr/lib/*/libnss_nis*