Skip to content

Commit

Permalink
support product name specific license file
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Feb 6, 2024
1 parent 97c2a7c commit 2d6cc62
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/productcomposer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,24 +283,32 @@ def create_tree(outdir, product_base_dir, yml, pool, kwdfile, flavor):
process_updateinfos(rpmdir, yml, pool, flavor, debugdir, sourcedir)

# Add License File and create extra .license directory
if os.path.exists(rpmdir + "/license.tar.gz"):
run_helper(['gzip', '-d', rpmdir + "/license.tar.gz"],
licensefilename = 'license.tar'
if os.path.exists(rpmdir + '/license-' + yml['name'] + '.tar') or os.path.exists(rpmdir + '/license-' + yml['name'] + '.tar.gz'):
licensefilename = '/license-' + yml['name'] + '.tar'
if os.path.exists(rpmdir + licensefilename + '.gz'):
run_helper(['gzip', '-d', rpmdir + licensefilename + '.gz'],
failmsg="Uncompress of license.tar.gz failed")
if os.path.exists(rpmdir + "/license.tar"):
if os.path.exists(rpmdir + licensefilename):
licensedir = rpmdir + ".license"
if not os.path.exists(licensedir):
os.mkdir(licensedir)
args = [ 'tar', 'xf', rpmdir + "/license.tar", '-C', licensedir ]
args = [ 'tar', 'xf', rpmdir + licensefilename, '-C', licensedir ]
output = run_helper(args, failmsg="extract license tar ball")
if not os.path.exists(licensedir + "/license.txt"):
die("No license.txt extracted", details=output)

mr = ModifyrepoWrapper(
file=os.path.join(rpmdir, "license.tar"),
file=rpmdir + licensefilename,
directory=os.path.join(rpmdir, "repodata"),
)
mr.run_cmd()
os.unlink(rpmdir + '/license.tar')
os.unlink(rpmdir + licensefilename)
# meta package may bring a second file or expanded symlink, so we need clean up
if os.path.exists(rpmdir + '/license.tar'):
os.unlink(rpmdir + '/license.tar')
if os.path.exists(rpmdir + '/license.tar.gz'):
os.unlink(rpmdir + '/license.tar.gz')

# detached signature
args = [ '/usr/lib/build/signdummy', '-d', rpmdir + "/repodata/repomd.xml" ]
Expand Down

0 comments on commit 2d6cc62

Please sign in to comment.