pmb.helpers.git.rev_parse: don't return "" on err (!1848)
Remove a legacy code path from back in the day, where pmaports were in
the same repository as pmbootstrap ([1]). Nowadays, pmaports are always in a
git repository, so this is not necessary anymore. If git fails at this
point, crash hard and don't carry on with an empty string.
This is in preparation for using rev_parse in new code paths, so we
don't need to check the return value of rev_parse.
[1] 39548835
"Write custom os-release (closes #324) (#439)"
https://github.com/postmarketOS/pmbootstrap/pull/439
This commit is contained in:
parent
7907e91879
commit
2b1dfe7cfc
|
@ -56,9 +56,11 @@ def clone(args, name_repo, shallow=True):
|
||||||
|
|
||||||
|
|
||||||
def rev_parse(args, revision="HEAD"):
|
def rev_parse(args, revision="HEAD"):
|
||||||
|
""" Run "git rev-parse" in the pmaports.git dir.
|
||||||
|
|
||||||
|
:returns: commit string like "90cd0ad84d390897efdcf881c0315747a4f3a966"
|
||||||
|
"""
|
||||||
|
|
||||||
rev = pmb.helpers.run.user(args, ["git", "rev-parse", revision],
|
rev = pmb.helpers.run.user(args, ["git", "rev-parse", revision],
|
||||||
args.aports, output_return=True, check=False)
|
args.aports, output_return=True)
|
||||||
if rev is None:
|
|
||||||
logging.warning("WARNING: Failed to determine revision of git repository at " + args.aports)
|
|
||||||
return ""
|
|
||||||
return rev.rstrip()
|
return rev.rstrip()
|
||||||
|
|
|
@ -25,21 +25,18 @@ import pmb.helpers.git
|
||||||
def write_os_release(args, suffix):
|
def write_os_release(args, suffix):
|
||||||
logging.info("(" + suffix + ") write /etc/os-release")
|
logging.info("(" + suffix + ") write /etc/os-release")
|
||||||
revision = pmb.helpers.git.rev_parse(args)
|
revision = pmb.helpers.git.rev_parse(args)
|
||||||
has_revision = revision != ""
|
|
||||||
filepath = args.work + "/chroot_" + suffix + "/tmp/os-release"
|
filepath = args.work + "/chroot_" + suffix + "/tmp/os-release"
|
||||||
os_release = ('PRETTY_NAME="postmarketOS {version}"\n'
|
os_release = ('PRETTY_NAME="postmarketOS {version}"\n'
|
||||||
'NAME="postmarketOS"\n'
|
'NAME="postmarketOS"\n'
|
||||||
'VERSION_ID="{version}"\n'
|
'VERSION_ID="{version}"\n'
|
||||||
'VERSION="{version}{sep}{hash:.8}"\n'
|
'VERSION="{version}-{hash:.8}"\n'
|
||||||
'ID="postmarketos"\n'
|
'ID="postmarketos"\n'
|
||||||
'ID_LIKE="alpine"\n'
|
'ID_LIKE="alpine"\n'
|
||||||
'HOME_URL="https://www.postmarketos.org/"\n'
|
'HOME_URL="https://www.postmarketos.org/"\n'
|
||||||
'SUPPORT_URL="https://gitlab.com/postmarketOS"\n'
|
'SUPPORT_URL="https://gitlab.com/postmarketOS"\n'
|
||||||
'BUG_REPORT_URL="https://gitlab.com/postmarketOS/pmbootstrap/issues"\n'
|
'BUG_REPORT_URL="https://gitlab.com/postmarketOS/pmbootstrap/issues"\n'
|
||||||
).format(version=pmb.config.version,
|
'PMOS_HASH="{hash}"\n'
|
||||||
sep=("-" if has_revision else ""), hash=revision)
|
).format(version=pmb.config.version, hash=revision)
|
||||||
if has_revision:
|
|
||||||
os_release += ('PMOS_HASH="{hash}"\n').format(hash=revision)
|
|
||||||
with open(filepath, "w") as handle:
|
with open(filepath, "w") as handle:
|
||||||
handle.write(os_release)
|
handle.write(os_release)
|
||||||
pmb.chroot.root(args, ["mv", "/tmp/os-release", "/etc/os-release"], suffix)
|
pmb.chroot.root(args, ["mv", "/tmp/os-release", "/etc/os-release"], suffix)
|
||||||
|
|
Loading…
Reference in New Issue