Package: jack / 3.1.1+cvs20050801-31

42_cd_device_fallback.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
If the user doesn't specify a device and the default (/dev/cdrom) doesn't
exist, it would be nice if jack could fall back to the device(s) listed in
/proc/sys/dev/cdrom/info (at least on Linux).  According to the
linux-kernel mailing list, this is a stable interface.

Debian #353551
Depends on 21_fallback_ripper.patch

--- a/jack_checkopts.py
+++ b/jack_checkopts.py
@@ -242,3 +242,44 @@
             else:
                 error("No valid ripper found on your system.")
 
+    # If the default CD device doesn't exist, see whether we can find another one
+    if ('cd_device' not in all_keys and cf["rip_from_device"]["val"] and
+        not os.path.exists(cf["cd_device"]["val"])):
+        default = cf["cd_device"]["val"]
+        devices = []
+        # All CD devices can be found in /proc on Linux
+        cdrom_info = "/proc/sys/dev/cdrom/info"
+        if os.path.exists(cdrom_info):
+            try:
+                info = open(cdrom_info, "r")
+            except (IOError, OSError):
+                pass
+            else:
+                for line in info.readlines():
+                    if line.startswith("drive name:"):
+                        devices = ["/dev/" + x for x in line.rstrip().split("\t")[2:]]
+                        break
+                info.close()
+        message = "Default CD device %s does not exist" % default
+        if not devices:
+            warning("%s." % message)
+        elif len(devices) == 1:
+            warning("%s, using %s." % (message, devices[0]))
+            cf.rupdate({'cd_device': {'val': devices[0]}}, "check")
+        else:
+            warning("%s but there are several CD devices." % message)
+            for i in range(len(devices)):
+                print "%2d" % (i+1) + ".) " + devices[i]
+            input = 0
+            while input <= 0 or input > len(devices):
+                try:
+                    input = raw_input("Please choose: ")
+                except KeyboardInterrupt:
+                    sys.exit(0)
+                if input.isdigit():
+                    input = int(input)
+                else:
+                    input = 0
+            devices[0] = devices[input-1]
+            cf.rupdate({'cd_device': {'val': devices[0]}}, "check")
+