Make it possible to specify Type: in prjconf and have non-rpm.rpm chroots
authorCarsten Munk <carsten.munk@gmail.com>
Fri, 24 Feb 2012 09:36:17 +0000 (10:36 +0100)
committerAdrian Schröter <adrian@suse.de>
Tue, 10 Apr 2012 12:08:07 +0000 (14:08 +0200)
Signed-off-by: Carsten Munk <carsten.munk@gmail.com>
Conflicts:

init_buildsystem

Makefile
gettype [new file with mode: 0755]
init_buildsystem

index ff34b8a..4fc8021 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,6 +38,7 @@ install:
            killchroot \
            getmacros \
            getoptflags \
+           gettype \
            getchangetarget \
            common_functions \
            init_buildsystem \
diff --git a/gettype b/gettype
new file mode 100755 (executable)
index 0000000..e07483a
--- /dev/null
+++ b/gettype
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+  unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
+}
+
+use strict;
+
+use Build;
+
+my ($dist, $archs, $configdir, $debug);
+
+while (@ARGV)  {
+  if ($ARGV[0] eq '--dist') {
+    shift @ARGV;
+    $dist = shift @ARGV;
+    next;
+  }
+  if ($ARGV[0] eq '--archpath') {
+    shift @ARGV;
+    $archs = shift @ARGV;
+    next;
+  }
+  if ($ARGV[0] eq '--configdir') {
+    shift @ARGV;
+    $configdir = shift @ARGV;
+    next;
+  }
+  last;
+}
+
+die("Usage: gettype --dist <dist> --archpath <archpath> [--configdir <configdir>]\n") if @ARGV;
+
+my $cf = Build::read_config_dist($dist, $archs, $configdir);
+exit 0 unless $cf->{'type'};
+print "$cf->{'type'}\n";
index 53bd5e8..f036448 100755 (executable)
@@ -723,13 +723,24 @@ else
 
     echo "$GUESSED_DIST" > $BUILD_ROOT/.guessed_dist
     test -n "$BUILD_DIST" || BUILD_DIST="$GUESSED_DIST"
-    PSUF=
-    test -L $BUILD_ROOT/.init_b_cache/rpms/rpm.rpm && PSUF=rpm
-    test -L $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb && PSUF=deb
-    test -L $BUILD_ROOT/.init_b_cache/rpms/pacman.arch && PSUF=arch
-    if test -z "$PSUF" ; then
-       echo "unknown package manager" >&2
-       cleanup_and_exit 1
+    DIST_TYPE=`gettype --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH"`
+    if [ -n $DIST_TYPE ]; then
+       case $DIST_TYPE in
+               spec)
+                       PSUF=rpm 
+                       ;;
+               dsc)
+                       PSUF=deb
+                       ;;
+               *)
+                       PSUF=rpm
+                       test -L $BUILD_TARGET/.init_b_cache/rpms/rpm.rpm || PSUF=deb
+               ;;
+       esac
+    else
+       PSUF=rpm
+       test -L $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb && PSUF=deb
+       test -L $BUILD_ROOT/.init_b_cache/rpms/pacman.arch && PSUF=arch
     fi
 fi