mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
server: smooth out btlog transfer for offline signing setups
It turns out it is error prone to `git push` to a non-bare git repo. For the offline signing machine, the git remote needs to be a regular git repo in a directory on a thumbdrive so that once the thumbdrive is plugged into an online machine, that git repo can be transferred to the online machine.
This commit is contained in:
parent
be8e7830e1
commit
523b5f4777
@ -507,7 +507,8 @@ def push_binary_transparency(git_repo_path, git_remote):
|
|||||||
|
|
||||||
If the remote is a local directory, make sure it exists, and is a
|
If the remote is a local directory, make sure it exists, and is a
|
||||||
git repo. This is used to move this git repo from an offline
|
git repo. This is used to move this git repo from an offline
|
||||||
machine onto a flash drive, then onto the online machine.
|
machine onto a flash drive, then onto the online machine. Also,
|
||||||
|
this pulls because pushing to a non-bare git repo is error prone.
|
||||||
|
|
||||||
This is also used in offline signing setups, where it then also
|
This is also used in offline signing setups, where it then also
|
||||||
creates a "local copy dir" git repo that serves to shuttle the git
|
creates a "local copy dir" git repo that serves to shuttle the git
|
||||||
@ -518,24 +519,36 @@ def push_binary_transparency(git_repo_path, git_remote):
|
|||||||
'''
|
'''
|
||||||
import git
|
import git
|
||||||
|
|
||||||
if os.path.isdir(os.path.dirname(git_remote)) \
|
|
||||||
and not os.path.isdir(os.path.join(git_remote, '.git')):
|
|
||||||
os.makedirs(git_remote, exist_ok=True)
|
|
||||||
repo = git.Repo.init(git_remote)
|
|
||||||
config = repo.config_writer()
|
|
||||||
config.set_value('receive', 'denyCurrentBranch', 'updateInstead')
|
|
||||||
config.release()
|
|
||||||
|
|
||||||
logging.info('Pushing binary transparency log to ' + git_remote)
|
logging.info('Pushing binary transparency log to ' + git_remote)
|
||||||
gitrepo = git.Repo(git_repo_path)
|
|
||||||
origin = git.remote.Remote(gitrepo, 'origin')
|
if os.path.isdir(os.path.dirname(git_remote)):
|
||||||
if origin in gitrepo.remotes:
|
# from offline machine to thumbdrive
|
||||||
origin = gitrepo.remote('origin')
|
remote_path = os.path.abspath(git_repo_path)
|
||||||
if 'set_url' in dir(origin): # added in GitPython 2.x
|
if not os.path.isdir(os.path.join(git_remote, '.git')):
|
||||||
origin.set_url(git_remote)
|
os.makedirs(git_remote, exist_ok=True)
|
||||||
|
thumbdriverepo = git.Repo.init(git_remote)
|
||||||
|
local = thumbdriverepo.create_remote('local', remote_path)
|
||||||
|
else:
|
||||||
|
thumbdriverepo = git.Repo(git_remote)
|
||||||
|
local = git.remote.Remote(thumbdriverepo, 'local')
|
||||||
|
if local in thumbdriverepo.remotes:
|
||||||
|
local = thumbdriverepo.remote('local')
|
||||||
|
if 'set_url' in dir(local): # force remote URL if using GitPython 2.x
|
||||||
|
local.set_url(remote_path)
|
||||||
|
else:
|
||||||
|
local = thumbdriverepo.create_remote('local', remote_path)
|
||||||
|
local.pull('master')
|
||||||
else:
|
else:
|
||||||
origin = gitrepo.create_remote('origin', git_remote)
|
# from online machine to remote on a server on the internet
|
||||||
origin.push('master')
|
gitrepo = git.Repo(git_repo_path)
|
||||||
|
origin = git.remote.Remote(gitrepo, 'origin')
|
||||||
|
if origin in gitrepo.remotes:
|
||||||
|
origin = gitrepo.remote('origin')
|
||||||
|
if 'set_url' in dir(origin): # added in GitPython 2.x
|
||||||
|
origin.set_url(git_remote)
|
||||||
|
else:
|
||||||
|
origin = gitrepo.create_remote('origin', git_remote)
|
||||||
|
origin.push('master')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1051,24 +1051,20 @@ test `grep '<mirror>' archive/index.xml | wc -l` -eq 2
|
|||||||
cd binary_transparency
|
cd binary_transparency
|
||||||
[ `git rev-list --count HEAD` == "1" ]
|
[ `git rev-list --count HEAD` == "1" ]
|
||||||
cd ..
|
cd ..
|
||||||
if have_git_2_3; then
|
$fdroid server update --verbose
|
||||||
$fdroid server update --verbose
|
grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
|
||||||
grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
|
cd $ONLINE_ROOT
|
||||||
cd $ONLINE_ROOT
|
echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
|
||||||
echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
|
echo "sync_from_local_copy_dir = True" >> config.py
|
||||||
echo "sync_from_local_copy_dir = True" >> config.py
|
echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
|
||||||
echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
|
echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
|
||||||
echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
|
echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
|
||||||
echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
|
echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
|
||||||
echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
|
$fdroid server update --verbose
|
||||||
$fdroid server update --verbose
|
cd $BINARY_TRANSPARENCY_REMOTE
|
||||||
cd $BINARY_TRANSPARENCY_REMOTE
|
[ `git rev-list --count HEAD` == "1" ]
|
||||||
[ `git rev-list --count HEAD` == "1" ]
|
cd $SERVER_GIT_MIRROR
|
||||||
cd $SERVER_GIT_MIRROR
|
[ `git rev-list --count HEAD` == "1" ]
|
||||||
[ `git rev-list --count HEAD` == "1" ]
|
|
||||||
else
|
|
||||||
echo "Skipping test, `git --version` older than 2.3"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
|
Loading…
Reference in New Issue
Block a user