2017-05-26 20:08:45 +00:00
|
|
|
"""
|
2018-01-04 03:53:35 +00:00
|
|
|
Copyright 2018 Oliver Smith
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
This file is part of pmbootstrap.
|
|
|
|
|
|
|
|
pmbootstrap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
pmbootstrap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
import pmb.build
|
|
|
|
import pmb.chroot.apk
|
|
|
|
import pmb.config
|
2017-09-25 22:05:29 +00:00
|
|
|
import pmb.helpers.run
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
def clone(args, repo_name):
|
|
|
|
if repo_name not in pmb.config.git_repos:
|
|
|
|
raise ValueError("No git repository configured for " + repo_name)
|
|
|
|
|
|
|
|
if not os.path.exists(args.work + "/cache_git/" + repo_name):
|
|
|
|
pmb.chroot.apk.install(args, ["git"])
|
|
|
|
logging.info("(native) git clone " + pmb.config.git_repos[repo_name])
|
|
|
|
pmb.chroot.user(args, ["git", "clone", "--depth=1",
|
2017-10-12 20:08:10 +00:00
|
|
|
pmb.config.git_repos[repo_name], repo_name], working_dir="/home/pmos/git/")
|
2017-08-23 16:40:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def rev_parse(args, revision="HEAD"):
|
|
|
|
rev = pmb.helpers.run.user(args, ["git", "rev-parse", revision],
|
|
|
|
working_dir=args.aports,
|
|
|
|
return_stdout=True,
|
|
|
|
check=False)
|
|
|
|
if rev is None:
|
|
|
|
logging.warning("WARNING: Failed to determine revision of git repository at " + args.aports)
|
|
|
|
return ""
|
|
|
|
return rev.rstrip()
|