2017-12-11 23:41:07 +00:00
|
|
|
import re, sys, os, collections
|
|
|
|
|
|
|
|
buildroot = sys.argv[1]
|
2023-11-23 14:10:10 +00:00
|
|
|
no_bootloader = '--no-bootloader' in sys.argv
|
2023-11-23 13:45:33 +00:00
|
|
|
|
|
|
|
known_files = '''
|
|
|
|
%ghost %config(noreplace) /etc/crypttab
|
|
|
|
%ghost %attr(0444,root,root) /etc/udev/hwdb.bin
|
|
|
|
/etc/inittab
|
|
|
|
/usr/lib/systemd/purge-nobody-user
|
2023-12-09 13:36:49 +00:00
|
|
|
# This directory is owned by openssh-server, but we don't want to introduce
|
|
|
|
# a dependency. So let's copy the config and co-own the directory.
|
2023-12-08 17:17:39 +00:00
|
|
|
%dir %attr(0700,root,root) /etc/ssh/sshd_config.d
|
2023-11-23 13:45:33 +00:00
|
|
|
%ghost %config(noreplace) /etc/vconsole.conf
|
|
|
|
%ghost %config(noreplace) /etc/X11/xorg.conf.d/00-keyboard.conf
|
|
|
|
%ghost %attr(0664,root,root) %verify(not group) /run/utmp
|
|
|
|
%ghost %attr(0664,root,root) %verify(not group) /var/log/wtmp
|
|
|
|
%ghost %attr(0660,root,root) %verify(not group) /var/log/btmp
|
|
|
|
%ghost %attr(0664,root,root) %verify(not md5 size mtime group) /var/log/lastlog
|
|
|
|
%ghost %config(noreplace) /etc/hostname
|
|
|
|
%ghost %config(noreplace) /etc/localtime
|
|
|
|
%ghost %config(noreplace) /etc/locale.conf
|
|
|
|
%ghost %attr(0444,root,root) %config(noreplace) /etc/machine-id
|
|
|
|
%ghost %config(noreplace) /etc/machine-info
|
|
|
|
%ghost %attr(0700,root,root) %dir /var/cache/private
|
|
|
|
%ghost %attr(0700,root,root) %dir /var/lib/private
|
|
|
|
%ghost %dir /var/lib/private/systemd
|
|
|
|
%ghost %dir /var/lib/private/systemd/journal-upload
|
|
|
|
%ghost /var/lib/private/systemd/journal-upload/state
|
|
|
|
%ghost %dir /var/lib/systemd/timesync
|
|
|
|
%ghost /var/lib/systemd/timesync/clock
|
|
|
|
%ghost %dir /var/lib/systemd/backlight
|
|
|
|
%ghost /var/lib/systemd/catalog/database
|
|
|
|
%ghost %dir /var/lib/systemd/coredump
|
|
|
|
%ghost /var/lib/systemd/journal-upload
|
|
|
|
%ghost %dir /var/lib/systemd/linger
|
|
|
|
%ghost %attr(0600,root,root) /var/lib/systemd/random-seed
|
|
|
|
%ghost %dir /var/lib/systemd/rfkill
|
|
|
|
%ghost %dir %verify(not mode group) /var/log/journal
|
|
|
|
%ghost %dir /var/log/journal/remote
|
|
|
|
%ghost %attr(0700,root,root) %dir /var/log/private
|
2023-12-11 21:51:48 +00:00
|
|
|
'''
|
2023-11-23 13:45:33 +00:00
|
|
|
|
2023-12-09 13:36:49 +00:00
|
|
|
known_files = {line.split()[-1]:line for line in known_files.splitlines()
|
|
|
|
if line and not line.startswith('#')}
|
2017-12-11 23:41:07 +00:00
|
|
|
|
|
|
|
def files(root):
|
|
|
|
os.chdir(root)
|
|
|
|
todo = collections.deque(['.'])
|
|
|
|
while todo:
|
|
|
|
n = todo.pop()
|
|
|
|
files = os.scandir(n)
|
|
|
|
for file in files:
|
|
|
|
yield file
|
|
|
|
if file.is_dir() and not file.is_symlink():
|
|
|
|
todo.append(file)
|
|
|
|
|
2023-11-23 13:53:53 +00:00
|
|
|
outputs = {suffix: open(f'.file-list-{suffix}', 'w')
|
|
|
|
for suffix in (
|
|
|
|
'libs',
|
|
|
|
'udev',
|
|
|
|
'ukify',
|
|
|
|
'boot',
|
|
|
|
'pam',
|
|
|
|
'rpm-macros',
|
|
|
|
'devel',
|
|
|
|
'container',
|
|
|
|
'networkd',
|
|
|
|
'networkd-defaults',
|
|
|
|
'oomd-defaults',
|
|
|
|
'remote',
|
|
|
|
'resolve',
|
|
|
|
'tests',
|
|
|
|
'standalone-repart',
|
|
|
|
'standalone-tmpfiles',
|
|
|
|
'standalone-sysusers',
|
|
|
|
'standalone-shutdown',
|
|
|
|
'main',
|
|
|
|
)}
|
|
|
|
|
2017-12-11 23:41:07 +00:00
|
|
|
for file in files(buildroot):
|
|
|
|
n = file.path[1:]
|
|
|
|
if re.match(r'''/usr/(share|include)$|
|
|
|
|
/usr/share/man(/man.|)$|
|
|
|
|
/usr/share/zsh(/site-functions|)$|
|
|
|
|
/usr/share/dbus-1$|
|
|
|
|
/usr/share/dbus-1/system.d$|
|
|
|
|
/usr/share/dbus-1/(system-|)services$|
|
|
|
|
/usr/share/polkit-1(/actions|/rules.d|)$|
|
|
|
|
/usr/share/pkgconfig$|
|
|
|
|
/usr/share/bash-completion(/completions|)$|
|
|
|
|
/usr(/lib|/lib64|/bin|/sbin|)$|
|
|
|
|
/usr/lib.*/(security|pkgconfig)$|
|
|
|
|
/usr/lib/rpm(/macros.d|)$|
|
|
|
|
/usr/lib/firewalld(/services|)$|
|
|
|
|
/usr/share/(locale|licenses|doc)| # no $
|
2017-12-12 06:49:18 +00:00
|
|
|
/etc(/pam\.d|/xdg|/X11|/X11/xinit|/X11.*\.d|)$|
|
2018-09-10 09:18:18 +00:00
|
|
|
/etc/(dnf|dnf/protected.d)$|
|
2017-12-11 23:41:07 +00:00
|
|
|
/usr/(src|lib/debug)| # no $
|
2020-04-01 17:42:04 +00:00
|
|
|
/run$|
|
2017-12-12 06:49:18 +00:00
|
|
|
/var(/cache|/log|/lib|/run|)$
|
2017-12-11 23:41:07 +00:00
|
|
|
''', n, re.X):
|
|
|
|
continue
|
2023-01-24 23:16:28 +00:00
|
|
|
|
|
|
|
if n.endswith('.standalone'):
|
|
|
|
if 'repart' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['standalone-repart']
|
2023-01-24 23:16:28 +00:00
|
|
|
elif 'tmpfiles' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['standalone-tmpfiles']
|
2023-01-24 23:16:28 +00:00
|
|
|
elif 'sysusers' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['standalone-sysusers']
|
2023-01-24 23:16:28 +00:00
|
|
|
elif 'shutdown' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['standalone-shutdown']
|
2023-01-24 23:16:28 +00:00
|
|
|
else:
|
|
|
|
assert False, 'Found .standalone not belonging to known packages'
|
|
|
|
|
|
|
|
elif '/security/pam_' in n or '/man8/pam_' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['pam']
|
2020-02-07 15:34:30 +00:00
|
|
|
elif '/rpm/' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['rpm-macros']
|
2017-12-11 23:41:07 +00:00
|
|
|
elif '/usr/lib/systemd/tests' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['tests']
|
2023-01-24 23:16:28 +00:00
|
|
|
elif 'ukify' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['ukify']
|
2022-03-29 20:07:50 +00:00
|
|
|
elif re.search(r'/libsystemd-(shared|core)-.*\.so$', n):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['main']
|
2022-03-18 12:35:22 +00:00
|
|
|
elif re.search(r'/libcryptsetup-token-systemd-.*\.so$', n):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['udev']
|
2022-03-17 20:37:30 +00:00
|
|
|
elif re.search(r'/lib.*\.pc|/man3/|/usr/include|\.so$', n):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['devel']
|
2017-12-11 23:41:07 +00:00
|
|
|
elif re.search(r'''journal-(remote|gateway|upload)|
|
|
|
|
systemd-remote\.conf|
|
2017-12-12 06:49:18 +00:00
|
|
|
/usr/share/systemd/gatewayd|
|
|
|
|
/var/log/journal/remote
|
2017-12-11 23:41:07 +00:00
|
|
|
''', n, re.X):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['remote']
|
2022-03-17 20:37:30 +00:00
|
|
|
|
2017-12-11 23:41:07 +00:00
|
|
|
elif re.search(r'''mymachines|
|
|
|
|
machinectl|
|
|
|
|
systemd-nspawn|
|
2023-11-07 17:41:08 +00:00
|
|
|
systemd-vmspawn|
|
2017-12-11 23:41:07 +00:00
|
|
|
import-pubring.gpg|
|
|
|
|
systemd-(machined|import|pull)|
|
|
|
|
/machine.slice|
|
|
|
|
/machines.target|
|
|
|
|
var-lib-machines.mount|
|
|
|
|
org.freedesktop.(import|machine)1
|
|
|
|
''', n, re.X):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['container']
|
2022-03-17 20:37:30 +00:00
|
|
|
|
2023-11-22 23:38:44 +00:00
|
|
|
# .network.example files go into systemd-networkd, and the matching files
|
|
|
|
# without .example go into systemd-networkd-defaults
|
|
|
|
elif (re.search(r'''/usr/lib/systemd/network/.*\.network$''', n)
|
|
|
|
and os.path.exists(f'./{n}.example')):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['networkd-defaults']
|
2023-11-22 23:38:44 +00:00
|
|
|
|
|
|
|
elif re.search(r'''/usr/lib/systemd/network/.*\.network|
|
2020-09-30 16:21:11 +00:00
|
|
|
networkd|
|
|
|
|
networkctl|
|
2022-05-05 17:24:55 +00:00
|
|
|
org.freedesktop.network1|
|
2022-07-07 10:07:01 +00:00
|
|
|
sysusers\.d/systemd-network.conf|
|
2022-07-06 18:50:31 +00:00
|
|
|
tmpfiles\.d/systemd-network.conf|
|
|
|
|
systemd\.network|
|
|
|
|
systemd\.netdev
|
2020-09-30 16:21:11 +00:00
|
|
|
''', n, re.X):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['networkd']
|
2022-03-17 20:37:30 +00:00
|
|
|
|
2017-12-11 23:41:07 +00:00
|
|
|
elif '.so.' in n:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['libs']
|
2021-12-09 22:10:44 +00:00
|
|
|
|
2023-11-07 16:45:57 +00:00
|
|
|
elif re.search(r'10-oomd-.*defaults.conf|lib/systemd/oomd.conf.d', n, re.X):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['oomd-defaults']
|
2023-11-07 16:45:57 +00:00
|
|
|
|
2017-12-11 23:41:07 +00:00
|
|
|
elif re.search(r'''udev(?!\.pc)|
|
|
|
|
hwdb|
|
|
|
|
bootctl|
|
2021-12-12 12:01:40 +00:00
|
|
|
boot-update|
|
2020-02-28 12:41:05 +00:00
|
|
|
bless-boot|
|
|
|
|
boot-system-token|
|
2023-12-08 08:43:00 +00:00
|
|
|
bsod|
|
2017-12-11 23:41:07 +00:00
|
|
|
kernel-install|
|
2023-09-15 08:57:19 +00:00
|
|
|
installkernel|
|
2017-12-11 23:41:07 +00:00
|
|
|
vconsole|
|
|
|
|
backlight|
|
|
|
|
rfkill|
|
|
|
|
random-seed|
|
|
|
|
modules-load|
|
2017-12-12 06:49:18 +00:00
|
|
|
timesync|
|
2021-12-09 22:10:44 +00:00
|
|
|
crypttab|
|
2021-11-30 20:00:44 +00:00
|
|
|
cryptenroll|
|
2017-12-11 23:41:07 +00:00
|
|
|
cryptsetup|
|
|
|
|
kmod|
|
|
|
|
quota|
|
2020-02-28 13:36:53 +00:00
|
|
|
pstore|
|
2017-12-11 23:41:07 +00:00
|
|
|
sleep|suspend|hibernate|
|
|
|
|
systemd-tmpfiles-setup-dev|
|
2023-02-02 17:09:03 +00:00
|
|
|
network/98-default-mac-none.link|
|
2017-12-11 23:41:07 +00:00
|
|
|
network/99-default.link|
|
2020-02-28 13:36:53 +00:00
|
|
|
growfs|makefs|makeswap|mkswap|
|
|
|
|
fsck|
|
|
|
|
repart|
|
2017-12-11 23:41:07 +00:00
|
|
|
gpt-auto|
|
2020-02-28 13:36:53 +00:00
|
|
|
volatile-root|
|
2021-12-09 22:10:44 +00:00
|
|
|
veritysetup|
|
|
|
|
integritysetup|
|
|
|
|
integritytab|
|
2020-02-28 13:36:53 +00:00
|
|
|
remount-fs|
|
2022-10-07 16:12:10 +00:00
|
|
|
/initrd|
|
2023-11-07 15:27:34 +00:00
|
|
|
systemd-pcr|
|
2022-10-09 13:20:23 +00:00
|
|
|
systemd-measure|
|
2017-12-11 23:41:07 +00:00
|
|
|
/boot$|
|
|
|
|
/kernel/|
|
|
|
|
/kernel$|
|
2021-12-09 22:10:44 +00:00
|
|
|
/modprobe.d|
|
|
|
|
binfmt|
|
|
|
|
sysctl|
|
|
|
|
coredump|
|
|
|
|
homed|home1|
|
2023-11-07 16:45:57 +00:00
|
|
|
oomd|
|
2021-12-09 22:10:44 +00:00
|
|
|
portabled|portable1
|
|
|
|
''', n, re.X): # coredumpctl, homectl, portablectl are included in the main package because
|
|
|
|
# they can be used to interact with remote daemons. Also, the user could be
|
|
|
|
# confused if those user-facing binaries are not available.
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['udev']
|
2021-12-09 22:10:44 +00:00
|
|
|
|
2023-03-01 13:09:03 +00:00
|
|
|
elif re.search(r'''/boot/efi|
|
2023-03-09 08:05:16 +00:00
|
|
|
/usr/lib/systemd/boot|
|
2023-03-01 13:09:03 +00:00
|
|
|
sd-boot|systemd-boot\.|loader.conf
|
|
|
|
''', n, re.X):
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['boot']
|
2022-04-27 13:45:25 +00:00
|
|
|
|
2021-12-09 22:10:44 +00:00
|
|
|
elif re.search(r'''resolved|resolve1|
|
2021-06-16 15:03:00 +00:00
|
|
|
systemd-resolve|
|
|
|
|
resolvconf|
|
2021-12-09 22:10:44 +00:00
|
|
|
systemd\.(positive|negative)
|
|
|
|
''', n, re.X): # resolvectl and nss-resolve are in the main package.
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['resolve']
|
2021-12-09 22:10:44 +00:00
|
|
|
|
2017-12-11 23:41:07 +00:00
|
|
|
else:
|
2023-11-23 13:53:53 +00:00
|
|
|
o = outputs['main']
|
2017-12-11 23:41:07 +00:00
|
|
|
|
|
|
|
if n in known_files:
|
2023-12-13 12:02:45 +00:00
|
|
|
prefix = known_files[n].split()[:-1]
|
2017-12-11 23:41:07 +00:00
|
|
|
elif file.is_dir() and not file.is_symlink():
|
2023-12-13 12:02:45 +00:00
|
|
|
prefix = ['%dir']
|
2021-03-31 08:03:27 +00:00
|
|
|
elif 'README' in n:
|
2023-12-13 12:02:45 +00:00
|
|
|
prefix = ['%doc']
|
2017-12-11 23:41:07 +00:00
|
|
|
elif n.startswith('/etc'):
|
2023-12-13 12:02:45 +00:00
|
|
|
prefix = ['%config(noreplace)']
|
|
|
|
if file.stat().st_size == 0:
|
|
|
|
prefix += ['%ghost']
|
2017-12-11 23:41:07 +00:00
|
|
|
else:
|
2023-12-13 12:02:45 +00:00
|
|
|
prefix = []
|
|
|
|
prefix = ' '.join(prefix + ['']) if prefix else ''
|
2017-12-11 23:41:07 +00:00
|
|
|
|
|
|
|
suffix = '*' if '/man/' in n else ''
|
|
|
|
|
|
|
|
print(f'{prefix}{n}{suffix}', file=o)
|
2023-11-23 13:57:31 +00:00
|
|
|
|
|
|
|
if [print(f'ERROR: no file names were written to {o.name}')
|
2023-11-23 14:10:10 +00:00
|
|
|
for name, o in outputs.items()
|
|
|
|
if (o.tell() == 0 and
|
2023-12-02 09:56:51 +00:00
|
|
|
not (no_bootloader and name in ('ukify', 'boot')))
|
2023-11-23 14:10:10 +00:00
|
|
|
]:
|
2023-11-23 13:57:31 +00:00
|
|
|
sys.exit(1)
|