Check the real RPMs/SRPMs dir in chroot, instead of hardcode
authoryuanhao <yuanhao.zhou@intel.com>
Tue, 17 Sep 2013 06:31:20 +0000 (02:31 -0400)
committeryuanhao <yuanhao.zhou@intel.com>
Thu, 26 Sep 2013 10:49:08 +0000 (06:49 -0400)
For root user, the output dir of RPMs in chroot is /usr/src/packages/RPMS, not
/home/abuild/rpmbuild.
Get the output dir of RPMs/SRPMs using the following command
RPMs:  sudo chroot $BUILD_ROOT rpm --eval "%{_rpmdir}"
SRPMs: sudo chroot $BUILD_ROOT rpm --eval "%{_srcrpmdir}"

Fixes: #1326

Change-Id: I8fd79e2b67d9bb2e04274d8d563ed49038e820fa

data/gbs
depanneur

index 121bdbe..42be93c 100644 (file)
--- a/data/gbs
+++ b/data/gbs
@@ -6,6 +6,8 @@ ALL     ALL=(ALL) NOPASSWD: /usr/bin/build
 ALL     ALL=(ALL) NOPASSWD: /bin/cp *.conf */scratch.*/*.conf
 ALL     ALL=(ALL) NOPASSWD: /bin/rm -f */.build.log
 ALL     ALL=(ALL) NOPASSWD: /bin/echo -n
+ALL     ALL=(ALL) NOPASSWD: /usr/sbin/chroot */scratch.*
+ALL     ALL=(ALL) NOPASSWD: /usr/bin/chroot */scratch.*
 
 Defaults env_keep += "http_proxy"
 Defaults env_keep += "no_proxy"
index eb6ecd2..d329273 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -1381,11 +1381,16 @@ sub build_package {
     my_system("sudo /bin/cp $dist_configs/$dist.conf $scratch/$dist.conf") if ($noinit == 0);
 
     if ($ret == 0) {
-        if (bsd_glob "$scratch/home/abuild/rpmbuild/SRPMS/*.rpm") {
-            my_system ("cp $scratch/home/abuild/rpmbuild/SRPMS/*.rpm $srpm_repo_path");
+        # Set the real path of RPMS and SRPMS
+        my $rpmdirpath = `sudo chroot $scratch su -c "rpm --eval %{_rpmdir} 2>/dev/null" - abuild`;
+        my $srcrpmdirpath = `sudo chroot $scratch su -c "rpm --eval %{_srcrpmdir} 2>/dev/null" - abuild`;
+        chomp($rpmdirpath);
+        chomp($srcrpmdirpath);
+        if (bsd_glob "$scratch/$srcrpmdirpath/*.rpm") {
+            my_system ("cp $scratch/$srcrpmdirpath/*.rpm $srpm_repo_path");
         }
-        if (bsd_glob "$scratch/home/abuild/rpmbuild/RPMS/*/*.rpm") {
-            my_system ("cp $scratch/home/abuild/rpmbuild/RPMS/*/*.rpm $rpm_repo_path");
+        if (bsd_glob "$scratch/$rpmdirpath/*/*.rpm") {
+            my_system ("cp $scratch/$rpmdirpath/*/*.rpm $rpm_repo_path");
         }
         mkdir_p "$success_logs_path/$name-$version-$release";
         if (-e "$scratch/.build.log") {