mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-26 14:04:12 +03:00
ostbuild: Kill "autodiscover-meta"
No longer needed.
This commit is contained in:
parent
d3059d254b
commit
c11cefb99b
@ -22,7 +22,6 @@ bin_SCRIPTS += ostbuild
|
|||||||
pyostbuilddir=$(libdir)/ostbuild/pyostbuild
|
pyostbuilddir=$(libdir)/ostbuild/pyostbuild
|
||||||
pyostbuild_PYTHON = \
|
pyostbuild_PYTHON = \
|
||||||
src/ostbuild/pyostbuild/buildutil.py \
|
src/ostbuild/pyostbuild/buildutil.py \
|
||||||
src/ostbuild/pyostbuild/builtin_autodiscover_meta.py \
|
|
||||||
src/ostbuild/pyostbuild/builtin_build.py \
|
src/ostbuild/pyostbuild/builtin_build.py \
|
||||||
src/ostbuild/pyostbuild/builtin_checkout.py \
|
src/ostbuild/pyostbuild/builtin_checkout.py \
|
||||||
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
|
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
#!/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
|
|
||||||
import json
|
|
||||||
|
|
||||||
from . import builtins
|
|
||||||
from . import buildutil
|
|
||||||
from .ostbuildlog import log, fatal
|
|
||||||
from .subprocess_helpers import run_sync, run_sync_get_output
|
|
||||||
|
|
||||||
class OstbuildAutodiscoverMeta(builtins.Builtin):
|
|
||||||
name = "autodiscover-meta"
|
|
||||||
short_description = "Extract metadata from the current source directory"
|
|
||||||
|
|
||||||
def execute(self, argv):
|
|
||||||
parser = argparse.ArgumentParser(self.short_description)
|
|
||||||
parser.add_argument('--meta')
|
|
||||||
|
|
||||||
args = parser.parse_args(argv)
|
|
||||||
|
|
||||||
KEYS = {}
|
|
||||||
AUTODISCOVERED_KEYS = {}
|
|
||||||
|
|
||||||
def _register_discover_func(key, func):
|
|
||||||
if key not in AUTODISCOVERED_KEYS:
|
|
||||||
AUTODISCOVERED_KEYS[key] = []
|
|
||||||
AUTODISCOVERED_KEYS[key].append(func)
|
|
||||||
|
|
||||||
_register_discover_func('name', self._discover_name_from_cwd)
|
|
||||||
_register_discover_func('version', self._discover_version_from_git)
|
|
||||||
_register_discover_func('branch', self._discover_branch_from_git)
|
|
||||||
|
|
||||||
if args.meta:
|
|
||||||
f = open(args.meta)
|
|
||||||
KEYS = json.load(f)
|
|
||||||
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
|
|
||||||
|
|
||||||
json.dump(KEYS, sys.stdout, indent=2)
|
|
||||||
|
|
||||||
def _discover_name_from_cwd(self):
|
|
||||||
return os.path.basename(os.getcwd())
|
|
||||||
|
|
||||||
def _discover_version_from_git(self):
|
|
||||||
if os.path.isdir('.git'):
|
|
||||||
return buildutil.get_git_version_describe(os.getcwd())
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _discover_branch_from_git(self):
|
|
||||||
if os.path.isdir('.git'):
|
|
||||||
devnull=open('/dev/null', 'w')
|
|
||||||
ref = run_sync_get_output(['git', 'symbolic-ref', 'HEAD'], stderr=devnull, none_on_error=True)
|
|
||||||
if ref is not None:
|
|
||||||
return ref.replace('refs/heads/', '').strip()
|
|
||||||
ref = run_sync_get_output(['git', 'describe', '--tags', '--exact-match', 'HEAD'], stderr=devnull, none_on_error=True)
|
|
||||||
if ref is not None:
|
|
||||||
return ref
|
|
||||||
return None
|
|
||||||
|
|
||||||
builtins.register(OstbuildAutodiscoverMeta)
|
|
@ -22,7 +22,6 @@ import sys
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from . import builtins
|
from . import builtins
|
||||||
from . import builtin_autodiscover_meta
|
|
||||||
from . import builtin_build
|
from . import builtin_build
|
||||||
from . import builtin_checkout
|
from . import builtin_checkout
|
||||||
from . import builtin_chroot_compile_one
|
from . import builtin_chroot_compile_one
|
||||||
|
Loading…
x
Reference in New Issue
Block a user