Fix for 1278834
[awesomized/libmemcached] / bootstrap.sh
index d45c919464205c1fab567142541d50ffd71b863a..0383c8fa7ec1f3746a6bb8755d68433ada7b0a26 100755 (executable)
@@ -1010,14 +1010,16 @@ make_rpm ()
 {
   if command_exists 'rpmbuild'; then
     if [ -f 'rpm.am' -o -d 'rpm' ]; then
-      mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
-      mkdir -p ~/rpmbuild/RPMS/{i386,i486,i586,i686,noarch,athlon}
-
       run_configure_if_required
-      make_target 'rpm'
+      make_target 'dist-rpm'
 
       if $jenkins_build_environment; then
-        make_target 'clean'
+        mkdir artifacts
+        mv *.tar.gz *.rpm artifacts
+
+        make_target 'maintainer-clean'
+        mv artifacts/* .
+        rmdir artifacts
       fi
 
     fi
@@ -1098,7 +1100,11 @@ run_autoreconf ()
 
   if $use_libtool; then
     assert $BOOTSTRAP_LIBTOOLIZE
-    run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
+    if $jenkins_build_environment; then
+      run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
+    else
+      run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
+    fi
   fi
 
   run "$AUTORECONF" "$AUTORECONF_ARGS" || die "Cannot execute $AUTORECONF"
@@ -1239,7 +1245,11 @@ autoreconf_setup ()
   fi
 
   if [[ -z "$GNU_BUILD_FLAGS" ]]; then
-    GNU_BUILD_FLAGS="--install --force"
+    if $jenkins_build_environment; then
+      GNU_BUILD_FLAGS="--install"
+    else
+      GNU_BUILD_FLAGS="--install --force"
+    fi
   fi
 
   if $verbose; then
@@ -1557,7 +1567,8 @@ execute_job ()
       check_make_target $target
       ret=$?
       if [ $ret -ne 0 ]; then
-        die "Unknown BOOTSTRAP_TARGET option: $target"
+        warn "Unknown BOOTSTRAP_TARGET option: $target"
+        target="jenkins"
       fi
     fi
 
@@ -1732,24 +1743,6 @@ main ()
     BOOTSTRAP_TARGET="$OPT_TARGET"
   fi
 
-  # If we are running under Jenkins we predetermine what tests we will run against
-  # This BOOTSTRAP_TARGET can be overridden by parse_command_line_options based BOOTSTRAP_TARGET changes.
-  # We don't want Jenkins overriding other variables, so we NULL them.
-  if [ -z "$BOOTSTRAP_TARGET" ]; then
-    if $jenkins_build_environment; then
-      if [[ -n "$JENKINS_TARGET" ]]; then
-        check_make_target $JENKINS_TARGET
-        if [ $? -eq 0 ]; then
-          BOOTSTRAP_TARGET="$JENKINS_TARGET"
-        else
-          die "label not found: $label"
-        fi
-      else
-          BOOTSTRAP_TARGET='jenkins'
-      fi
-    fi
-  fi
-
   if [ -z "$BOOTSTRAP_TARGET" ]; then
     BOOTSTRAP_TARGET="make_default"
   fi