Reworking these to look attempt to find the right parent directory, as well
as adjustments due to sysvinit rename.
This commit is contained in:
parent
1516bfb51d
commit
a80727a512
@ -5,11 +5,21 @@ import shutil
|
|||||||
import sys
|
import sys
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
|
||||||
|
def find_root():
|
||||||
|
look_where = [
|
||||||
|
os.path.join(os.getcwd(), 'setup.py'),
|
||||||
|
os.path.join(os.pardir, 'setup.py'),
|
||||||
|
]
|
||||||
|
for fn in look_where:
|
||||||
|
if os.path.isfile(fn):
|
||||||
|
return os.path.dirname(os.path.abspath(fn))
|
||||||
|
raise ImportError(("Unable to determine where your cloud-init 'setup.py'"
|
||||||
|
" file is located at!"))
|
||||||
|
|
||||||
|
|
||||||
# Use the util functions from cloudinit
|
# Use the util functions from cloudinit
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
sys.path.insert(0, find_root())
|
||||||
sys.argv[0]), os.pardir, os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cloudinit import templater
|
from cloudinit import templater
|
||||||
from cloudinit import util
|
from cloudinit import util
|
||||||
@ -34,7 +44,8 @@ def write_debian_folder(root, version, revno, init_sys):
|
|||||||
os.makedirs(deb_dir)
|
os.makedirs(deb_dir)
|
||||||
|
|
||||||
# Fill in the change log template
|
# Fill in the change log template
|
||||||
templater.render_to_file(util.abs_join('debian', 'changelog'),
|
templater.render_to_file(util.abs_join(find_root(),
|
||||||
|
'packages', 'debian', 'changelog'),
|
||||||
util.abs_join(deb_dir, 'changelog'),
|
util.abs_join(deb_dir, 'changelog'),
|
||||||
params={
|
params={
|
||||||
'version': version,
|
'version': version,
|
||||||
@ -43,7 +54,7 @@ def write_debian_folder(root, version, revno, init_sys):
|
|||||||
|
|
||||||
# Write out the control file template
|
# Write out the control file template
|
||||||
cmd = [sys.executable,
|
cmd = [sys.executable,
|
||||||
util.abs_join(os.pardir, 'tools', 'read-dependencies')]
|
util.abs_join(find_root(), 'tools', 'read-dependencies')]
|
||||||
(stdout, _stderr) = util.subp(cmd)
|
(stdout, _stderr) = util.subp(cmd)
|
||||||
|
|
||||||
# Map to known packages
|
# Map to known packages
|
||||||
@ -61,17 +72,20 @@ def write_debian_folder(root, version, revno, init_sys):
|
|||||||
else:
|
else:
|
||||||
requires.append(tgt_pkg)
|
requires.append(tgt_pkg)
|
||||||
|
|
||||||
templater.render_to_file(util.abs_join('debian', 'control'),
|
templater.render_to_file(util.abs_join(find_root(),
|
||||||
|
'packages', 'debian', 'control'),
|
||||||
util.abs_join(deb_dir, 'control'),
|
util.abs_join(deb_dir, 'control'),
|
||||||
params={'requires': requires})
|
params={'requires': requires})
|
||||||
|
|
||||||
templater.render_to_file(util.abs_join('debian', 'rules'),
|
templater.render_to_file(util.abs_join(find_root(),
|
||||||
|
'packages', 'debian', 'rules'),
|
||||||
util.abs_join(deb_dir, 'rules'),
|
util.abs_join(deb_dir, 'rules'),
|
||||||
params={'init_sys': init_sys})
|
params={'init_sys': init_sys})
|
||||||
|
|
||||||
# Just copy the following directly
|
# Just copy the following directly
|
||||||
for base_fn in ['dirs', 'copyright', 'compat', 'pycompat']:
|
for base_fn in ['dirs', 'copyright', 'compat', 'pycompat']:
|
||||||
shutil.copy(util.abs_join('debian', base_fn),
|
shutil.copy(util.abs_join(find_root(),
|
||||||
|
'packages', 'debian', base_fn),
|
||||||
util.abs_join(deb_dir, base_fn))
|
util.abs_join(deb_dir, base_fn))
|
||||||
|
|
||||||
|
|
||||||
@ -100,8 +114,7 @@ def main():
|
|||||||
|
|
||||||
with util.tempdir() as tdir:
|
with util.tempdir() as tdir:
|
||||||
|
|
||||||
cmd = [sys.executable,
|
cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
|
||||||
util.abs_join(os.pardir, 'tools', 'read-version')]
|
|
||||||
(sysout, _stderr) = util.subp(cmd)
|
(sysout, _stderr) = util.subp(cmd)
|
||||||
version = sysout.strip()
|
version = sysout.strip()
|
||||||
|
|
||||||
@ -113,24 +126,20 @@ def main():
|
|||||||
# since we will extract it then add in the debian
|
# since we will extract it then add in the debian
|
||||||
# folder, then re-archive it for debian happiness
|
# folder, then re-archive it for debian happiness
|
||||||
print("Creating a temporary tarball using the 'make-tarball' helper")
|
print("Creating a temporary tarball using the 'make-tarball' helper")
|
||||||
cmd = [sys.executable,
|
cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')]
|
||||||
util.abs_join(os.getcwd(), 'make-tarball')]
|
|
||||||
(sysout, _stderr) = util.subp(cmd)
|
(sysout, _stderr) = util.subp(cmd)
|
||||||
arch_fn = sysout.strip()
|
arch_fn = sysout.strip()
|
||||||
tmp_arch_fn = util.abs_join(tdir, os.path.basename(arch_fn))
|
tmp_arch_fn = util.abs_join(tdir, os.path.basename(arch_fn))
|
||||||
shutil.move(arch_fn, tmp_arch_fn)
|
shutil.move(arch_fn, tmp_arch_fn)
|
||||||
|
|
||||||
print("Extracting temporary tarball %r" % (tmp_arch_fn))
|
print("Extracting temporary tarball %r" % (tmp_arch_fn))
|
||||||
cmd = ['tar', '-xvzf', tmp_arch_fn, '-C', tdir]
|
xdir = util.abs_join(tdir, 'cloud-init')
|
||||||
|
os.makedirs(xdir)
|
||||||
|
cmd = ['tar', '-xvzf', tmp_arch_fn, '-C', xdir]
|
||||||
util.subp(cmd, capture=capture)
|
util.subp(cmd, capture=capture)
|
||||||
base_name = os.path.basename(arch_fn)[:-len(".tar.gz")]
|
|
||||||
shutil.move(util.abs_join(tdir, base_name),
|
|
||||||
util.abs_join(tdir, 'cloud-init'))
|
|
||||||
|
|
||||||
print("Creating a debian/ folder in %r" %
|
print("Creating a debian/ folder in %r" % (xdir)))
|
||||||
(util.abs_join(tdir, 'cloud-init')))
|
write_debian_folder(xdir, version, revno, args.boot)
|
||||||
write_debian_folder(util.abs_join(tdir, 'cloud-init'),
|
|
||||||
version, revno, args.boot)
|
|
||||||
|
|
||||||
# The naming here seems to follow some debian standard
|
# The naming here seems to follow some debian standard
|
||||||
# so it will whine if it is changed...
|
# so it will whine if it is changed...
|
||||||
@ -138,13 +147,13 @@ def main():
|
|||||||
print("Archiving that new folder into %r" % (tar_fn))
|
print("Archiving that new folder into %r" % (tar_fn))
|
||||||
cmd = ['tar', '-czvf',
|
cmd = ['tar', '-czvf',
|
||||||
util.abs_join(tdir, tar_fn),
|
util.abs_join(tdir, tar_fn),
|
||||||
'-C', util.abs_join(tdir, 'cloud-init')]
|
'-C', xdir]
|
||||||
cmd.extend(os.listdir(util.abs_join(tdir, 'cloud-init')))
|
cmd.extend(os.listdir(xdir))
|
||||||
util.subp(cmd, capture=capture)
|
util.subp(cmd, capture=capture)
|
||||||
shutil.copy(util.abs_join(tdir, tar_fn), tar_fn)
|
shutil.copy(util.abs_join(tdir, tar_fn), tar_fn)
|
||||||
print("Wrote out archive %r" % (util.abs_join(tar_fn)))
|
print("Wrote out archive %r" % (util.abs_join(tar_fn)))
|
||||||
|
|
||||||
print("Running 'debuild' in %r" % (util.abs_join(tdir, 'cloud-init')))
|
print("Running 'debuild' in %r" % (xdir))
|
||||||
with util.chdir(util.abs_join(tdir, 'cloud-init')):
|
with util.chdir(util.abs_join(tdir, 'cloud-init')):
|
||||||
cmd = ['debuild']
|
cmd = ['debuild']
|
||||||
if not args.sign:
|
if not args.sign:
|
||||||
|
@ -11,11 +11,21 @@ import re
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
def find_root():
|
||||||
|
look_where = [
|
||||||
|
os.path.join(os.getcwd(), 'setup.py'),
|
||||||
|
os.path.join(os.pardir, 'setup.py'),
|
||||||
|
]
|
||||||
|
for fn in look_where:
|
||||||
|
if os.path.isfile(fn):
|
||||||
|
return os.path.dirname(os.path.abspath(fn))
|
||||||
|
raise ImportError(("Unable to determine where your cloud-init 'setup.py'"
|
||||||
|
" file is located at!"))
|
||||||
|
|
||||||
|
|
||||||
# Use the util functions from cloudinit
|
# Use the util functions from cloudinit
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
sys.path.insert(0, find_root())
|
||||||
sys.argv[0]), os.pardir, os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cloudinit import templater
|
from cloudinit import templater
|
||||||
from cloudinit import util
|
from cloudinit import util
|
||||||
@ -82,8 +92,7 @@ def format_change_line(ds, who, comment=None):
|
|||||||
def generate_spec_contents(args, tmpl_fn):
|
def generate_spec_contents(args, tmpl_fn):
|
||||||
|
|
||||||
# Figure out the version and revno
|
# Figure out the version and revno
|
||||||
cmd = [sys.executable,
|
cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
|
||||||
util.abs_join(os.pardir, 'tools', 'read-version')]
|
|
||||||
(stdout, _stderr) = util.subp(cmd)
|
(stdout, _stderr) = util.subp(cmd)
|
||||||
version = stdout.strip()
|
version = stdout.strip()
|
||||||
|
|
||||||
@ -99,8 +108,7 @@ def generate_spec_contents(args, tmpl_fn):
|
|||||||
subs['archive_name'] = '%{name}-%{version}-' + revno + '.tar.gz'
|
subs['archive_name'] = '%{name}-%{version}-' + revno + '.tar.gz'
|
||||||
subs['bd_requires'] = ['python-devel', 'python-setuptools']
|
subs['bd_requires'] = ['python-devel', 'python-setuptools']
|
||||||
|
|
||||||
cmd = [sys.executable,
|
cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')]
|
||||||
util.abs_join(os.pardir, 'tools', 'read-dependencies')]
|
|
||||||
(stdout, _stderr) = util.subp(cmd)
|
(stdout, _stderr) = util.subp(cmd)
|
||||||
|
|
||||||
# Map to known packages
|
# Map to known packages
|
||||||
@ -122,7 +130,7 @@ def generate_spec_contents(args, tmpl_fn):
|
|||||||
subs['requires'] = requires
|
subs['requires'] = requires
|
||||||
|
|
||||||
# Format a nice changelog (as best as we can)
|
# Format a nice changelog (as best as we can)
|
||||||
changelog = util.load_file(util.abs_join(os.pardir, 'ChangeLog'))
|
changelog = util.load_file(util.abs_join(find_root(), 'ChangeLog'))
|
||||||
changelog_lines = []
|
changelog_lines = []
|
||||||
for line in changelog.splitlines():
|
for line in changelog.splitlines():
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
@ -159,8 +167,8 @@ def main():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-b", "--boot", dest="boot",
|
parser.add_argument("-b", "--boot", dest="boot",
|
||||||
help="select boot type (default: %(default)s)",
|
help="select boot type (default: %(default)s)",
|
||||||
metavar="TYPE", default='initd',
|
metavar="TYPE", default='sysvinit',
|
||||||
choices=('initd', 'systemd', 'initd-local'))
|
choices=('sysvinit', 'systemd'))
|
||||||
parser.add_argument("-v", "--verbose", dest="verbose",
|
parser.add_argument("-v", "--verbose", dest="verbose",
|
||||||
help=("run verbosely"
|
help=("run verbosely"
|
||||||
" (default: %(default)s)"),
|
" (default: %(default)s)"),
|
||||||
@ -179,17 +187,16 @@ def main():
|
|||||||
util.ensure_dirs([root_dir, arc_dir])
|
util.ensure_dirs([root_dir, arc_dir])
|
||||||
|
|
||||||
# Archive the code
|
# Archive the code
|
||||||
cmd = [sys.executable,
|
cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')]
|
||||||
util.abs_join(os.getcwd(), 'make-tarball')]
|
|
||||||
(stdout, _stderr) = util.subp(cmd)
|
(stdout, _stderr) = util.subp(cmd)
|
||||||
archive_fn = stdout.strip()
|
archive_fn = stdout.strip()
|
||||||
real_archive_fn = os.path.join(arc_dir, os.path.basename(archive_fn))
|
real_archive_fn = os.path.join(arc_dir, os.path.basename(archive_fn))
|
||||||
shutil.move(archive_fn, real_archive_fn)
|
shutil.move(archive_fn, real_archive_fn)
|
||||||
|
|
||||||
# Form the spec file to be used
|
# Form the spec file to be used
|
||||||
tmpl_fn = util.abs_join(os.getcwd(), 'redhat', 'cloud-init.spec')
|
tmpl_fn = util.abs_join(find_root(), 'packages', 'redhat', 'cloud-init.spec')
|
||||||
contents = generate_spec_contents(args, tmpl_fn)
|
contents = generate_spec_contents(args, tmpl_fn)
|
||||||
spec_fn = os.path.join(root_dir, 'cloud-init.spec')
|
spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
|
||||||
util.write_file(spec_fn, contents)
|
util.write_file(spec_fn, contents)
|
||||||
|
|
||||||
# Now build it!
|
# Now build it!
|
||||||
@ -199,11 +206,11 @@ def main():
|
|||||||
# Copy the items built to our local dir
|
# Copy the items built to our local dir
|
||||||
globs = []
|
globs = []
|
||||||
globs.extend(glob.glob("%s/*.rpm" %
|
globs.extend(glob.glob("%s/*.rpm" %
|
||||||
(os.path.join(root_dir, 'RPMS', 'noarch'))))
|
(util.abs_join(root_dir, 'RPMS', 'noarch'))))
|
||||||
globs.extend(glob.glob("%s/*.rpm" %
|
globs.extend(glob.glob("%s/*.rpm" %
|
||||||
(os.path.join(root_dir, 'RPMS'))))
|
(util.abs_join(root_dir, 'RPMS'))))
|
||||||
globs.extend(glob.glob("%s/*.rpm" %
|
globs.extend(glob.glob("%s/*.rpm" %
|
||||||
(os.path.join(root_dir, 'SRPMS'))))
|
(util.abs_join(root_dir, 'SRPMS'))))
|
||||||
for rpm_fn in globs:
|
for rpm_fn in globs:
|
||||||
tgt_fn = util.abs_join(os.getcwd(), os.path.basename(rpm_fn))
|
tgt_fn = util.abs_join(os.getcwd(), os.path.basename(rpm_fn))
|
||||||
shutil.move(rpm_fn, tgt_fn)
|
shutil.move(rpm_fn, tgt_fn)
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import contextlib
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
import optparse
|
|
||||||
|
|
||||||
|
|
||||||
# Use the util functions from cloudinit
|
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
|
||||||
sys.argv[0]), os.pardir, os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cloudinit import util
|
|
||||||
|
|
||||||
|
|
||||||
def find_versioned_files():
|
|
||||||
(stdout, _stderr) = util.subp(['bzr', 'ls', '--versioned', '--recursive'])
|
|
||||||
fns = [fn for fn in stdout.splitlines()
|
|
||||||
if fn and not fn.startswith('.')]
|
|
||||||
fns.sort()
|
|
||||||
return fns
|
|
||||||
|
|
||||||
|
|
||||||
def copy(fn, where_to, verbose):
|
|
||||||
if verbose:
|
|
||||||
print("Copying %r --> %r" % (fn, where_to))
|
|
||||||
if os.path.isfile(fn):
|
|
||||||
shutil.copy(fn, where_to)
|
|
||||||
elif os.path.isdir(fn) and not os.path.isdir(where_to):
|
|
||||||
os.makedirs(where_to)
|
|
||||||
else:
|
|
||||||
raise RuntimeError("Do not know how to copy %s" % (fn))
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
parser = optparse.OptionParser()
|
|
||||||
parser.add_option("-f", "--file", dest="filename",
|
|
||||||
help="write archive to FILE", metavar="FILE")
|
|
||||||
parser.add_option("-v", "--verbose",
|
|
||||||
action="store_true", dest="verbose", default=False,
|
|
||||||
help="show verbose messaging")
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
base_fn = options.filename
|
|
||||||
if not base_fn:
|
|
||||||
(stdout, _stderr) = util.subp(['bzr', 'revno'])
|
|
||||||
revno = stdout.strip()
|
|
||||||
cmd = [sys.executable,
|
|
||||||
util.abs_join(os.pardir, 'tools', 'read-version')]
|
|
||||||
(stdout, _stderr) = util.subp(cmd)
|
|
||||||
version = stdout.strip()
|
|
||||||
base_fn = 'cloud-init-%s-%s' % (version, revno)
|
|
||||||
|
|
||||||
with util.tempdir() as tdir:
|
|
||||||
util.ensure_dir(util.abs_join(tdir, base_fn))
|
|
||||||
arch_fn = '%s.tar.gz' % (base_fn)
|
|
||||||
|
|
||||||
with util.chdir(os.pardir):
|
|
||||||
fns = find_versioned_files()
|
|
||||||
for fn in fns:
|
|
||||||
copy(fn, util.abs_join(tdir, base_fn, fn),
|
|
||||||
verbose=options.verbose)
|
|
||||||
|
|
||||||
arch_full_fn = util.abs_join(tdir, arch_fn)
|
|
||||||
cmd = ['tar', '-czvf', arch_full_fn, '-C', tdir, base_fn]
|
|
||||||
if options.verbose:
|
|
||||||
print("Creating an archive from directory %r to %r" %
|
|
||||||
(util.abs_join(tdir, base_fn), arch_full_fn))
|
|
||||||
|
|
||||||
util.subp(cmd, capture=(not options.verbose))
|
|
||||||
shutil.move(util.abs_join(tdir, arch_fn),
|
|
||||||
util.abs_join(os.getcwd(), arch_fn))
|
|
||||||
|
|
||||||
print(os.path.abspath(arch_fn))
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.exit(main())
|
|
||||||
|
|
33
tools/make-tarball
Executable file
33
tools/make-tarball
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ROOT_DIR=""
|
||||||
|
if [ -e "setup.py" ]
|
||||||
|
then
|
||||||
|
ROOT_DIR="$PWD"
|
||||||
|
elif [ -e "../setup.py" ]
|
||||||
|
then
|
||||||
|
ROOT_DIR="$PWD/../"
|
||||||
|
else
|
||||||
|
echo "Unable to locate 'setup.py' file that should" \
|
||||||
|
"exist in the cloud-init root directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$1" ]
|
||||||
|
then
|
||||||
|
ARCHIVE_FN="$1"
|
||||||
|
else
|
||||||
|
REVNO=$(bzr revno $ROOT_DIR)
|
||||||
|
VERSION=$($ROOT_DIR/tools/read-version)
|
||||||
|
ARCHIVE_FN="$PWD/cloud-init-$REVNO-$VERSION.tar.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILES=$(cd $ROOT_DIR && bzr ls --versioned --recursive)
|
||||||
|
echo "$FILES" | tar czf $ARCHIVE_FN \
|
||||||
|
-C "$ROOT_DIR" \
|
||||||
|
--no-recursion --files-from -
|
||||||
|
|
||||||
|
echo "$ARCHIVE_FN"
|
||||||
|
|
@ -1,45 +1,30 @@
|
|||||||
#!/usr/bin/python
|
#!/bin/sh
|
||||||
# vi: ts=4 expandtab
|
|
||||||
|
|
||||||
import os
|
set -e
|
||||||
import sys
|
|
||||||
import re
|
if [ -e "setup.py" ]
|
||||||
|
then
|
||||||
|
ROOT_DIR="$PWD"
|
||||||
|
elif [ -e "../setup.py" ]
|
||||||
|
then
|
||||||
|
ROOT_DIR="$PWD/../"
|
||||||
|
else
|
||||||
|
echo "Unable to locate 'setup.py' file that should" \
|
||||||
|
"exist in the cloud-init root directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REQUIRES="$ROOT_DIR/Requires"
|
||||||
|
|
||||||
|
if [ ! -e "$REQUIRES" ]
|
||||||
|
then
|
||||||
|
echo "Unable to find 'Requires' file located at $REQUIRES"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Filter out comments and empty liens
|
||||||
|
DEPS=$(cat $REQUIRES | grep -Pv "^\s*#" | grep -Pv '^\s*$')
|
||||||
|
echo "$DEPS" | sort -d -f
|
||||||
|
|
||||||
|
|
||||||
def parse_requires(fn):
|
|
||||||
requires = []
|
|
||||||
with open(fn, 'r') as fh:
|
|
||||||
lines = fh.read().splitlines()
|
|
||||||
for line in lines:
|
|
||||||
line = line.strip()
|
|
||||||
if not line or line[0] == '#':
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
requires.append(line)
|
|
||||||
return requires
|
|
||||||
|
|
||||||
|
|
||||||
def find_requires(args):
|
|
||||||
p_files = []
|
|
||||||
if args:
|
|
||||||
p_files.append(args[0])
|
|
||||||
p_files.append(os.path.join(os.pardir, "Requires"))
|
|
||||||
p_files.append(os.path.join(os.getcwd(), 'Requires'))
|
|
||||||
found = None
|
|
||||||
for fn in p_files:
|
|
||||||
if os.path.isfile(fn):
|
|
||||||
found = fn
|
|
||||||
break
|
|
||||||
return found
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
run_args = sys.argv[1:]
|
|
||||||
fn = find_requires(run_args)
|
|
||||||
if not fn:
|
|
||||||
sys.stderr.write("'Requires' file not found!\n")
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
deps = parse_requires(fn)
|
|
||||||
for entry in deps:
|
|
||||||
print entry
|
|
||||||
|
@ -1,70 +1,27 @@
|
|||||||
#!/usr/bin/python
|
#!/bin/sh
|
||||||
# vi: ts=4 expandtab
|
|
||||||
|
|
||||||
import os
|
set -e
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
|
|
||||||
from distutils import version as ver
|
if [ -e "setup.py" ]
|
||||||
|
then
|
||||||
|
ROOT_DIR="$PWD"
|
||||||
|
elif [ -e "../setup.py" ]
|
||||||
|
then
|
||||||
|
ROOT_DIR="$PWD/../"
|
||||||
|
else
|
||||||
|
echo "Unable to locate 'setup.py' file that should" \
|
||||||
|
"exist in the cloud-init root directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
CHNG_LOG="$ROOT_DIR/ChangeLog"
|
||||||
sys.argv[0]), os.pardir, os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cloudinit import version as cver
|
if [ ! -e "$CHNG_LOG" ]
|
||||||
|
then
|
||||||
|
echo "Unable to find 'ChangeLog' file located at $CHNG_LOG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
def parse_versions(fn):
|
VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG | cut -f1 -d ":" | head -n 1)
|
||||||
with open(fn, 'r') as fh:
|
echo $VERSION
|
||||||
lines = fh.read().splitlines()
|
|
||||||
versions = []
|
|
||||||
for line in lines:
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith("-") or not line:
|
|
||||||
continue
|
|
||||||
if not re.match(r"[\d]", line):
|
|
||||||
continue
|
|
||||||
line = line.strip(":")
|
|
||||||
if (re.match(r"^[\d+]\.[\d+]\.[\d+]$", line) or
|
|
||||||
re.match(r"^[\d+]\.[\d+]$", line)):
|
|
||||||
versions.append(line)
|
|
||||||
return versions
|
|
||||||
|
|
||||||
def find_changelog(args):
|
|
||||||
p_files = []
|
|
||||||
if args:
|
|
||||||
p_files.append(args[0])
|
|
||||||
p_files.append(os.path.join(os.pardir, "ChangeLog"))
|
|
||||||
p_files.append(os.path.join(os.getcwd(), 'ChangeLog'))
|
|
||||||
found = None
|
|
||||||
for fn in p_files:
|
|
||||||
if os.path.isfile(fn):
|
|
||||||
found = fn
|
|
||||||
break
|
|
||||||
return found
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
run_args = sys.argv[1:]
|
|
||||||
fn = find_changelog(run_args)
|
|
||||||
if not fn:
|
|
||||||
sys.stderr.write("'ChangeLog' file not found!\n")
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
versions = parse_versions(fn)
|
|
||||||
if not versions:
|
|
||||||
sys.stderr.write("No versions found in %s!\n" % (fn))
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
# Check that the code version is the same
|
|
||||||
# as the version we found!
|
|
||||||
ch_ver = versions[0].strip()
|
|
||||||
code_ver = cver.version()
|
|
||||||
ch_ver_obj = ver.StrictVersion(ch_ver)
|
|
||||||
if ch_ver_obj != code_ver:
|
|
||||||
sys.stderr.write(("Code version %s does not match"
|
|
||||||
" changelog version %s\n") %
|
|
||||||
(code_ver, ch_ver_obj))
|
|
||||||
sys.exit(1)
|
|
||||||
sys.stdout.write(ch_ver)
|
|
||||||
sys.exit(0)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user