[Debpool-commits] [SCM] Debpool Project Repository branch, master, updated. debian/0.3.6-2-g924e0c2

Andres Mejia mcitadel at gmail.com
Thu Oct 16 20:56:12 UTC 2008


The following commit has been merged in the master branch:
commit 924e0c201dce929b8db732769c6a0f01124ee771
Author: Andres Mejia <mcitadel at gmail.com>
Date:   Thu Oct 16 16:56:07 2008 -0400

      * Use Compress::Zlib and Compress::Bzip2 to create bzip2 and gzip Packages and
        Sources files.
        + Adding Depends of libcompress-bzip2-perl.
        + (Closes: #502454)
      * Drop liblinux-inotify2-perl to Recommends. It is not necessary to use
        inotify and this would allow users of non-Linux ports of debian to use
        debpool.
      * Bumped libproc-daemon-perl up to depends.
        + Changed debpool to not check for existence of Proc::Daemon, since it will
          now be installed by default.
      * Write an entry about dependencies in the README.Debian file.

diff --git a/bin/debpool b/bin/debpool
index e815583..6da583a 100755
--- a/bin/debpool
+++ b/bin/debpool
@@ -56,15 +56,8 @@ use DebPool::Signal qw(:functions :vars); # Handle signals
 
 if ($Options{'daemon'}) {
     Log_Message("Trying to enter daemon mode.", LOG_GENERAL, LOG_INFO);
-
-    if (eval{ require Proc::Daemon; }) {
-        Proc::Daemon::Init();
-        Log_Message("Now running as a daemon.", LOG_GENERAL, LOG_INFO);
-    } else {
-        print "ERROR: Running as a daemon requires installation of libproc-daemon-perl.\n";
-        Log_Message("Running as a daemon requires installation of libproc-daemon-perl.", LOG_GENERAL, LOG_ERROR);
-        exit 1;
-    }
+    Proc::Daemon::Init();
+    Log_Message("Now running as a daemon.", LOG_GENERAL, LOG_INFO);
 }
 
 # Set up a directory for debpool in the user's HOME directory, even if we're
diff --git a/debian/README.Debian b/debian/README.Debian
index 3a817fc..9e37fdb 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -7,3 +7,19 @@ Important notes about using debpool:
 
 * For setting up signature verification or Release signing, please see the
   README.GnuPG file.
+
+Dependencies:
+
+* One of the goals of debpool is to keep the amount of dependencies down to a
+  minimum. The idea with this is so debpool would be able to run on different
+  ports of Debian (such as on freebsd). With this in mind, the dependencies for
+  debpool are essentially Perl, other Perl modules, and a C compiler.
+
+  With other Perl modules, careful consideration is taken to pick out a module
+  that isn't too complex. For example, libproc-daemon-perl depends solely on Perl,
+  which is why it is allowed as a dependency. libcompress-bzip2-perl depends on
+  Perl, libc, and libbz2. The dependencies of Perl and libc are ok. The
+  dependency of libbz2 had to be checked further. It turned out that libbz2
+  just needs libc to run and gcc to build (aside from texinfo for documentation)
+  therefore in this case, libcompress-bzip2-perl was allowed as a dependency for
+  debpool.
diff --git a/debian/TODO b/debian/TODO
index 4d1e4ef..798a05f 100644
--- a/debian/TODO
+++ b/debian/TODO
@@ -23,11 +23,6 @@ Features, fixes, and other stuff to be done.
 * Implement package migration between different sections.
   - For example, migration from unstable to testing.
 
-(compression)
-
-* Use Compress::Zlib and Compress::Bzip2 to create bzip2 and gzip Packages and
-  Sources files.
-
 (config file)
 
 * Perhaps change the name of config file to debpoolrc.
diff --git a/debian/changelog b/debian/changelog
index 6abe3a4..2ccbc6f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,19 @@
+debpool (0.3.8) experimental; urgency=low
+
+  * Use Compress::Zlib and Compress::Bzip2 to create bzip2 and gzip Packages and
+    Sources files.
+    + Adding Depends of libcompress-bzip2-perl.
+    + (Closes: #502454)
+  * Drop liblinux-inotify2-perl to Recommends. It is not necessary to use
+    inotify and this would allow users of non-Linux ports of debian to use
+    debpool.
+  * Bumped libproc-daemon-perl up to depends.
+    + Changed debpool to not check for existence of Proc::Daemon, since it will
+      now be installed by default.
+  * Write an entry about dependencies in the README.Debian file.
+
+ -- Andres Mejia <mcitadel at gmail.com>  Thu, 16 Oct 2008 16:55:37 -0400
+
 debpool (0.3.7) experimental; urgency=low
 
   * Removed unnecessary comments from debian/rules.
diff --git a/debian/control b/debian/control
index c4ed1e6..22e4f13 100644
--- a/debian/control
+++ b/debian/control
@@ -11,8 +11,8 @@ Homepage: http://wiki.debian.org/debpool
 
 Package: debpool
 Architecture: all
-Depends: ${perl:Depends}, liblinux-inotify2-perl
-Recommends: gnupg, libproc-daemon-perl
+Depends: ${perl:Depends}, libcompress-bzip2-perl, libproc-daemon-perl
+Recommends: gnupg, liblinux-inotify2-perl
 Description: Debian package archive maintenance utility
  DebPool is a package archive maintenance utility. It is designed with the goal
  of keeping the number of dependencies down to a minimum. It is intended to be
diff --git a/lib/DebPool/Bzip2.pm b/lib/DebPool/Bzip2.pm
index eab24dc..f14aa14 100644
--- a/lib/DebPool/Bzip2.pm
+++ b/lib/DebPool/Bzip2.pm
@@ -5,7 +5,7 @@ package DebPool::Bzip2;
 # DebPool::Bzip2 - Module for handling Bzip2 interactions
 #
 # Copyright 2003-2004 Joel Aelwyn. All rights reserved.
-# 
+#
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
@@ -45,11 +45,6 @@ use warnings;
 
 use POSIX; # WEXITSTATUS
 
-# Needed for open2()
-
-use Fcntl;
-use IPC::Open2;
-
 ### Module setup
 
 BEGIN {
@@ -100,59 +95,55 @@ our($Error);
 
 sub Bzip2_File {
     use DebPool::Logging qw(:functions :facility :level);
+    use Compress::Bzip2;
 
     my($file) = @_;
 
     # Open a secure tempfile to write the compressed data into
 
-    my($tmpfile) = new File::Temp( SUFFIX => '.bz2', UNLINK => 0 );
+    my($tmpfile) = new File::Temp( SUFFIX => '.bz2' );
+    my $bz = bzopen($tmpfile, 'wb9');
+    if (!$bz) {
+        $Error = "Couldn't initialize compression library: " . $bzerrno;
+        return undef;
+    }
 
     # Open the source file so that we have it available.
-
-    my $source_fh;
-    if (!open($source_fh, '<', $file)) {
+    if (!open(SOURCE, '<', $file)) {
         $Error = "Couldn't open source file '$file': $!";
-        return;
+        return undef;
     }
 
-    # We are go for main engine start
-
-    my(@args) = ('--best', '--force', '--stdout');
-
-    my($bzip2_pid) = open2(*BZIP2_IN, *BZIP2_OUT, '/bin/bzip2', @args);
-
-    my($child_pid);
-    if ($child_pid = fork) { # In the parent
-        # Send all the data to Bzip2;
-
-        close(BZIP2_IN);
-        close($tmpfile);
-
-        print BZIP2_OUT <$source_fh>;
-        close(BZIP2_OUT);
-        close($source_fh);
-
-        waitpid($child_pid, 0);
-        waitpid($bzip2_pid, 0);
-    } else { # In the child - we hope
-        if (!defined($child_pid)) {
-            die "Couldn't fork: $!\n";
+    while (1) {
+        my $buffer;
+        my $bytesread = read SOURCE, $buffer, 4096;
+        if (!defined $bytesread) {
+            $Error = "Error reading from '$file': $!";
+            close SOURCE;
+            return undef;
         }
+        last if $bytesread == 0;
+        my $byteswritten = $bz->bzwrite($buffer);
+        if ($byteswritten < $bytesread) {
+            $Error = "Error bzwriting to temporary file: " . $bz->bzerror;
+            close SOURCE;
+            return undef;
+        }
+    }
 
-        # Read back the results, and print them into the tempfile.
-
-        close(BZIP2_OUT);
-        close($source_fh);
-
-        print $tmpfile <BZIP2_IN>;
-        close(BZIP2_IN);
-        close($tmpfile);
+    my $bzflush = $bz->bzflush(BZ_FINISH);
 
-        exit(0);
+    # BZ_OK and BZ_STREAM_END are ok
+    if (($bzflush != BZ_OK) && ($bzflush != BZ_STREAM_END)) {
+        $Error = "Error flushing compressed file: " . $bz->bzerror;
+        close SOURCE;
+        return undef;
     }
 
     # And we're done
-
+    close SOURCE;
+    $bz->bzclose;
+    $tmpfile->unlink_on_destroy(0);
     return $tmpfile->filename;
 }
 
@@ -164,10 +155,9 @@ sub Compress_File {
     my $self = shift;
     my $tempname = Bzip2_File(@_);
     if ($tempname) {
-	$self->{'ERROR'} = undef;
-    }
-    else {
-	$self->{'ERROR'} = $Error;
+        $self->{'ERROR'} = undef;
+    } else {
+        $self->{'ERROR'} = $Error;
     }
     $tempname;
 }
diff --git a/lib/DebPool/Gzip.pm b/lib/DebPool/Gzip.pm
index 47026f8..f596d87 100644
--- a/lib/DebPool/Gzip.pm
+++ b/lib/DebPool/Gzip.pm
@@ -5,7 +5,7 @@ package DebPool::Gzip;
 # DebPool::Gzip - Module for handling Gzip interactions
 #
 # Copyright 2003-2004 Joel Aelwyn. All rights reserved.
-# 
+#
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
@@ -45,11 +45,6 @@ use warnings;
 
 use POSIX; # WEXITSTATUS
 
-# Needed for open2()
-
-use Fcntl;
-use IPC::Open2;
-
 ### Module setup
 
 BEGIN {
@@ -95,63 +90,61 @@ our($Error);
 
 # Gzip_File($file)
 #
-# Generates a gzipped version of $file using gzip, and returns the filename.
-# Returns undef (and sets $Error) on failure.
+# Generates a gzipped version of $file using Compress::Zlib, and returns the
+# filename. Returns undef (and sets $Error) on failure.
 
 sub Gzip_File {
     use DebPool::Logging qw(:functions :facility :level);
+    use Compress::Zlib;
 
     my($file) = @_;
 
     # Open a secure tempfile to write the compressed data into
 
-    my($tmpfile) = new File::Temp( SUFFIX => '.gz', UNLINK => 0 );
+    my($tmpfile) = new File::Temp( SUFFIX => '.gz' );
+    my $gz = gzopen($tmpfile, 'wb9');
+    if (!$gz) {
+        $Error = "Couldn't initialize compression library: $gzerrno";
+        return undef;
+    }
 
     # Open the source file so that we have it available.
-
-    my $source_fh;
-    if (!open($source_fh, '<', $file)) {
+    if (!open(SOURCE, '<', $file)) {
         $Error = "Couldn't open source file '$file': $!";
-        return;
+        return undef;
     }
 
-    # We are go for main engine start
-
-    my(@args) = ('--best', '--force', '--stdout');
-
-    my($gzip_pid) = open2(*GZIP_IN, *GZIP_OUT, '/bin/gzip', @args);
-
-    my($child_pid);
-    if ($child_pid = fork) { # In the parent
-        # Send all the data to Gzip;
-
-        close(GZIP_IN);
-        close($tmpfile);
-
-        print GZIP_OUT <$source_fh>;
-        close(GZIP_OUT);
-        close($source_fh);
-
-        waitpid($child_pid, 0);
-        waitpid($gzip_pid, 0);
-    } else { # In the child - we hope
-        if (!defined($child_pid)) {
-            die "Couldn't fork: $!\n";
+    while (1) {
+        my $buffer;
+        my $bytesread = read SOURCE, $buffer, 4096;
+        if (!defined $bytesread) {
+            $Error = "Error reading from '$file': $!";
+            close SOURCE;
+            return undef;
         }
+        last if $bytesread == 0;
+        my $byteswritten = $gz->gzwrite($buffer);
+        if ($byteswritten < $bytesread) {
+            $Error = "Error gzwriting to temporary file: " . $gz->gzerror;
+            close SOURCE;
+            return undef;
+        }
+    }
 
-        # Read back the results, and print them into the tempfile.
-
-        close(GZIP_OUT);
-        close($source_fh);
-
-        print $tmpfile <GZIP_IN>;
-        close(GZIP_IN);
-        close($tmpfile);
+    my $gzflush = $gz->gzflush(Z_FINISH);
 
-        exit(0);
+    # zlib documentation says that Z_OK and Z_STREAM_END are ok
+    if (($gzflush != Z_OK) && ($gzflush != Z_STREAM_END)) {
+        $Error = "Error flushing compressed file: " . $gz->gzerror;
+        print "$Error\n";
+        close SOURCE;
+        return undef;
     }
 
     # And we're done
+    close SOURCE;
+    $gz->gzclose;
+    $tmpfile->unlink_on_destroy(0);
     return $tmpfile->filename;
 }
 
@@ -163,10 +156,9 @@ sub Compress_File {
     my $self = shift;
     my $tempname = Gzip_File(@_);
     if ($tempname) {
-	$self->{'ERROR'} = undef;
-    }
-    else {
-	$self->{'ERROR'} = $Error;
+        $self->{'ERROR'} = undef;
+    } else {
+        $self->{'ERROR'} = $Error;
     }
     $tempname;
 }

-- 
Debpool Project Repository



More information about the Debpool-commits mailing list