Skip to content
Snippets Groups Projects
Commit 0be893d9 authored by Luca Weiss's avatar Luca Weiss
Browse files

pmb.config.init: fix init when work path is an empty directory

In case a user removes all contents of the work path then pmbootstrap
init will fail and show

  WARNING: Your work folder version needs to be migrated (from version 0 to 6)!

Later the migration would fail with the error

  ERROR: We have split the aports repository from the pmbootstrap repository (#383). Please run 'pmbootstrap init' again to clone it.

This is due to the existing check not accounting for e.g. log.txt being
written in the work path before we get to this check. Now change it so
we always create the version file if it doesn't exist yet.

Test plan:
$ grep work ~/.config/pmbootstrap.cfg
work = /tmp/pmbootstrap-work
$ rm -rf /tmp/pmbootstrap-work
$ mkdir /tmp/pmbootstrap-work
$ pmbootstrap init

This was previously attempted to be fixed in !1975
parent 87f7520e
No related branches found
No related tags found
No related merge requests found
Pipeline #189051 passed
......@@ -64,10 +64,12 @@ def ask_for_work_path(args):
if not exists:
os.makedirs(work, 0o700, True)
if not os.listdir(work):
# Directory is empty, either because we just created it or
# because user created it before running pmbootstrap init
with open(f"{work}/version", "w") as handle:
# If the version file doesn't exists yet because we either just
# created the work directory or the user has deleted it for
# whatever reason then we need to write initialize it.
work_version_file = f"{work}/version"
if not os.path.isfile(work_version_file):
with open(work_version_file, "w") as handle:
handle.write(f"{pmb.config.work_version}\n")
# Create cache_git dir, so it is owned by the host system's user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment