core: Split pull functionality into separate ostree-pull binary

This is to avoid everything depending on libsoup.
This commit is contained in:
Colin Walters committed 2011-11-30 09:21:14 -05:00
1 parent 3ac841d931
commit e8865af09e
14 files changed
+378 -157

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/python
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
# http://people.gnome.org/~walters/docs/build-api.txt
import os,sys,subprocess,tempfile,re
i=1
repo=sys.argv[i]
artifact_re = re.compile(r'^artifact-([^,]+)-([^,]+),(.+).tar.gz$')
if os.getuid() != 0:
print "This program must be run as root."
sys.exit(1)
def call_ostree_sync(*args):
subprocess.check_call(['ostree', '--repo=' + repo] + args)
for arg in sys.argv[1:]:
match = artifact_re.match(arg)
if match is None
print "Invalid artifact name: %s" % (arg, )
sys.exit(1)
arch = match.group(1)
name = match.group(2)
version = match.group(3)
branch_name = 'artifact-%s-%s' % (arch, name)
call_ostree_sync('commit', '-b', branch_name, '-s', version,
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Author: Colin Walters <walters@verbum.org>
bn=$(basename $(pwd))
ostbuild-nice-and-log-output "compile-${bn}.log" ostbuild-chroot-compile-one-impl "$@"
@@ -0,0 +1,53 @@
#!/usr/bin/python
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
import os,sys,re,subprocess
i=1
repo=sys.argv[i]
i += 1
chroot_path=sys.argv[i]
i += 1
args=sys.argv[i:]
if os.getuid() != 0:
print "This program must be run as root."
sys.exit(1)
rootdir=os.path.join(chroot_path, 'root')
if not os.path.isdir(rootdir):
print "Not a directory: %s" % (rootdir, )
sys.exit(1)
builddir = os.path.join(rootdir, 'ostree-build')
if not os.path.isdir(builddir):
os.mkdir(builddir)
def run_in_chroot(args):
proc_path=os.path.join(chroot_path, 'proc')
subprocess.check_call(['mount', '-t', 'proc', 'proc', proc_path])
try:
subprocess.check_call(['chroot', chroot_path])
finally:
subprocess.call(['umount', proc_path])
run_in_chroot(args)