ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
d0811f
import re, sys, os, collections
d0811f
d0811f
buildroot = sys.argv[1]
7172f2
release = sys.argv[2]
d0811f
known_files = sys.stdin.read().splitlines()
d0811f
known_files = {line.split()[-1]:line for line in known_files}
d0811f
d0811f
def files(root):
d0811f
    os.chdir(root)
d0811f
    todo = collections.deque(['.'])
d0811f
    while todo:
d0811f
        n = todo.pop()
d0811f
        files = os.scandir(n)
d0811f
        for file in files:
d0811f
            yield file
d0811f
            if file.is_dir() and not file.is_symlink():
d0811f
                todo.append(file)
d0811f
d0811f
o_libs = open('.file-list-libs', 'w')
d0811f
o_udev = open('.file-list-udev', 'w')
8c1b90
o_ukify = open('.file-list-ukify', 'w')
09f814
o_boot = open('.file-list-boot', 'w')
d0811f
o_pam = open('.file-list-pam', 'w')
d0811f
o_rpm_macros = open('.file-list-rpm-macros', 'w')
d0811f
o_devel = open('.file-list-devel', 'w')
d0811f
o_container = open('.file-list-container', 'w')
ae4880
o_networkd = open('.file-list-networkd', 'w')
167d2b
o_oomd_defaults = open('.file-list-oomd-defaults', 'w')
d0811f
o_remote = open('.file-list-remote', 'w')
ae4880
o_resolve = open('.file-list-resolve', 'w')
d0811f
o_tests = open('.file-list-tests', 'w')
8c1b90
o_standalone_repart = open('.file-list-standalone-repart', 'w')
167d2b
o_standalone_tmpfiles = open('.file-list-standalone-tmpfiles', 'w')
167d2b
o_standalone_sysusers = open('.file-list-standalone-sysusers', 'w')
8c1b90
o_standalone_shutdown = open('.file-list-standalone-shutdown', 'w')
d2f4df
o_main = open('.file-list-main', 'w')
d0811f
for file in files(buildroot):
d0811f
    n = file.path[1:]
d0811f
    if re.match(r'''/usr/(share|include)$|
d0811f
                    /usr/share/man(/man.|)$|
d0811f
                    /usr/share/zsh(/site-functions|)$|
d0811f
                    /usr/share/dbus-1$|
d0811f
                    /usr/share/dbus-1/system.d$|
d0811f
                    /usr/share/dbus-1/(system-|)services$|
d0811f
                    /usr/share/polkit-1(/actions|/rules.d|)$|
d0811f
                    /usr/share/pkgconfig$|
d0811f
                    /usr/share/bash-completion(/completions|)$|
d0811f
                    /usr(/lib|/lib64|/bin|/sbin|)$|
d0811f
                    /usr/lib.*/(security|pkgconfig)$|
d0811f
                    /usr/lib/rpm(/macros.d|)$|
d0811f
                    /usr/lib/firewalld(/services|)$|
d0811f
                    /usr/share/(locale|licenses|doc)|             # no $
d0811f
                    /etc(/pam\.d|/xdg|/X11|/X11/xinit|/X11.*\.d|)$|
d0811f
                    /etc/(dnf|dnf/protected.d)$|
d0811f
                    /usr/(src|lib/debug)|                         # no $
d0811f
                    /run$|
d0811f
                    /var(/cache|/log|/lib|/run|)$
d0811f
    ''', n, re.X):
d0811f
        continue
8c1b90
8c1b90
    if n.endswith('.standalone'):
8c1b90
        if 'repart' in n:
8c1b90
            o = o_standalone_repart
8c1b90
        elif 'tmpfiles' in n:
8c1b90
            o = o_standalone_tmpfiles
8c1b90
        elif 'sysusers' in n:
8c1b90
            o = o_standalone_sysusers
8c1b90
        elif 'shutdown' in n:
8c1b90
            o = o_standalone_shutdown
8c1b90
        else:
8c1b90
            assert False, 'Found .standalone not belonging to known packages'
8c1b90
8c1b90
    elif '/security/pam_' in n or '/man8/pam_' in n:
d0811f
        o = o_pam
d0811f
    elif '/rpm/' in n:
d0811f
        o = o_rpm_macros
d0811f
    elif '/usr/lib/systemd/tests' in n:
d0811f
        o = o_tests
8c1b90
    elif 'ukify' in n:
8c1b90
        o = o_ukify
d2f4df
    elif re.search(r'/libsystemd-(shared|core)-.*\.so$', n):
d2f4df
        o = o_main
d2f4df
    elif re.search(r'/libcryptsetup-token-systemd-.*\.so$', n):
d2f4df
        o = o_udev
d2f4df
    elif re.search(r'/lib.*\.pc|/man3/|/usr/include|\.so$', n):
167d2b
        o = o_devel
d0811f
    elif re.search(r'''journal-(remote|gateway|upload)|
d0811f
                       systemd-remote\.conf|
d0811f
                       /usr/share/systemd/gatewayd|
d0811f
                       /var/log/journal/remote
d0811f
    ''', n, re.X):
d0811f
        o = o_remote
d2f4df
d0811f
    elif re.search(r'''mymachines|
d0811f
                       machinectl|
d0811f
                       systemd-nspawn|
d0811f
                       import-pubring.gpg|
d0811f
                       systemd-(machined|import|pull)|
d0811f
                       /machine.slice|
d0811f
                       /machines.target|
d0811f
                       var-lib-machines.mount|
d0811f
                       org.freedesktop.(import|machine)1
d0811f
    ''', n, re.X):
d0811f
        o = o_container
d2f4df
566842
    elif re.search(r'''/usr/lib/systemd/network/80-|
566842
                       networkd|
566842
                       networkctl|
566842
                       org.freedesktop.network1|
566842
                       sysusers\.d/systemd-network.conf|
566842
                       tmpfiles\.d/systemd-network.conf|
566842
                       systemd\.network|
566842
                       systemd\.netdev
8595a3
    ''', n, re.X):
8595a3
        o = o_networkd
8595a3
8595a3
    elif re.search(r'systemd-network-generator', n, re.X) and release == "8":
ae4880
        o = o_networkd
d2f4df
d0811f
    elif '.so.' in n:
d0811f
        o = o_libs
9e3166
d0811f
    elif re.search(r'''udev(?!\.pc)|
d0811f
                       hwdb|
d0811f
                       bootctl|
9e3166
                       boot-update|
d0811f
                       bless-boot|
d0811f
                       boot-system-token|
d0811f
                       kernel-install|
d0811f
                       vconsole|
d0811f
                       backlight|
d0811f
                       rfkill|
d0811f
                       random-seed|
d0811f
                       modules-load|
d0811f
                       timesync|
9e3166
                       crypttab|
d2f4df
                       cryptenroll|
d0811f
                       cryptsetup|
d0811f
                       kmod|
d0811f
                       quota|
d0811f
                       pstore|
d0811f
                       sleep|suspend|hibernate|
d0811f
                       systemd-tmpfiles-setup-dev|
8c1b90
                       network/98-default-mac-none.link|
d0811f
                       network/99-default.link|
d0811f
                       growfs|makefs|makeswap|mkswap|
d0811f
                       fsck|
d0811f
                       repart|
d0811f
                       gpt-auto|
d0811f
                       volatile-root|
9e3166
                       veritysetup|
9e3166
                       integritysetup|
9e3166
                       integritytab|
d0811f
                       remount-fs|
09f814
                       /initrd|
09f814
                       systemd-pcrphase|
09f814
                       systemd-measure|
d0811f
                       /boot$|
d0811f
                       /kernel/|
d0811f
                       /kernel$|
9e3166
                       /modprobe.d|
9e3166
                       binfmt|
9e3166
                       sysctl|
9e3166
                       coredump|
9e3166
                       homed|home1|
9e3166
                       portabled|portable1
9e3166
    ''', n, re.X):     # coredumpctl, homectl, portablectl are included in the main package because
9e3166
                       # they can be used to interact with remote daemons. Also, the user could be
9e3166
                       # confused if those user-facing binaries are not available.
d0811f
        o = o_udev
9e3166
8c1b90
    elif re.search(r'''/boot/efi|
8c1b90
                       /usr/lib/systemd/boot|
8c1b90
                       sd-boot|systemd-boot\.|loader.conf
8c1b90
    ''', n, re.X):
09f814
        o = o_boot
09f814
9e3166
    elif re.search(r'''resolved|resolve1|
ae4880
                       systemd-resolve|
ae4880
                       resolvconf|
9e3166
                       systemd\.(positive|negative)
9e3166
    ''', n, re.X):     # resolvectl and nss-resolve are in the main package.
ae4880
        o = o_resolve
9e3166
167d2b
    elif re.search(r'10-oomd-.*defaults.conf|lib/systemd/oomd.conf.d', n, re.X):
167d2b
        o = o_oomd_defaults
9e3166
d0811f
    else:
d2f4df
        o = o_main
d0811f
d0811f
    if n in known_files:
d0811f
        prefix = ' '.join(known_files[n].split()[:-1])
d0811f
        if prefix:
d0811f
            prefix += ' '
d0811f
    elif file.is_dir() and not file.is_symlink():
d0811f
        prefix = '%dir '
167d2b
    elif 'README' in n:
167d2b
        prefix = '%doc '
d0811f
    elif n.startswith('/etc'):
d0811f
        prefix = '%config(noreplace) '
d0811f
    else:
d0811f
        prefix = ''
d0811f
d0811f
    suffix = '*' if '/man/' in n else ''
d0811f
d0811f
    print(f'{prefix}{n}{suffix}', file=o)