daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
d0811f
import re, sys, os, collections
d0811f
d0811f
buildroot = sys.argv[1]
49aed1
release = sys.argv[2]
d0811f
known_files = sys.stdin.read().splitlines()
d0811f
known_files = {line.split()[-1]:line for line in known_files}
d0811f
49aed1
networkd_regex = r'''
49aed1
    /usr/lib/systemd/network/80-|
49aed1
    networkd|
49aed1
    networkctl|
3e5fd3
    org\.freedesktop\.network1|
3e5fd3
    systemd\.network|
3e5fd3
    systemd-network\.conf|
3e5fd3
    systemd\.netdev
49aed1
'''
49aed1
49aed1
if release == "8":
49aed1
    networkd_regex += r'''|
49aed1
        systemd-network-generator
49aed1
    '''
49aed1
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')
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')
167d2b
o_standalone_tmpfiles = open('.file-list-standalone-tmpfiles', 'w')
167d2b
o_standalone_sysusers = open('.file-list-standalone-sysusers', 'w')
d0811f
o_rest = open('.file-list-rest', '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
d0811f
    if '/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
167d2b
    elif re.search(r'/lib.*\.pc|/man3/|/usr/include|(?
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
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
49aed1
    elif re.search(networkd_regex, n, re.X):
ae4880
        o = o_networkd
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
                       sd-boot|systemd-boot\.|loader.conf|
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|
d0811f
                       cryptsetup|
9e3166
                       libcryptsetup-token-systemd|
d0811f
                       kmod|
d0811f
                       quota|
d0811f
                       pstore|
d0811f
                       sleep|suspend|hibernate|
d0811f
                       systemd-tmpfiles-setup-dev|
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|
d0811f
                       /boot$|
d0811f
                       /boot/efi|
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
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
167d2b
    elif n.endswith('.standalone'):
167d2b
        if 'tmpfiles' in n:
167d2b
            o = o_standalone_tmpfiles
167d2b
        elif 'sysusers' in n:
167d2b
            o = o_standalone_sysusers
167d2b
        else:
167d2b
            assert False, 'Found .standalone not belonging to known packages'
9e3166
d0811f
    else:
d0811f
        o = o_rest
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)