ostbuild: Separate metadata discovery, kill wrapper scripts
Add a simple KEY=VALUE metadata file format, and rather than assuming 'basename' at a low level, allow passing e.g. NAME=gtk3 to override "gtk+". The wrapper scripts are annoying...for now let's just remove them.
This commit is contained in:
parent
835e0eae59
commit
0b8754d47c
|
|
@ -15,9 +15,9 @@
|
||||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
bin_SCRIPTS += src/ostbuild/ostbuild-compile-one \
|
bin_SCRIPTS += \
|
||||||
|
src/ostbuild/ostbuild-autodiscover-meta \
|
||||||
src/ostbuild/ostbuild-compile-one-impl \
|
src/ostbuild/ostbuild-compile-one-impl \
|
||||||
src/ostbuild/ostbuild-chroot-compile-one \
|
|
||||||
src/ostbuild/ostbuild-chroot-compile-one-impl \
|
src/ostbuild/ostbuild-chroot-compile-one-impl \
|
||||||
src/ostbuild/ostbuild-nice-and-log-output \
|
src/ostbuild/ostbuild-nice-and-log-output \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/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,tempfile,shutil
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="Discover source metadata from current directory")
|
||||||
|
parser.add_argument('--meta')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
AUTODISCOVERED_KEYS = {}
|
||||||
|
KEYS = {}
|
||||||
|
|
||||||
|
def _register_discover_func(key, func):
|
||||||
|
if key not in AUTODISCOVERED_KEYS:
|
||||||
|
AUTODISCOVERED_KEYS[key] = []
|
||||||
|
AUTODISCOVERED_KEYS[key].append(func)
|
||||||
|
|
||||||
|
def _discover_name_from_cwd():
|
||||||
|
return os.path.basename(os.getcwd())
|
||||||
|
_register_discover_func('NAME', _discover_name_from_cwd)
|
||||||
|
|
||||||
|
def _discover_version_from_git():
|
||||||
|
if os.path.isdir('.git'):
|
||||||
|
try:
|
||||||
|
version = subprocess.check_output(['git', 'describe'])
|
||||||
|
except subprocess.CalledProcessError, e:
|
||||||
|
version = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
|
||||||
|
return version.strip()
|
||||||
|
return None
|
||||||
|
_register_discover_func('VERSION', _discover_version_from_git)
|
||||||
|
|
||||||
|
if args.meta:
|
||||||
|
f = open(args.meta)
|
||||||
|
for line in f.readlines():
|
||||||
|
(k,v) = line.split('=', 1)
|
||||||
|
KEYS[k.strip()] = v.strip()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
for (key,hooks) in AUTODISCOVERED_KEYS.iteritems():
|
||||||
|
if key in KEYS:
|
||||||
|
continue
|
||||||
|
for func in hooks:
|
||||||
|
value = func()
|
||||||
|
|
||||||
|
if value is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
KEYS[key] = value
|
||||||
|
break
|
||||||
|
|
||||||
|
for (key,value) in KEYS.iteritems():
|
||||||
|
print "%s=%s" % (key, value)
|
||||||
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
#!/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 "$@"
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
import os,sys,re,subprocess,tempfile,shutil
|
import os,sys,re,subprocess,tempfile,shutil
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path
|
||||||
|
|
||||||
def get_build_env():
|
def get_build_env():
|
||||||
return {'HOME' : '/',
|
return {'HOME' : '/',
|
||||||
'HOSTNAME' : 'ostbuild',
|
'HOSTNAME' : 'ostbuild',
|
||||||
|
|
@ -36,6 +38,7 @@ parser = argparse.ArgumentParser(description="Build a module in a given root")
|
||||||
parser.add_argument('--repo')
|
parser.add_argument('--repo')
|
||||||
parser.add_argument('--resultdir')
|
parser.add_argument('--resultdir')
|
||||||
parser.add_argument('--branch')
|
parser.add_argument('--branch')
|
||||||
|
parser.add_argument('--meta')
|
||||||
parser.add_argument('--debug-shell', type=bool)
|
parser.add_argument('--debug-shell', type=bool)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
#!/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-compile-one-impl "$@"
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
# http://people.gnome.org/~walters/docs/build-api.txt
|
# http://people.gnome.org/~walters/docs/build-api.txt
|
||||||
|
|
||||||
import os,sys,subprocess,tempfile,re
|
import os,sys,subprocess,tempfile,re
|
||||||
|
from StringIO import StringIO
|
||||||
from multiprocessing import cpu_count
|
from multiprocessing import cpu_count
|
||||||
import select,time
|
import select,time
|
||||||
|
|
||||||
|
|
@ -71,15 +72,35 @@ makeargs = ['make']
|
||||||
top_srcdir=os.getcwd()
|
top_srcdir=os.getcwd()
|
||||||
|
|
||||||
ostbuild_resultdir=top_srcdir
|
ostbuild_resultdir=top_srcdir
|
||||||
|
ostbuild_meta=None
|
||||||
|
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if arg.startswith('OSTBUILD_RESULTDIR='):
|
if arg.startswith('OSTBUILD_RESULTDIR='):
|
||||||
ostbuild_resultdir=arg[len('OSTBUILD_RESULTDIR='):]
|
ostbuild_resultdir=arg[len('OSTBUILD_RESULTDIR='):]
|
||||||
|
elif arg.startswith('OSTBUILD_META='):
|
||||||
|
ostbuild_meta=arg[len('OSTBUILD_META='):]
|
||||||
elif arg.startswith('--'):
|
elif arg.startswith('--'):
|
||||||
configargs.append(arg)
|
configargs.append(arg)
|
||||||
else:
|
else:
|
||||||
makeargs.append(arg)
|
makeargs.append(arg)
|
||||||
|
|
||||||
|
metadata = {}
|
||||||
|
|
||||||
|
if ostbuild_meta is None:
|
||||||
|
output = subprocess.check_output(['ostbuild-autodiscover-meta'])
|
||||||
|
ostbuild_meta_f = StringIO(output)
|
||||||
|
else:
|
||||||
|
ostbuild_meta_f = open(ostbuild_meta)
|
||||||
|
|
||||||
|
for line in ostbuild_meta_f:
|
||||||
|
(k,v) = line.split('=', 1)
|
||||||
|
metadata[k.strip()] = v.strip()
|
||||||
|
|
||||||
|
for k in ['NAME', 'VERSION']:
|
||||||
|
if k not in metadata:
|
||||||
|
sys.stderr.write('Missing required key "%s" in metadata' % (k, ))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
fullmsg = '%s: %s\n' % (sys.argv[0], msg)
|
fullmsg = '%s: %s\n' % (sys.argv[0], msg)
|
||||||
sys.stdout.write(fullmsg)
|
sys.stdout.write(fullmsg)
|
||||||
|
|
@ -269,19 +290,13 @@ def make_artifact(name, from_files, tempdir=None, resultdir=None):
|
||||||
log("created: %s" % (os.path.abspath (result_path), ))
|
log("created: %s" % (os.path.abspath (result_path), ))
|
||||||
|
|
||||||
def phase_make_artifacts(builddir=None):
|
def phase_make_artifacts(builddir=None):
|
||||||
basename=os.path.basename(os.getcwd())
|
name = metadata['NAME']
|
||||||
|
version = metadata['VERSION']
|
||||||
|
assert ',' not in version
|
||||||
|
|
||||||
try:
|
artifact_prefix='artifact-%s-%s,%s' % (build_target, name, version)
|
||||||
version = subprocess.check_output(['git', 'describe'])
|
|
||||||
except subprocess.CalledProcessError, e:
|
|
||||||
version = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
|
|
||||||
version = version.strip()
|
|
||||||
|
|
||||||
version = version.replace(',', '_')
|
tempdir = tempfile.mkdtemp(prefix='ostree-build-%s-' % (name,))
|
||||||
|
|
||||||
artifact_prefix='artifact-%s-%s,%s' % (build_target, basename, version)
|
|
||||||
|
|
||||||
tempdir = tempfile.mkdtemp(prefix='ostree-build-%s-' % (basename,))
|
|
||||||
tempfiles.append(tempdir)
|
tempfiles.append(tempdir)
|
||||||
args = ['make', 'install', 'DESTDIR=' + tempdir]
|
args = ['make', 'install', 'DESTDIR=' + tempdir]
|
||||||
run_sync(args, cwd=builddir)
|
run_sync(args, cwd=builddir)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue