diff --git a/config.json b/config.json index e3705f4..486b49d 100644 --- a/config.json +++ b/config.json @@ -1,3 +1,5 @@ { - "buildhistory" : "True" -} \ No newline at end of file + "build-history-targets" : ["arm64", "arm", "arm-lsb", "mips64", "mips", "mips-lsb", "ppc", "ppc-lsb", "x86-64", "x86-64-lsb", "x86", "x86-lsb"], + "BUILD_HISTORY_DIR" : "/srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory", + "BUILD_HISTORY_REPO" : "ssh://git@push.yoctoproject.org/poky-buildhistory" +} diff --git a/scripts/buildhistory-init b/scripts/buildhistory-init index 0aef036..cbc8a39 100755 --- a/scripts/buildhistory-init +++ b/scripts/buildhistory-init @@ -1,27 +1,39 @@ #!/bin/sh +# +# Called with $1 - The target name +# $2 - The buildhistory directory +# $3 - The remote repository url +# $4 - The remote branch name +# +TARGETNAME=$1 +BUILDHISTDIR=$2 +REMOTEREPO=$3 +REMOTEBRANCH=$4 + +echo BH $@ exit 0 # Example code dumped from an existing nightly-arm buildhistory step for reference -if [ ! -d /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm ]; then - mkdir -p /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm - git init /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm +if [ ! -d $BUILDHISTDIR ]; then + mkdir -p $BUILDHISTDIR + git init $BUILDHISTDIR fi -rm -rf /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm -mkdir -p /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm -git init /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm +rm -rf $BUILDHISTDIR +mkdir -p $BUILDHISTDIR +git init $BUILDHISTDIR -if git ls-remote --exit-code ssh://git@push.yoctoproject.org/poky-buildhistory refs/heads/poky/master-next/nightly-arm> /dev/null; then - git push -q ssh://git@push.yoctoproject.org/poky-buildhistory :poky/master-next/nightly-arm +if git ls-remote --exit-code $REMOTEREPO refs/heads/$REMOTEBRANCH> /dev/null; then + git push -q $REMOTEREPO :$REMOTEBRANCH fi -if ! git ls-remote --exit-code ssh://git@push.yoctoproject.org/poky-buildhistory refs/heads/poky/master-next/nightly-arm > /dev/null; then - cd /srv/www/vhosts/autobuilder.yoctoproject.org/buildhistory/poky/master-next/nightly-arm +if ! git ls-remote --exit-code $REMOTEREPO refs/heads/$REMOTEBRANCH > /dev/null; then + cd $BUILDHISTDIR echo 'Initializing Repo' >> README - git checkout -b poky/master-next/nightly-arm + git checkout -b $REMOTEBRANCH git add README git commit -s -m 'Initializing Repo' - git push -q ssh://git@push.yoctoproject.org/poky-buildhistory poky/master-next/nightly-arm:poky/master-next/nightly-arm + git push -q $REMOTEREPO $REMOTEBRANCH:$REMOTEBRANCH fi diff --git a/scripts/setup-config b/scripts/setup-config index e41c141..91feca5 100755 --- a/scripts/setup-config +++ b/scripts/setup-config @@ -3,13 +3,37 @@ import json import os import sys +import subprocess scriptsdir = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(scriptsdir, '..', 'config.json')) as f: ourconfig = json.load(f) -os.system(os.path.join(scriptsdir, "buildhistory-init")) +target = "nightly-arm" +branchname = "master" +distro = "poky" + +# Strip off "nightly-" +target = target[8:] + +# +# Check if config contains all the listed params +# +def contains(params, config): + for p in params: + if p not in config: + return False + return True + +if contains(["BUILD_HISTORY_DIR", "build-history-targets", "BUILD_HISTORY_REPO"], ourconfig): + if target in ourconfig["build-history-targets"]: + bh_path = os.path.join(ourconfig["BUILD_HISTORY_DIR"], distro, branchname, "nightly-" + target) + remoterepo = ourconfig["BUILD_HISTORY_REPO"] + remotebranch = distro + "/" + branchname + "/nightly-" + target + subprocess.check_output([os.path.join(scriptsdir, "buildhistory-init"), target, bh_path, remoterepo, remotebranch], stderr=subprocess.STDOUT) + +print(str(ourconfig)) print("setup-config called with %s" % " ".join(sys.argv))