further steps towards Perl bindings, still incomplete
authorKlaus Kaempf <kkaempf@suse.de>
Fri, 4 Jan 2008 12:25:53 +0000 (12:25 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Fri, 4 Jan 2008 12:25:53 +0000 (12:25 +0000)
- merge stuff from Kiwi
- work around bugs in CMake FindPerlLibs

examples/perl/example.pl [new file with mode: 0644]
examples/perl/tmp/primary.gz [new file with mode: 0644]
examples/perl/tmp/repo2solv.pl [new file with mode: 0755]
examples/perl/tmp/repo2solv.sh [new file with mode: 0755]

diff --git a/examples/perl/example.pl b/examples/perl/example.pl
new file mode 100644 (file)
index 0000000..7b4fe82
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+use lib './blib/arch/auto/SaT';
+
+use SaT;
+
+# Open Solvable file
+open(F, "gzip -cd tmp/primary.gz |") || die;
+
+# Create Pool and Repository 
+my $pool = new SaT::_Pool;
+my $repo = $pool -> createRepo('repo');
+
+# Add Solvable to Repository
+$repo -> addSolvable (F);
+close(F) || die;
+
+# Create Solver
+my $solver = new SaT::Solver ($pool);
+
+# Create dependencies to provides table
+$pool -> createWhatProvides();
+
+# Create Queue
+my $job = new SaT::Queue;
+
+# Push jobs on Queue
+$job -> queuePush ( $SaT::SOLVER_INSTALL_SOLVABLE );
+if (! $job -> queuePush ( $pool -> selectSolvable ($repo,"pattern:default"))) {
+       die "failed to push job";
+}
+
+# Solve the jobs
+$solver -> solve ($job);
+
+# Print packages to install
+$a = $solver -> getInstallList($pool);
+foreach my $c (@{$a}) {
+       print "$c\n";
+}
+
diff --git a/examples/perl/tmp/primary.gz b/examples/perl/tmp/primary.gz
new file mode 100644 (file)
index 0000000..64bdb59
Binary files /dev/null and b/examples/perl/tmp/primary.gz differ
diff --git a/examples/perl/tmp/repo2solv.pl b/examples/perl/tmp/repo2solv.pl
new file mode 100755 (executable)
index 0000000..1497ce0
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use lib '/usr/share/kiwi/modules';
+
+use strict;
+use KIWIXML;
+
+our $BasePath = "/usr/share/kiwi";
+our $Scheme   = $BasePath."/modules/KIWIScheme.rng";
+
+my $kiwi = new KIWILog ("tiny");
+my $xml  = new KIWIXML ($kiwi,"/usr/share/kiwi/image/isoboot/suse-10.3");
+
+#my @list = ("http://download.opensuse.org/distribution/10.3/repo/oss");
+my @list = ("/image/CDs/full-10.3-i386");
+my $data = $xml -> getInstSourceSatSolvable (\@list);
+
+if (defined $data) {
+       print "$data\n";
+}
diff --git a/examples/perl/tmp/repo2solv.sh b/examples/perl/tmp/repo2solv.sh
new file mode 100755 (executable)
index 0000000..4b2c5ee
--- /dev/null
@@ -0,0 +1,46 @@
+#! /bin/sh
+# repo2solv
+#
+# give it a directory of a local mirror of a repo and this
+# tries to detect the repo type and generate one SOLV file on stdout
+# set -x
+
+LANG=C
+
+dir="$1"
+
+cd "$dir" || exit 1
+
+
+if test -d suse/setup/descr; then
+  olddir=`pwd`
+  cd suse/setup/descr || exit 2
+  filepack=`mktemp` || exit 3
+
+  (
+    # First packages
+    if test -s packages.gz; then
+      gzip -dc packages.gz
+    elif test -s packages.bz2; then
+      bzip2 -dc packages.bz2
+    elif test -s packages; then
+      cat packages
+    fi
+
+    # patterns: but only those mentioned in the file 'patterns'
+    if test -f patterns; then
+      for i in `cat patterns`; do
+        test -s "$i" || continue
+        case $i in
+          *.gz) gzip -dc "$i" ;;
+         *.bz2) bzip2 -dc "$i" ;;
+         *) cat "$i" ;;
+       esac
+      done
+    fi
+  ) | susetags2solv > $filepack
+
+  cd "$olddir"
+  mergesolv $filecont $filepack
+  rm -f $filepack
+fi