Browse code

btrfs: build tag to enable showing version info

be default it is on, with build tags to disable the version info

Signed-off-by: Vincent Batts <vbatts@redhat.com>

Vincent Batts authored on 2014/11/07 05:56:13
Showing 4 changed files
... ...
@@ -60,10 +60,14 @@ func (d *Driver) String() string {
60 60
 }
61 61
 
62 62
 func (d *Driver) Status() [][2]string {
63
-	return [][2]string{
64
-		{"Build Version", BtrfsBuildVersion()},
65
-		{"Library Version", fmt.Sprintf("%d", BtrfsLibVersion())},
63
+	status := [][2]string{}
64
+	if bv := BtrfsBuildVersion(); bv != "-" {
65
+		status = append(status, [2]string{"Build Version", bv})
66 66
 	}
67
+	if lv := BtrfsLibVersion(); lv != -1 {
68
+		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
69
+	}
70
+	return status
67 71
 }
68 72
 
69 73
 func (d *Driver) Cleanup() error {
... ...
@@ -1,9 +1,18 @@
1
-// +build linux
1
+// +build linux,!btrfs_noversion
2 2
 
3 3
 package btrfs
4 4
 
5 5
 /*
6 6
 #include <btrfs/version.h>
7
+
8
+// because around version 3.16, they did not define lib version yet
9
+int my_btrfs_lib_version() {
10
+#ifdef BTRFS_LIB_VERSION
11
+  return BTRFS_LIB_VERSION;
12
+#else
13
+  return -1;
14
+#endif
15
+}
7 16
 */
8 17
 import "C"
9 18
 
10 19
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+// +build linux,btrfs_noversion
1
+
2
+package btrfs
3
+
4
+// TODO(vbatts) remove this work-around once supported linux distros are on
5
+// btrfs utililties of >= 3.16.1
6
+
7
+func BtrfsBuildVersion() string {
8
+	return "-"
9
+}
10
+func BtrfsLibVersion() int {
11
+	return -1
12
+}
... ...
@@ -162,6 +162,12 @@ SELinux, you will need to use the `selinux` build tag:
162 162
 export DOCKER_BUILDTAGS='selinux'
163 163
 ```
164 164
 
165
+If your version of btrfs-progs is < 3.16.1 (also called btrfs-tools), then you
166
+will need the following tag to not check for btrfs version headers:
167
+```bash
168
+export DOCKER_BUILDTAGS='btrfs_noversion'
169
+```
170
+
165 171
 There are build tags for disabling graphdrivers as well. By default, support
166 172
 for all graphdrivers are built in.
167 173