Add suse support for the snaps build 01/68201/38
authorManuel Buil <mbuil@suse.com>
Tue, 13 Feb 2018 17:52:04 +0000 (18:52 +0100)
committerManuel Buil <mbuil@suse.com>
Mon, 5 Mar 2018 16:01:44 +0000 (17:01 +0100)
suse snaps rpm build and test happens inside a docker container
This patch requires the following patch to be merged:

https://git.opendaylight.org/gerrit/#/c/68114/

It reuses most of the building and testing scripts and it avoids
duplicating the packaging-build-rpm-snap job using the variable
{distro} to differentiate between suse and epel.

Change-Id: I31ee0558f3cc76e27f462f1d3ac528b5906a122c
Signed-off-by: Manuel Buil <mbuil@suse.com>
jjb/packaging/build-rpm-snap-docker.sh
jjb/packaging/build-rpm.sh
jjb/packaging/install-rpm.sh
jjb/packaging/packaging-macros.yaml
jjb/packaging/packaging.yaml
jjb/packaging/test-rpm-deps.sh
jjb/packaging/test-rpm-docker.sh
jjb/packaging/uninstall-rpm.sh

index 0da5178cacba3d3d0669b66394d31089e8caf3b4..e66851a54bf3f3cefac18b15f248224a2ec578db 100644 (file)
@@ -10,12 +10,19 @@ env | grep STREAM > env-file
 
 scripts_path=/builder/jjb/packaging
 
-docker_id=$(sudo docker run --env-file env-file --name build_rpm_epel -di --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos /usr/lib/systemd/systemd)
+if [ "$DISTRO" == "epel-7" ]; then
+  docker_id=$(sudo docker run --env-file env-file --name build_rpm_epel -di --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos /usr/lib/systemd/systemd)
+  sudo docker exec $docker_id /usr/bin/yum -y install sudo rpmdevtools rpmbuild git python-virtualenv python
+elif [ "$DISTRO" == "opensuse-42" ]; then
+  docker_id=$(sudo docker run --env-file env-file --name build_rpm_suse -di --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro opensuse /usr/lib/systemd/systemd)
+  sudo docker exec $docker_id /usr/bin/zypper -n install sudo rpmdevtools rpmbuild git python-virtualenv python
+fi
 
 sudo docker cp "$(pwd)"/packaging/ $docker_id:/packaging
 
-sudo docker exec $docker_id /usr/bin/yum -y install sudo rpmdevtools rpmbuild git python-virtualenv python
-
 sudo docker exec $docker_id git clone https://git.opendaylight.org/gerrit/releng/builder
 
+sudo docker exec $docker_id git -C /builder fetch https://git.opendaylight.org/gerrit/releng/builder refs/changes/01/68201/38
+sudo docker exec $docker_id git -C /builder checkout FETCH_HEAD
+
 sudo docker exec $docker_id /bin/bash $scripts_path/build-rpm-snap.sh
index 7613e521916e3843a471217ba52e5a48c59be033..e5066a498036564a9aac8333529ed9d1f4b3e3b5 100644 (file)
@@ -43,8 +43,8 @@ elif  [ "$SILO" == "releng" ]; then
   # Move RPMs (SRPM and noarch) to dir of files that will be uploaded to Nexus
   UPLOAD_FILES_PATH="$WORKSPACE/upload_files"
   mkdir -p "$UPLOAD_FILES_PATH"
-  cp "/home/$USER/rpmbuild/RPMS/noarch/"*.rpm "$_"
-  cp "/home/$USER/rpmbuild/SRPMS/"*.rpm "$_"
+  cp "$HOME/rpmbuild/RPMS/noarch/"*.rpm "$_"
+  cp "$HOME/rpmbuild/SRPMS/"*.rpm "$_"
 else
   echo "Unknown Jenkins silo: $SILO"
   exit 1
index 2e08872e0a9600429a8d8531d6e8207a40d4ddab..6112a2a78d7d27b5bad180cc3431e38e71db6bc6 100644 (file)
@@ -6,26 +6,49 @@
 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
 set -ex -o pipefail
 
-# Update mirror list to avoid slow/hung one
-sudo yum update -y yum-plugin-fastestmirror
-
 # Use local RPM in build-out dir if URL not passed
 URL=${URL:-"$HOME/rpmbuild/RPMS/noarch/*.rpm"}
 
-# Install ODL from RPM path, RPM URL or .repo file url
-# NB: Paths must be anchored at root
-if [[ $URL == /*  ]]; then
-  # If path is globbed (/path/to/*.rpm), expand it
-  path=$(sudo find / -wholename $URL)
-  sudo yum install -y "$path"
-elif [[ $URL == *.rpm ]]; then
-  sudo yum install -y "$URL"
-elif [[ $URL == *.repo ]]; then
-  # shellcheck disable=SC2154
-  repo_file="${URL##*/}"
-  sudo curl --silent -o /etc/yum.repos.d/"$repo_file" "$URL"
-  sudo yum install -y opendaylight
+if [ -f /usr/bin/yum ]; then
+  # Update mirror list to avoid slow/hung one
+  sudo yum update -y yum-plugin-fastestmirror
+
+  # Install ODL from RPM path, RPM URL or .repo file url
+  # NB: Paths must be anchored at root
+  if [[ $URL == /*  ]]; then
+    # If path is globbed (/path/to/*.rpm), expand it
+    path=$(sudo find / -wholename $URL)
+    sudo yum install -y "$path"
+  elif [[ $URL == *.rpm ]]; then
+    sudo yum install -y "$URL"
+  elif [[ $URL == *.repo ]]; then
+    # shellcheck disable=SC2154
+    repo_file="${URL##*/}"
+    sudo curl --silent -o /etc/yum.repos.d/"$repo_file" "$URL"
+    sudo yum install -y opendaylight
+  else
+    echo "URL is not a link to .rpm or .repo"
+    exit 1
+  fi
+elif [ -f /usr/bin/zypper ]; then
+  # Install ODL from RPM path, RPM URL or .repo file url
+  # NB: Paths must be anchored at root
+  if [[ $URL == /*  ]]; then
+    # If path is globbed (/path/to/*.rpm), expand it
+    path=$(sudo find /root -wholename $URL)
+    sudo zypper -n --no-gpg-checks install "$path"
+  elif [[ $URL == *.rpm ]]; then
+    sudo zypper -n --no-gpg-checks install "$URL"
+  elif [[ $URL == *.repo ]]; then
+    # shellcheck disable=SC2154
+    repo_file="${URL##*/}"
+    sudo curl --silent -o /etc/zypp/repos.d/"$repo_file" "$URL"
+    sudo zypper -n --no-gpg-checks install opendaylight
+  else
+    echo "URL is not a link to .rpm or .repo"
+    exit 1
+  fi
 else
-  echo "URL is not a link to .rpm or .repo"
+  echo "The package manager is not supported (not yum or zypper)"
   exit 1
 fi
index 754219b9b6811f5ab2b8cb64740168c961029062..5abfaf2ad2864a6acbe6386b5494d5307276df5d 100644 (file)
@@ -21,4 +21,4 @@
       - shell: !include-raw: uninstall-rpm.sh
       - shell: |
           # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+          rm /home/jenkins/.ssh/known_hosts || echo "No known_hosts file"
index c2614cfab3d9db66ed788800655c4a0bd8d04031..d533b3f094a9ea1e309a75bd5f33fc96a6e627b6 100644 (file)
@@ -5,7 +5,7 @@
 
     jobs:
       - 'packaging-build-rpm-{stream}'
-      - 'packaging-build-rpm-snap-{stream}'
+      - 'packaging-build-rpm-{distro}-snap-{stream}'
       - 'packaging-build-deb-{stream}'
       - 'packaging-verify-full-rpm-master'
       - 'packaging-verify-rpm-master'
@@ -23,6 +23,9 @@
       - carbon
       - nitrogen
       - oxygen
+    distro:
+      - opensuse-42
+      - epel-7
     branch: 'master'
 
     # common parameters required for 'lf-infra-deploy-maven-file' builder
 
 
 - job-template:
-    name: 'packaging-build-rpm-snap-{stream}'
+    name: 'packaging-build-rpm-{distro}-snap-{stream}'
 
     node: centos7-docker-2c-8g
 
 
     builders:
       - inject:
-          properties-content: 'STREAM={stream}'
+          properties-content: |
+              STREAM={stream}
+              DISTRO={distro}
       - shell: !include-raw: build-rpm-snap-docker.sh
       - shell: !include-raw: test-rpm-docker.sh
       - lf-infra-deploy-maven-file:
           global-settings-file: 'global-settings'
           settings-file: 'packaging-settings'
           mvn-version: '{mvn-version}'
-          repo-id: 'opendaylight-{stream}-epel-7-x86_64-devel'
+          repo-id: 'opendaylight-{stream}-{distro}-x86_64-devel'
           group-id: '{group-id}'
           upload-files-dir: '{upload-files-dir}'
           maven-repo-url: '{maven-repo-url}'
index 028fc02b1c4428e42a127e21beea56c71b0fd4c3..982fb5c27c564d8c12e0a0254cc406ccef895286 100644 (file)
@@ -24,18 +24,31 @@ if [ -z $path ]; then
     exit 1
 fi
 
-# Requirements for package where SRPM was built into noarch on CentOS CBS
-# rpm -qp opendaylight-8.0.0-0.1.20171125rel2049.el7.noarch.rpm --requires
-# shellcheck disable=SC2034
-declare -a expected_deps=( "/bin/bash"
-                           "/bin/sh"
-                           "java >= 1:1.8.0"
-                           "rpmlib(CompressedFileNames) <= 3.0.4-1"
-                           "rpmlib(FileDigests) <= 4.6.0-1"
-                           "rpmlib(PartialHardlinkSets) <= 4.0.4-1"
-                           "rpmlib(PayloadFilesHavePrefix) <= 4.0-1"
-                           "shadow-utils"
-                           "rpmlib(PayloadIsXz) <= 5.2-1" )
+
+if [ -f /usr/bin/yum ]; then
+  # Requirements for package where SRPM was built into noarch on CentOS CBS
+  # rpm -qp opendaylight-8.0.0-0.1.20171125rel2049.el7.noarch.rpm --requires
+  # shellcheck disable=SC2034
+  declare -a expected_deps=( "/bin/bash"
+                             "/bin/sh"
+                             "java >= 1:1.8.0"
+                             "rpmlib(CompressedFileNames) <= 3.0.4-1"
+                             "rpmlib(FileDigests) <= 4.6.0-1"
+                             "rpmlib(PartialHardlinkSets) <= 4.0.4-1"
+                             "rpmlib(PayloadFilesHavePrefix) <= 4.0-1"
+                             "shadow-utils"
+                             "rpmlib(PayloadIsXz) <= 5.2-1" )
+
+elif [ -f /usr/bin/zypper ]; then
+  declare -a expected_deps=( "/bin/bash"
+                             "/bin/sh"
+                             "java >= 1.8.0"
+                             "rpmlib(CompressedFileNames) <= 3.0.4-1"
+                             "rpmlib(PayloadFilesHavePrefix) <= 4.0-1"
+                             "shadow"
+                             "rpmlib(PayloadIsLzma) <= 4.4.6-1" )
+
+fi
 
 # Karaf 4 distros also have a /usr/bin/env requirement INTPAK-120
 if [[ ! $path == *opendaylight-6*  ]]; then
@@ -49,6 +62,7 @@ printf 'Dependency found: %s\n' "${actual_deps[@]}"
 
 # shellcheck disable=SC2154,SC2145,SC2034,SC2207
 diff_deps=(`echo "${expected_deps[@]}" "${actual_deps[@]}" | tr ' ' '\n' | sort | uniq -u`)
+
 # shellcheck disable=SC2154 disable=SC2145 disable=SC2068 disable=SC2170 disable=SC1083
 if [ ${#diff_deps[*]} -eq 0 ]; then
     echo "RPM requirements are as expected"
index 5f4fa30fc51222865e1a40f6f971baf560d3862b..a5c15f471093738c9f2563207354ff24b41b3599 100644 (file)
@@ -9,9 +9,13 @@ set -ex -o pipefail
 scripts_path=/builder/jjb/packaging
 
 # A docker container must have been created by the build script
-docker_id=$(sudo docker ps -qf name=build_rpm_epel)
-
-sudo docker exec $docker_id /usr/bin/yum -y install curl expect nmap openssh
+if [ "$DISTRO" == "epel-7" ]; then
+  docker_id=$(sudo docker ps -qf name=build_rpm_epel)
+  sudo docker exec $docker_id /usr/bin/yum -y install curl expect nmap openssh
+elif [ "$DISTRO" == "opensuse-42" ]; then
+  docker_id=$(sudo docker ps -qf name=build_rpm_suse)
+  sudo docker exec $docker_id /usr/bin/zypper -n install curl expect nmap openssh
+fi
 
 sudo docker exec $docker_id /bin/bash $scripts_path/test-rpm-deps.sh
 
index 1d62ede1b41f44d732f99c064259b13e03ad359b..0b339a86f2224707bece5ef501198f3ee1e61590 100644 (file)
@@ -6,14 +6,31 @@
 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
 set -ex -o pipefail
 
-# Uninstall ODL
-sudo yum remove -y opendaylight
+if [ -f /usr/bin/yum ]; then
+  # Uninstall ODL
+  sudo yum remove -y opendaylight
 
-# Verify ODL not installed
-if yum list installed opendaylight; then
-  # Fail if exit code 0, ie ODL is still installed
-  echo "OpenDaylight unexpectedly still installed"
-  exit 1
+  # Verify ODL not installed
+  if yum list installed opendaylight; then
+    # Fail if exit code 0, ie ODL is still installed
+    echo "OpenDaylight unexpectedly still installed"
+    exit 1
+  else
+    echo "OpenDaylight not installed, as expected"
+  fi
+elif [ -f /usr/bin/zypper ]; then
+  # Uninstall ODL
+  sudo zypper -n remove opendaylight
+
+  # Verify ODL not installed
+  if zypper search --installed-only opendaylight; then
+    # Fail if exit code 0, ie ODL is still installed
+    echo "OpenDaylight unexpectedly still installed"
+    exit 1
+  else
+    echo "OpenDaylight not installed, as expected"
+  fi
 else
-  echo "OpenDaylight not installed, as expected"
+  echo "The package manager is not supported (not yum or zypper)"
+  exit 1
 fi