David Caro has uploaded a new change for review. Change subject: New standard build scripts ......................................................................
New standard build scripts First jobs using the new standard build script, still a POC. * build_artifacts: script to generate the artifacts (rpms in this case), it creates a directory 'exported-artifacts' in the same directory where it's run with the artifacts that should be archived. * build_artifacts.req[.$dist] plain text files with the package names of the requirements needed to build the artifacts, if the one with the suffix $dist exists it will be used (if matches), if not, it will use the .req one. Change-Id: Ib77e348877058e718d797e1f17084eebb1304cf8 Signed-off-by: David Caro <dcaro...@redhat.com> --- A jobs/confs/shell-scripts/standard_build_artifacts.sh A jobs/confs/yaml/builders/build_artifacts.yaml A jobs/confs/yaml/jobs/repoman/repoman_build-artifacts.yaml A jobs/confs/yaml/scms/repoman.yaml A jobs/confs/yaml/templates/standard-build-artifacts.yaml 5 files changed, 221 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/jenkins refs/changes/72/36972/1 diff --git a/jobs/confs/shell-scripts/standard_build_artifacts.sh b/jobs/confs/shell-scripts/standard_build_artifacts.sh new file mode 100644 index 0000000..4e2ba83 --- /dev/null +++ b/jobs/confs/shell-scripts/standard_build_artifacts.sh @@ -0,0 +1,151 @@ +#!/bin/bash -xe +echo "shell-scripts/standard_build_artifacts.sh" +# PARAMETERS +# +# project +# Name of the project it runs on, specifically the dir where the code +# has been cloned +# +# distro +# Distribution it should create the rpms for (usually el6, el7, fc19 or +# fc20) +# +# arch +# Architecture to build the packages for +# +# extra-packages +# List of packages to install +# +# extra-repos +# List of extra repositories to use when building, in a space separated list +# of name,url pairs +# +# extra-env +# Extra environment variables + +distro="{distro}" +arch="{arch}" +project="{project}" +extra_packages=({extra-packages}) +extra_repos=({extra-repos}) +extra_env=({extra-env}) +WORKSPACE=$PWD +script="build_artifacts" + + +### Generate the mock configuration +pushd "$WORKSPACE"/jenkins/mock_configs +case $distro in + fc*) distribution="fedora-${{distro#fc}}";; + el*) distribution="epel-${{distro#el}}";; + *) echo "Unknown distro $distro"; exit 1;; +esac +mock_conf="${{distribution}}-$arch-ovirt-snapshot" +mock_repos=() +for mock_repo in "${{extra_repos[@]}}"; do + mock_repos+=("--repo" "$mock_repo") +done +echo "#### Generating mock configuration" +./mock_genconfig \ + --name="$mock_conf" \ + --base="$distribution-$arch.cfg" \ + --option="basedir=$WORKSPACE/mock/" \ + --option="resultdir=$WORKSPACE/exported-artifacts" \ + "${{mock_repos[@]}}" \ +> "$mock_conf.cfg" +sudo touch /var/cache/mock/*/root_cache/cache.tar.gz &>/dev/null || : +cat "$mock_conf.cfg" +popd + +## prepare the command line +my_mock="/usr/bin/mock" +my_mock+=" --configdir=$WORKSPACE/jenkins/mock_configs" +my_mock+=" --root=$mock_conf" + +## init the chroot +$my_mock \ + --init + +### Configure extra yum vars +echo "Configuring custom env variables for repo urls" +$my_mock \ + --no-clean \ + --shell <<EOF + mkdir -p /etc/yum/vars + echo "$distro" > /etc/yum/vars/distro +EOF + +### Install any extra packages if needed +## from config +if [[ -n "$extra_packages" ]]; then + echo "##### Installing extra dependencies: $extra_packages" + $my_mock \ + --no-clean \ + --install "${{extra_packages[@]}}" +fi +## from project requirements file +build_deps_file="repoman/build_artifacts.req.${{distro}}" +[[ -f "$build_deps_file" ]] \ +|| build_deps_file="repoman/build_artifacts.req" +if [[ -f "$build_deps_file" ]]; then + echo "##### Installing extra dependencies from $build_deps_file" + packages=($(cat "$build_deps_file")) + $my_mock \ + --no-clean \ + --install "${{packages[@]}}" +fi + +## Needed when running shell on different arch than the host, because rpmdb is +## copied from it when creating the chroot and x86_64 rpmdb is not compatible on +## i686 +$my_mock \ + --no-clean \ + --shell <<EOF +rm -f /var/lib/rpm/__db* +rpm --rebuilddb +EOF + +### Mount the current workspace in the chroot +$my_mock \ + --no-clean \ + --shell <<EOFMAKINGTHISHARDTOMATCH +mkdir -p /tmp/run +EOFMAKINGTHISHARDTOMATCH + +# Adding the workspace mount to the config +pushd "$WORKSPACE"/jenkins/mock_configs +echo "#### Generating mock configuration with workspace mounted" +./mock_genconfig \ + --name="$mock_conf" \ + --base="$distribution-$arch.cfg" \ + --option="basedir=$WORKSPACE/mock/" \ + --option="resultdir=$WORKSPACE/exported-artifacts" \ + --option="plugin_conf.bind_mount_enable=True" \ + --option='plugin_conf.bind_mount_opts.dirs=[ + ["'"$WORKSPACE"'", "/tmp/run"] + ]' \ + "${{mock_repos[@]}}" \ +> "$mock_conf.cfg" +sudo touch /var/cache/mock/*/root_cache/cache.tar.gz &>/dev/null || : +cat "$mock_conf.cfg" +popd + +### Run the script +echo "##### Running $SCRIPT inside mock" +$my_mock \ + --no-clean \ + --shell <<EOFMAKINGTHISHARDTOMATCH +set -e +SCRIPT="/tmp/run/{project}/$script" +export HOME=/tmp/run +cd \$HOME/repoman +chmod +x \$SCRIPT +\$SCRIPT +echo -e "\n\n" +ls -la exported-artifacts +EOFMAKINGTHISHARDTOMATCH + +mkdir -p "$WORKSPACE"/exported-artifacts +sudo chown -R $USER:$USER "$WORKSPACE"/exported-artifacts +sudo mv "$WORKSPACE"/repoman/exported-artifacts/* \ + "$WORKSPACE"/exported-artifacts/ diff --git a/jobs/confs/yaml/builders/build_artifacts.yaml b/jobs/confs/yaml/builders/build_artifacts.yaml new file mode 100644 index 0000000..747ce3d --- /dev/null +++ b/jobs/confs/yaml/builders/build_artifacts.yaml @@ -0,0 +1,6 @@ +- builder: + name: build-artifacts + builders: + - shell: !include-raw shell-scripts/global_setup.sh + - shell: !include-raw shell-scripts/mock_setup.sh + - shell: !include-raw shell-scripts/standard_build_artifacts.sh diff --git a/jobs/confs/yaml/jobs/repoman/repoman_build-artifacts.yaml b/jobs/confs/yaml/jobs/repoman/repoman_build-artifacts.yaml new file mode 100644 index 0000000..8083a39 --- /dev/null +++ b/jobs/confs/yaml/jobs/repoman/repoman_build-artifacts.yaml @@ -0,0 +1,18 @@ +- project: + name: repoman_build-artifacts + project: + - repoman + trigger: + - merged + version: + - master: + branch: master + distro: + - el6 + - el7 + - fc20 + - fc21 + arch: + - x86_64 + jobs: + - '{project}_{version}_build-artifacts-{distro}-{arch}_{trigger}' diff --git a/jobs/confs/yaml/scms/repoman.yaml b/jobs/confs/yaml/scms/repoman.yaml new file mode 100644 index 0000000..f4525d5 --- /dev/null +++ b/jobs/confs/yaml/scms/repoman.yaml @@ -0,0 +1,16 @@ +- scm: + name: repoman-gerrit + scm: + - git: + url: git://gerrit.ovirt.org/repoman.git + branches: + - $GERRIT_BRANCH + basedir: repoman + scm-name: repoman + name: '' + refspec: $GERRIT_REFSPEC + choosing-strategy: gerrit + use-author: true + skip-tag: true + prune: true + wipe-workspace: false diff --git a/jobs/confs/yaml/templates/standard-build-artifacts.yaml b/jobs/confs/yaml/templates/standard-build-artifacts.yaml new file mode 100644 index 0000000..3a87b04 --- /dev/null +++ b/jobs/confs/yaml/templates/standard-build-artifacts.yaml @@ -0,0 +1,30 @@ +- job-template: + name: '{project}_{version}_build-artifacts-{distro}-{arch}_{trigger}' + node: '{node-filter}' + parameters: + - gerrit-params: + branch: '{branch}' + scm: + - '{project}-gerrit' + - jenkins: + branch: master + triggers: + - on-patch-{trigger}: + project: '{project}' + branch: '{branch}' + builders: + - build-artifacts: + project: '{project}' + distro: '{distro}' + arch: '{arch}' + extra-packages: '{extra-packages}' + extra-build-packages: '{extra-build-packages}' + extra-rpmbuild-options: '{extra-rpmbuild-options}' + extra-autogen-options: '{extra-autogen-options}' + extra-configure-options: '{extra-configure-options}' + extra-repos: '{extra-repos}' + extra-env: '{extra-env}' + cherry-pick: '{cherry-pick}' + publishers: + - mock-cleanup + - exported-artifacts -- To view, visit http://gerrit.ovirt.org/36972 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib77e348877058e718d797e1f17084eebb1304cf8 Gerrit-PatchSet: 1 Gerrit-Project: jenkins Gerrit-Branch: master Gerrit-Owner: David Caro <dcaro...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches