Fix dependencies after installing built package. refs #8345
[arvados-dev.git] / jenkins / run-library.sh
index 3c62d7bb3248a1d58033d29fa1f94a25765cc79e..0534b3d945b31ac07d390bca6bd84b6fc4180cfa 100755 (executable)
@@ -149,7 +149,8 @@ handle_rails_package() {
                        "$(cat "$version_file")")
     local license_arg="$license_path=$railsdir/$(basename "$license_path")"
     # --iteration=3 accommodates the package scripts change from #8014.
-    local -a switches=(--iteration=3
+    # --iteration=4 accommodates the packaging changes (inclusion of vendor/cache) from #8008.
+    local -a switches=(--iteration=4
                        --after-install "$scripts_dir/postinst"
                        --before-remove "$scripts_dir/prerm"
                        --after-remove "$scripts_dir/postrm")
@@ -157,8 +158,13 @@ handle_rails_package() {
     local exclude_root="${railsdir#/}"
     # .git and packages are for the SSO server, which is built from its
     # repository root.
-    for exclude in .git packages tmp log coverage \
-                        Capfile\* config/deploy\*; do
+    local -a exclude_list=(.git packages tmp log coverage Capfile\* \
+                           config/deploy\* config/application.yml)
+    # for arvados-workbench, we need to have the (dummy) config/database.yml in the package
+    if  [[ "$pkgname" != "arvados-workbench" ]]; then
+      exclude_list+=('config/database.yml')
+    fi
+    for exclude in ${exclude_list[@]}; do
         switches+=(-x "$exclude_root/$exclude")
     done
     fpm_build "${pos_args[@]}" "${switches[@]}" \
@@ -237,19 +243,50 @@ fpm_build () {
   # the package source dir. These are added last so they can override
   # the arguments added by this script.
   declare -a fpm_args=()
+  declare -a build_depends=()
   declare -a fpm_depends=()
+  declare -a fpm_exclude=()
+  FPM_INFO=""
   if [[ -d "$PACKAGE_DIR" ]]; then
       FPM_INFO="$PACKAGE_DIR/fpm-info.sh"
-  else
+  elif [[ -e "${WORKSPACE}/backports/${PACKAGE_TYPE}-${PACKAGE}/fpm-info.sh" ]]; then
       FPM_INFO="${WORKSPACE}/backports/${PACKAGE_TYPE}-${PACKAGE}/fpm-info.sh"
+      debug_echo "Found fpm-info.sh in backports: $FPM_INFO"
+  elif [[ -e "${WORKSPACE}/backports/${PACKAGE_TYPE}-${PACKAGE_NAME}/fpm-info.sh" ]]; then
+      FPM_INFO="${WORKSPACE}/backports/${PACKAGE_TYPE}-${PACKAGE_NAME}/fpm-info.sh"
   fi
   if [[ -e "$FPM_INFO" ]]; then
       debug_echo "Loading fpm overrides from $FPM_INFO"
       source "$FPM_INFO"
   fi
+  for pkg in "${build_depends[@]}"; do
+      if [[ $TARGET =~ debian|ubuntu ]]; then
+          pkg_deb=$(ls "$WORKSPACE/packages/$TARGET/$pkg_"*.deb | sort -rg | awk 'NR==1')
+          if [[ -e $pkg_deb ]]; then
+              echo "Installing build_dep $pkg from $pkg_deb"
+              dpkg -i "$pkg_deb"
+          else
+              echo "Attemping to install build_dep $pkg using apt-get"
+              apt-get install -y "$pkg"
+          fi
+          apt-get -y -f install
+      else
+          pkg_rpm=$(ls "$WORKSPACE/packages/$TARGET/$pkg"-[0-9]*.rpm | sort -rg | awk 'NR==1')
+          if [[ -e $pkg_rpm ]]; then
+              echo "Installing build_dep $pkg from $pkg_rpm"
+              rpm -i "$pkg_rpm"
+          else
+              echo "Attemping to install build_dep $pkg"
+              rpm -i "$pkg"
+          fi
+      fi
+  done
   for i in "${fpm_depends[@]}"; do
     COMMAND_ARR+=('--depends' "$i")
   done
+  for i in "${fpm_exclude[@]}"; do
+    COMMAND_ARR+=('--exclude' "$i")
+  done
 
   # Append remaining function arguments directly to fpm's command line.
   for i; do