forked from Mirror/pmbootstrap
pmb.helpers.git.clone: use git from host system (!1845)
Do not install git in the native chroot and use it from there. Remove the chown_to_user argument from pmb.helpers.git.clone(), the resulting dir is now always owned by the user. While at it, refactor the function and display the clone URL. Previously we had cloned aports_upstream (from Alpine) with chown_to_user=False (legacy) and pmaports with chown_to_user=True. pmb.helpers.git.rev_parse() would only work after chown_to_user=True. Check if git is installed in "pmbootstrap init", and remove the same check from rev_parse(). Add a new work dir version, that checks for git and changes ownership of already checked out aports_upstream to the host system's user. When creating a new work dir, create cache_git instead of cache_http. cache_http is created on demand already, with proper permissions. But cache_git must be created, otherwise pmb.helpers.mount.bind will create it as root. This is in preparation for the "pmbootstrap pull" feature, as it allows using the host system's git in all new code paths. We will be able to handle repositories even if they were cloned outside of the work dir (which we do in a few CI scripts for example). Related: #1858
This commit is contained in:
parent
cba37d5d79
commit
02e514f4d3
7 changed files with 54 additions and 47 deletions
|
@ -21,6 +21,7 @@ import os
|
|||
import re
|
||||
import pmb.chroot
|
||||
import pmb.config
|
||||
import pmb.config.init
|
||||
import pmb.helpers.pmaports
|
||||
import pmb.helpers.run
|
||||
|
||||
|
@ -154,6 +155,30 @@ def migrate_work_folder(args):
|
|||
migrate_success(args, 3)
|
||||
current = 3
|
||||
|
||||
if current == 3:
|
||||
# Ask for confirmation
|
||||
path = args.work + "/cache_git"
|
||||
logging.info("Changelog:")
|
||||
logging.info("* pmbootstrap clones repositories with host system's")
|
||||
logging.info(" 'git' instead of using it from an Alpine chroot")
|
||||
logging.info("Migration will do the following:")
|
||||
logging.info("* Check if 'git' is installed")
|
||||
logging.info("* Change ownership to your user: " + path)
|
||||
if not pmb.helpers.cli.confirm(args):
|
||||
raise RuntimeError("Aborted.")
|
||||
|
||||
# Require git, set cache_git ownership
|
||||
pmb.config.init.require_programs()
|
||||
if os.path.exists(path):
|
||||
uid_gid = "{}:{}".format(os.getuid(), os.getgid())
|
||||
pmb.helpers.run.root(args, ["chown", "-R", uid_gid, path])
|
||||
else:
|
||||
os.makedirs(path, 0o700, True)
|
||||
|
||||
# Update version file
|
||||
migrate_success(args, 4)
|
||||
current = 4
|
||||
|
||||
# Can't migrate, user must delete it
|
||||
if current != required:
|
||||
raise RuntimeError("Sorry, we can't migrate that automatically. Please"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue