The following commit has been merged in the master branch:
commit 70ebda71e67e603070678d301753bc40c3c307c4
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Wed Oct 8 20:55:30 2008 +0200

    Util: Add some more utility functions based on Lintian::Command
    
    delete_dir is a shorthand for 'rm -fr'
    copy_dir is a shorthand for 'cp -a'
    touch_file is Lab::_touch moved to Util
    gunzip_file is a shorthand for 'gzip -dc'
    
    All these are used repeatedly in collection scripts.

diff --git a/lib/Lab.pm b/lib/Lab.pm
index 8bf8184..413343f 100644
--- a/lib/Lab.pm
+++ b/lib/Lab.pm
@@ -120,7 +120,7 @@ sub setup_force {
     # can analyze what changed.
     for my $pkgtype (qw( binary source udeb )) {
        if (not -f "$dir/info/$pkgtype-packages") {
-           _touch("$dir/info/$pkgtype-packages")
+           touch_file("$dir/info/$pkgtype-packages")
                or fail("cannot create $pkgtype package list");
        }
     }
@@ -214,11 +214,10 @@ sub delete_force {
     }
 
     # looks ok.
-    unless (spawn(undef, ['rm', '-rf', '--',
-                         "$self->{dir}/binary",
-                         "$self->{dir}/source",
-                         "$self->{dir}/udeb",
-                         "$self->{dir}/info"])) {
+    unless (delete_dir("$self->{dir}/binary",
+                      "$self->{dir}/source",
+                      "$self->{dir}/udeb",
+                      "$self->{dir}/info")) {
                warning("cannot remove lab directory $self->{dir} (please 
remove it yourself)");
     }
 
@@ -234,16 +233,6 @@ sub delete_force {
     return 1;
 }
 
-# create an empty file
-# --okay, okay, this is not exactly what `touch' does :-)
-sub _touch {
-    open(T, '>', $_[0]) or return 0;
-    close(T) or return 0;
-
-    return 1;
-}
-
-
 1;
 
 # vim: ts=4 sw=4 noet
diff --git a/lib/Util.pm b/lib/Util.pm
index 0b8f91d..fd5d4f9 100644
--- a/lib/Util.pm
+++ b/lib/Util.pm
@@ -33,6 +33,10 @@ our @EXPORT = qw(parse_dpkg_control
        file_is_encoded_in_non_utf8
        fail
        system_env
+       delete_dir
+       copy_dir
+       gunzip_file
+       touch_file
        perm2oct);
 
 use FileHandle;
@@ -258,7 +262,30 @@ sub perm2oct {
     return $o;
 }
 
-# ------------------------
+
+sub delete_dir {
+    return spawn(undef, ['rm', '-rf', '--', @_]);
+}
+
+sub copy_dir {
+    return spawn(undef, ['cp', '-a', '--', @_]);
+}
+
+sub gunzip_file {
+    my ($in, $out) = @_;
+    spawn({out => $out},
+         ['gzip', '-dc', $in])
+       or fail("error in gzip");
+}
+
+# create an empty file
+# --okay, okay, this is not exactly what `touch' does :-)
+sub touch_file {
+    open(T, '>', $_[0]) or return 0;
+    close(T) or return 0;
+
+    return 1;
+}
 
 sub fail {
     my $str;

-- 
Debian package checker


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to