File: 10_protect_mdldm_call.diff

package info (click to toggle)
durep 0.9-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 416 kB
  • sloc: perl: 2,060; sh: 101; makefile: 23
file content (50 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Description: Issue warning on MLDBM
 Instead of of having the hashing library MLDBM as a prerequisite,
 implement code in 'durep' that issues a warning, and then aborts
 execution, in case the module is missing.
Forwarded: no
Author: Eduard Bloch
Last-Update: 2010-01-09
--- durep-0.9.orig/durep
+++ durep-0.9/durep
@@ -15,7 +15,7 @@
 
 use Getopt::Long;
 use File::Basename;
-use MLDBM qw(DB_File Storable);
+#use MLDBM qw(DB_File Storable);
 use Fcntl;
 use Sys::Hostname;
 use POSIX;
@@ -104,7 +104,15 @@
 $root_dir = cwd();
 chdir($_);
 
+sub check_mldbm {
+  eval 'use MLDBM qw(DB_File Storable)';
+  if ($@) {
+     die "Unable to load MLDBM, install the libmldbm-perl package.\n";
+  }
+}
+
 if($opt_loadfile) {
+  &check_mldbm;
   tie %{$root_node}, 'MLDBM', "$opt_loadfile", O_RDONLY, 0640 or doAbort("Unable to tie file '$opt_loadfile'.");
 }
 else {
@@ -121,6 +129,7 @@
       unlink $opt_savefile;
     }
 
+    &check_mldbm;
     tie %{$root_node}, 'MLDBM', "$opt_savefile", O_CREAT|O_RDWR, 0640 or doAbort("Unable to tie file '$opt_savefile'.");
   }
 
@@ -273,6 +282,7 @@
 
   doAbort("'$opt_collate' is not a valid directory.") unless -d $opt_collate;
 
+  &check_mldbm;
   tie %db, 'MLDBM', "$opt_collate/durep.cds", O_CREAT|O_RDWR, 0640 or doAbort("Unable to tie file '$opt_collate/durep.cds'");
 
   my @files;