Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions dlopen-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def rpm_name(self):
return 'Requires'
raise ValueError

@classmethod
def rpm_names(cls):
return [o.rpm_name() for o in cls]


def group_by_feature(elffiles):
features = {}
Expand Down Expand Up @@ -199,7 +203,7 @@ def rpm_fileattr_generator(args):

fileattr = Priority[level].rpm_name()

if fileattr != args.rpm_fileattr:
if fileattr not in args.rpm_fileattr:
continue

if first:
Expand Down Expand Up @@ -276,7 +280,10 @@ def make_parser():
)
p.add_argument(
'--rpm-fileattr',
type=lambda s: s.split(','),
action='extend',
metavar='TYPE',
default=[],
help='Run as rpm fileattr generator for TYPE dependencies',
)
p.add_argument(
Expand Down Expand Up @@ -314,27 +321,31 @@ def parse_args():
and args.features is None
and args.rpm_requires is None
and args.rpm_recommends is None
and args.rpm_fileattr is None):
and not args.rpm_fileattr):
# Make --raw the default if no action is specified.
args.raw = True

if args.rpm_fileattr is not None:
if args.rpm_fileattr:
if (args.filenames
or args.raw
or args.features is not None
or args.rpm_requires
or args.rpm_recommends):
raise ValueError('--rpm-generate cannot be combined with most options')

if args.rpm_fileattr is None and not args.filenames:
if not args.rpm_fileattr and not args.filenames:
raise ValueError('At least one positional FILENAME parameter is required')

for attr in args.rpm_fileattr:
if attr not in Priority.rpm_names():
raise ValueError(f'Bad --rpm-fileattr argument {attr}')

return args

if __name__ == '__main__':
args = parse_args()

if args.rpm_fileattr is not None:
if args.rpm_fileattr:
sys.exit(rpm_fileattr_generator(args))

elffiles = [ELFFileReader(filename) for filename in args.filenames]
Expand Down
Loading