Skip to content

Commit 7c5a01f

Browse files
authored
Merge pull request #367 from alisw/next
Merge next into master in preparation of 1.4.0.rc1
2 parents c8185af + f7ac648 commit 7c5a01f

30 files changed

+520
-6060
lines changed

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
sudo: required
22
dist: trusty
3+
python:
4+
- "2.6"
5+
- "2.7"
6+
- "3.5"
37
services:
48
- docker
59
cache:
@@ -10,6 +14,7 @@ before_install: |
1014
cd ..
1115
git clone -b IB/v5-06/next https://github.com/alisw/alidist
1216
install: |
17+
pip install --user pyyaml
1318
pip install --user codecov
1419
pip install --user coverage
1520
script: |
@@ -36,6 +41,9 @@ script: |
3641
time coverage run -a alibuild/aliBuild -c alibuild/tests/testdist build broken4 --no-system --disable GCC-Toolchain 2>&1 | grep "Malformed header"
3742
time coverage run -a alibuild/aliBuild -c alibuild/tests/testdist build broken5 --no-system --disable GCC-Toolchain 2>&1 | grep "Missing package"
3843
time coverage run -a alibuild/aliBuild -c alibuild/tests/testdist build broken6 --no-system --disable GCC-Toolchain 2>&1 | grep scanning
44+
pushd alibuild
45+
time coverage run -a tests/test_parseRecipe.py
46+
popd
3947
time coverage run -a alibuild/aliBuild build zlib --no-system --disable GCC-Toolchain
4048
alibuild/alienv q
4149
alibuild/alienv setenv zlib/latest -c bash -c '[[ $LD_LIBRARY_PATH == */zlib/* ]]'

README.rst

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ Instant gratification with::
1616
Full documentation at:
1717

1818
https://alisw.github.io/alibuild
19+
20+
Pre-requisites
21+
==============
22+
23+
If you are using aliBuild directly from git clone, you should make sure
24+
you have `pyyaml` and `argparse` in your python distribution.

aliBuild

+152-157
Large diffs are not rendered by default.

aliDeps

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def format(s, **kwds):
1212
return s % kwds
1313

1414
def execute(command):
15-
popen = Popen(command, shell=(isinstance(command, basestring)), stdout=PIPE, stderr=STDOUT)
15+
popen = Popen(command, shell=(isinstance(command, str)), stdout=PIPE, stderr=STDOUT)
1616
linesIterator = iter(popen.stdout.readline, "")
1717
for line in linesIterator:
1818
debug(line.strip("\n")) # yield line
@@ -60,7 +60,7 @@ def deps(recipesDir, topPackage, outFile, buildRequires, transitiveRed, disable)
6060

6161
with NamedTemporaryFile(delete=False) as fp:
6262
fp.write("digraph {\n")
63-
for p,deps in dot.iteritems():
63+
for p,deps in list(dot.items()):
6464
if selected and not p in selected: continue
6565
fp.write(" \"%s\";\n" % p)
6666
for d in deps:

aliDoctor

+47-18
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ import os, re
44
from os.path import exists, abspath, expanduser
55
from glob import glob
66
import yaml
7-
from commands import getstatusoutput
7+
try:
8+
from commands import getstatusoutput
9+
except ImportError:
10+
from subprocess import getstatusoutput
811
import logging
912
from alibuild_helpers.log import debug, error, banner, info, success, warning
1013
from alibuild_helpers.log import logger_handler, logger, LogFormatter, ProgressPrint
11-
from alibuild_helpers.utilities import getPackageList, format, detectArch
14+
from alibuild_helpers.utilities import getPackageList, format, detectArch, parseDefaults, readDefaults
15+
from alibuild_helpers.utilities import dockerStatusOutput
1216
import subprocess
1317

1418
def execute(command):
@@ -27,12 +31,12 @@ def prunePaths(workDir):
2731
workDirEscaped = re.escape("%s" % workDir) + "[^:]*:?"
2832
os.environ[x] = re.sub(workDirEscaped, "", os.environ[x])
2933

30-
def checkPreferSystem(spec, cmd, homebrew_replacement):
34+
def checkPreferSystem(spec, cmd, homebrew_replacement, dockerImage):
3135
if cmd == "false":
3236
debug("Package %s can only be managed via alibuild." % spec["package"])
3337
return (1, "")
3438
cmd = homebrew_replacement + cmd
35-
err, out = execute(cmd)
39+
err, out = dockerStatusOutput(cmd, dockerImage=dockerImage, executor=execute)
3640
if not err:
3741
success("Package %s will be picked up from the system." % spec["package"])
3842
for x in out.split("\n"):
@@ -49,12 +53,12 @@ def checkPreferSystem(spec, cmd, homebrew_replacement):
4953
error="\n".join(["%s: %s" % (spec["package"],x) for x in out.split("\n")])))
5054
return (err, "")
5155

52-
def checkRequirements(spec, cmd, homebrew_replacement):
56+
def checkRequirements(spec, cmd, homebrew_replacement, dockerImage):
5357
if cmd == "false":
5458
debug("Package %s is not a system requirement." % spec["package"])
5559
return (0, "")
5660
cmd = homebrew_replacement + cmd
57-
err, out = execute(cmd)
61+
err, out = dockerStatusOutput(cmd, dockerImage=dockerImage, executor=execute)
5862
if not err:
5963
success("Required package %s will be picked up from the system." % spec["package"])
6064
debug(cmd)
@@ -92,16 +96,29 @@ if __name__ == "__main__":
9296
parser.add_argument("-a", "--architecture", help="force architecture",
9397
dest="architecture", default=detectArch())
9498
parser.add_argument("-c", "--config", help="path to alidist",
95-
dest="config", default="alidist")
99+
dest="configDir", default="alidist")
96100
parser.add_argument("-w", "--work-dir", help="path to work dir",
97101
dest="workDir", default="workDir")
98102
parser.add_argument("-d", "--debug", help="Show also successful tests.",
99103
dest="debug", action="store_true", default=False)
104+
parser.add_argument("--defaults", default="release",
105+
dest="defaults", help="Specify default to use")
106+
parser.add_argument("--disable", dest="disable", default=[],
107+
metavar="PACKAGE", action="append",
108+
help="Do not build PACKAGE and all its (unique) dependencies.")
109+
parser.add_argument("--always-prefer-system", dest="preferSystem", default=False,
110+
action="store_true", help="Always use system packages when compatible")
111+
parser.add_argument("--no-system", dest="noSystem", default=False,
112+
action="store_true", help="Never use system packages")
100113
parser.add_argument("packages", nargs="+", help="Package to test",
101114
default=[])
115+
parser.add_argument("--docker", dest="docker", action="store_true", default=False)
116+
parser.add_argument("--docker-image", dest="dockerImage",
117+
help="Image to use in case you build with docker (implies --docker-image)")
118+
102119
args = parser.parse_args()
103-
if not exists(args.config):
104-
parser.error("Wrong path to alidist specified: %s" % args.config)
120+
if not exists(args.configDir):
121+
parser.error("Wrong path to alidist specified: %s" % args.configDir)
105122

106123
prunePaths(abspath(args.workDir))
107124

@@ -117,6 +134,11 @@ if __name__ == "__main__":
117134
if err:
118135
homebrew_replacement = "brew() { true; }; "
119136

137+
138+
dockerImage = args.dockerImage if "dockerImage" in args else ""
139+
if args.docker and not dockerImage:
140+
dockerImage = "alisw/%s-builder" % args.architecture.split("_")[0]
141+
120142
logger.setLevel(logging.BANNER)
121143
if args.debug:
122144
logger.setLevel(logging.DEBUG)
@@ -125,29 +147,36 @@ if __name__ == "__main__":
125147
packages = []
126148
exitcode = 0
127149
for p in args.packages:
128-
path = "%s/%s.sh" % (args.config, p.lower())
150+
path = "%s/%s.sh" % (args.configDir, p.lower())
129151
if not exists(path):
130152
error("Cannot find recipe %s for package %s." % (path, p))
131153
exitcode = 1
132154
continue
133155
packages.append(p)
134-
135156
systemInfo()
136157

137158
specs = {}
138159
def unreachable():
139160
assert(False)
161+
defaultsReader = lambda : readDefaults(args.configDir, args.defaults, parser.error)
162+
(err, overrides, taps) = parseDefaults(args.disable, defaultsReader, info)
163+
if err:
164+
error(err)
165+
exit(1)
140166
(fromSystem, own, failed) = getPackageList(packages=packages,
141167
specs=specs,
142-
configDir=args.config,
143-
preferSystem=False,
144-
noSystem=False,
168+
configDir=args.configDir,
169+
preferSystem=args.preferSystem,
170+
noSystem=args.noSystem,
145171
architecture=args.architecture,
146-
disable=[],
147-
defaults="release",
172+
disable=args.disable,
173+
defaults=args.defaults,
148174
dieOnError=lambda x, y : unreachable,
149-
performPreferCheck=lambda pkg, cmd : checkPreferSystem(pkg, cmd, homebrew_replacement),
150-
performRequirementCheck=lambda pkg, cmd : checkRequirements(pkg, cmd, homebrew_replacement))
175+
performPreferCheck=lambda pkg, cmd : checkPreferSystem(pkg, cmd, homebrew_replacement, dockerImage),
176+
performRequirementCheck=lambda pkg, cmd : checkRequirements(pkg, cmd, homebrew_replacement, dockerImage),
177+
overrides=overrides,
178+
taps=taps,
179+
log=info)
151180

152181
if fromSystem:
153182
banner("The following packages will be picked up from the system:\n\n- " +

alibuild_helpers/__init__.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
# Dummy file to package build_template.sh
2-
import utilities as utilities
3-
import analytics as analytics
4-
import log as log
2+
import sys
3+
4+
# absolute import compatibility check
5+
if sys.version_info < (3, 0):
6+
import utilities
7+
import analytics
8+
import log
9+
else:
10+
from . import utilities
11+
from . import analytics
12+
from . import log
13+
14+
# remove non-project imports from this module
15+
del sys

alibuild_helpers/analytics.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env python
22
import os, subprocess, sys
3-
from commands import getstatusoutput
4-
from urllib import urlopen
3+
try:
4+
from commands import getstatusoutput
5+
from urllib import urlopen
6+
except ImportError:
7+
from subprocess import getstatusoutput
8+
from urllib.request import urlopen
59
from alibuild_helpers.log import debug, error, banner, info, logger_handler
610
from os.path import exists, expanduser
711
from os import unlink
@@ -21,7 +25,10 @@ def askForAnalytics():
2125
banner("In order to improve user experience, aliBuild would like to gather "
2226
"analytics about your builds.\nYou can find all the details at:\n\n"
2327
" https://github.com/alisw/alibuild/blob/master/ANALYTICS.md\n")
24-
a = raw_input("Is that ok for you [YES/no]? ")
28+
# raw_input and input are different between python 2 and 3
29+
try: input = raw_input
30+
except NameError: pass
31+
a = input("Is that ok for you [YES/no]? ")
2532
if a.strip() and a.strip().lower().startswith("n"):
2633
debug("User requsted disabling analytics.")
2734
return disable_analytics()

alibuild_helpers/build_template.sh

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Build script for %(pkgname)s -- automatically generated
3+
# Automatically generated build script
44

55
set -e
66
set +h
@@ -9,29 +9,34 @@ export WORK_DIR="${WORK_DIR_OVERRIDE:-%(workDir)s}"
99
# From our dependencies
1010
%(dependencies)s
1111

12-
export CAN_DELETE="%(can_delete)s"
13-
export PKGNAME="%(pkgname)s"
14-
export PKGHASH="%(hash)s"
15-
export PKGVERSION="%(version)s"
16-
export PKGREVISION="%(revision)s"
17-
export REQUIRES="%(requires)s"
18-
export BUILD_REQUIRES="%(build_requires)s"
19-
export RUNTIME_REQUIRES="%(runtime_requires)s"
20-
export DEVEL_PREFIX="%(develPrefix)s"
21-
DEVEL_HASH="%(develHash)s"
22-
DEPS_HASH="%(depsHash)s"
12+
# The following environment variables are setup by
13+
# the aliBuild script itself
14+
#
15+
# - ARCHITECTURE
16+
# - BUILD_REQUIRES
17+
# - CACHED_TARBALL
18+
# - CAN_DELETE
19+
# - COMMIT_HASH
20+
# - DEPS_HASH
21+
# - DEVEL_HASH
22+
# - DEVEL_PREFIX
23+
# - GIT_TAG
24+
# - INCREMENTAL_BUILD_HASH
25+
# - JOBS
26+
# - PKGHASH
27+
# - PKGNAME
28+
# - PKGREVISION
29+
# - PKGVERSION
30+
# - REQUIRES
31+
# - RUNTIME_REQUIRES
32+
# - WRITE_REPO
2333

2434
export PKG_NAME="$PKGNAME"
2535
export PKG_VERSION="$PKGVERSION"
2636
export PKG_BUILDNUM="$PKGREVISION"
2737

28-
export ARCHITECTURE="%(architecture)s"
2938
export SOURCE0="${SOURCE0_DIR_OVERRIDE:-%(sourceDir)s}%(sourceName)s"
30-
export GIT_TAG="%(tag)s"
31-
export JOBS=${JOBS-%(jobs)s}
3239
export PKGPATH=${ARCHITECTURE}/${PKGNAME}/${PKGVERSION}-${PKGREVISION}
33-
%(incremental_hash)s
34-
INCREMENTAL_BUILD_HASH=${INCREMENTAL_BUILD_HASH:-0}
3540
mkdir -p "$WORK_DIR/BUILD" "$WORK_DIR/SOURCES" "$WORK_DIR/TARS" \
3641
"$WORK_DIR/SPECS" "$WORK_DIR/INSTALLROOT"
3742
export BUILDROOT="$WORK_DIR/BUILD/$PKGHASH"
@@ -44,15 +49,15 @@ if [ "${SOURCE0:0:1}" == "/" ]; then
4449
else
4550
export INSTALLROOT="$WORK_DIR/INSTALLROOT/$PKGHASH/$PKGPATH"
4651
fi
47-
export SOURCEDIR="$WORK_DIR/SOURCES/$PKGNAME/$PKGVERSION/%(commit_hash)s"
52+
export SOURCEDIR="$WORK_DIR/SOURCES/$PKGNAME/$PKGVERSION/$COMMIT_HASH"
4853
export BUILDDIR="$BUILDROOT/$PKGNAME"
4954

5055
SHORT_TAG=${GIT_TAG:0:10}
5156
mkdir -p $(dirname $SOURCEDIR)
52-
if [[ %(commit_hash)s != ${GIT_TAG} && "${SHORT_TAG:-0}" != %(commit_hash)s ]]; then
57+
if [[ ${COMMIT_HASH} != ${GIT_TAG} && "${SHORT_TAG:-0}" != ${COMMIT_HASH} ]]; then
5358
GIT_TAG_DIR=${GIT_TAG:-0}
5459
GIT_TAG_DIR=${GIT_TAG_DIR//\//_}
55-
ln -snf %(commit_hash)s "$WORK_DIR/SOURCES/$PKGNAME/$PKGVERSION/${GIT_TAG_DIR}"
60+
ln -snf ${COMMIT_HASH} "$WORK_DIR/SOURCES/$PKGNAME/$PKGVERSION/${GIT_TAG_DIR}"
5661
fi
5762
rm -fr "$WORK_DIR/INSTALLROOT/$PKGHASH"
5863
# We remove the build directory only if we are not in incremental mode.
@@ -75,7 +80,7 @@ if [[ ! "$SOURCE0" == '' && "${SOURCE0:0:1}" != "/" && ! -d "$SOURCEDIR" ]]; the
7580
git clone ${GIT_REFERENCE:+--reference $GIT_REFERENCE} "$SOURCE0" "$SOURCEDIR"
7681
cd $SOURCEDIR
7782
git checkout "${GIT_TAG}"
78-
git remote set-url --push origin %(write_repo)s
83+
git remote set-url --push origin $WRITE_REPO
7984
elif [[ ! "$SOURCE0" == '' && "${SOURCE0:0:1}" == "/" ]]; then
8085
ln -snf $SOURCE0 $SOURCEDIR
8186
fi
@@ -84,7 +89,6 @@ mkdir -p "$SOURCEDIR"
8489
cd "$BUILDDIR"
8590

8691
# Actual build script, as defined in the recipe
87-
CACHED_TARBALL=%(cachedTarball)s
8892

8993
# This actually does the build, taking in to account shortcuts like
9094
# having a pre build tarball or having an incremental recipe (in the
@@ -112,7 +116,7 @@ else
112116
# files.
113117
rm -rf "$BUILDROOT/log"
114118
mkdir -p $WORK_DIR/TMP/$PKGHASH
115-
%(gzip)s -dc $CACHED_TARBALL | tar -C $WORK_DIR/TMP/$PKGHASH -x
119+
$MY_GZIP -dc $CACHED_TARBALL | tar -C $WORK_DIR/TMP/$PKGHASH -x
116120
mkdir -p $(dirname $INSTALLROOT)
117121
rm -rf $INSTALLROOT
118122
mv $WORK_DIR/TMP/$PKGHASH/$ARCHITECTURE/$PKGNAME/$PKGVERSION-* $INSTALLROOT
@@ -137,7 +141,7 @@ export ${BIGPKGNAME}_ROOT=$INSTALLROOT
137141
export ${BIGPKGNAME}_VERSION=$PKGVERSION
138142
export ${BIGPKGNAME}_REVISION=$PKGREVISION
139143
export ${BIGPKGNAME}_HASH=$PKGHASH
140-
export ${BIGPKGNAME}_COMMIT=%(commit_hash)s
144+
export ${BIGPKGNAME}_COMMIT=${COMMIT_HASH}
141145
EOF
142146

143147
# Environment
@@ -188,9 +192,12 @@ cd "$WORK_DIR"
188192
tar xzf "$WORK_DIR/TARS/$HASH_PATH/$PACKAGE_WITH_REV"
189193
[ "X$CAN_DELETE" = X1 ] && rm "$WORK_DIR/TARS/$HASH_PATH/$PACKAGE_WITH_REV"
190194
bash -ex "$ARCHITECTURE/$PKGNAME/$PKGVERSION-$PKGREVISION/relocate-me.sh"
195+
# Last package built gets a "latest" mark.
191196
ln -snf $PKGVERSION-$PKGREVISION $ARCHITECTURE/$PKGNAME/latest
192-
if [[ $DEVEL_PREFIX ]]; then
193-
ln -snf $PKGVERSION-$PKGREVISION $ARCHITECTURE/$PKGNAME/latest-$DEVEL_PREFIX
197+
198+
# Latest package built for a given devel prefix gets latest-$BUILD_FAMILY
199+
if [[ $BUILD_FAMILY ]]; then
200+
ln -snf $PKGVERSION-$PKGREVISION $ARCHITECTURE/$PKGNAME/latest-$BUILD_FAMILY
194201
fi
195202

196203
# Mark the build as successful with a placeholder. Allows running incremental

alibuild_helpers/log.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, host, port):
2323
self.client.send({'host': self.currentHost, 'state': 'ok', 'service': "alibuild started"})
2424
self.enabled = True
2525
info("Sending log data to %s:%s" % (host, port))
26-
except Exception, e:
26+
except Exception as e:
2727
info("RIEMANN_HOST %s:%s specified, however there was a problem initialising:" % (host, port))
2828
info(e)
2929

0 commit comments

Comments
 (0)