Package: jack / 3.1.1+cvs20050801-31

21_fallback_ripper.patch Patch series | download
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
51
52
53
54
55
56
57
58
59
60
61
62
Fallback to an installed ripper when the default one is not available and
the user has not specified one.  Debian #347975.

Depends on 18_warn_no_base_dir.patch for check_rc().

diff -urN jack-3.1.1~/jack jack-3.1.1/jack
--- jack-3.1.1~/jack	2006-01-23 23:40:49.000000000 +0000
+++ jack-3.1.1/jack	2006-01-23 23:41:52.000000000 +0000
@@ -84,7 +84,7 @@
 debug("user_cf: " + `user_cf`)
 debug("argv_cf: " + `argv_cf`)
 
-jack_checkopts.check_rc(global_cf, user_cf, argv_cf)
+jack_checkopts.check_rc(cf, global_cf, user_cf, argv_cf)
 jack_checkopts.consistency_check(cf)
 
 if cf['save_args']['val'] == 1:
diff -urN jack-3.1.1~/jack_checkopts.py jack-3.1.1/jack_checkopts.py
--- jack-3.1.1~/jack_checkopts.py	2006-01-23 23:40:49.000000000 +0000
+++ jack-3.1.1/jack_checkopts.py	2006-01-24 00:04:35.000000000 +0000
@@ -219,9 +219,22 @@
 # Checks concerning options specified by the user (in the global or user rc
 # files or the command line), i.e. options/values that are not the default
 # jack options from jack_config.
-def check_rc(global_cf, user_cf, argv_cf):
+def check_rc(cf, global_cf, user_cf, argv_cf):
 
     all_keys = global_cf.keys() + user_cf.keys() + argv_cf.keys()
     if 'base_dir' not in all_keys:
         warning("You have no standard location set, putting files into the current directory. Please consider setting base_dir in ~/.jack3rc.")
 
+    # Check if the default ripper is installed, and if not, look for another one
+    if 'ripper' not in all_keys:
+        default_ripper = cf["ripper"]["val"]
+        if not jack_utils.in_path(default_ripper):
+            rippers = [i for i in jack_helpers.helpers if jack_helpers.helpers[i]["type"] == "ripper" and jack_helpers.helpers[i].has_key("toc_cmd")]
+            for cmd in rippers:
+                if jack_utils.in_path(cmd):
+                    warning("Using ripper %s since default ripper %s is not available." % (cmd, default_ripper))
+                    cf.rupdate({'ripper': {'val': cmd}}, "check")
+                    break
+            else:
+                error("No valid ripper found on your system.")
+
diff -urN jack-3.1.1~/jack_utils.py jack-3.1.1/jack_utils.py
--- jack-3.1.1~/jack_utils.py	2006-01-23 23:40:49.000000000 +0000
+++ jack-3.1.1/jack_utils.py	2006-01-24 00:04:35.000000000 +0000
@@ -207,6 +207,13 @@
     new_path.append(base)
     new_path.reverse()
 
+def in_path(file):
+    "check if a file is an executable in PATH"
+    for path in os.environ.get("PATH", "").split(os.path.pathsep):
+        p = os.path.join(path, file)
+        if (os.path.isfile(p) and os.access(p, os.X_OK)): return True
+    return False
+
 def ex_edit(file):
     editor = "/usr/bin/sensible-editor"
     if os.environ.has_key("EDITOR"):