Parcourir la source

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 il y a 10 ans
Parent
commit
25154682a5

+ 7 - 3
daemon/graphdriver/btrfs/btrfs.go

@@ -60,10 +60,14 @@ func (d *Driver) String() string {
 }
 
 func (d *Driver) Status() [][2]string {
-	return [][2]string{
-		{"Build Version", BtrfsBuildVersion()},
-		{"Library Version", fmt.Sprintf("%d", BtrfsLibVersion())},
+	status := [][2]string{}
+	if bv := BtrfsBuildVersion(); bv != "-" {
+		status = append(status, [2]string{"Build Version", bv})
 	}
+	if lv := BtrfsLibVersion(); lv != -1 {
+		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
+	}
+	return status
 }
 
 func (d *Driver) Cleanup() error {

+ 10 - 1
daemon/graphdriver/btrfs/version.go

@@ -1,9 +1,18 @@
-// +build linux
+// +build linux,!btrfs_noversion
 
 package btrfs
 
 /*
 #include <btrfs/version.h>
+
+// because around version 3.16, they did not define lib version yet
+int my_btrfs_lib_version() {
+#ifdef BTRFS_LIB_VERSION
+  return BTRFS_LIB_VERSION;
+#else
+  return -1;
+#endif
+}
 */
 import "C"
 

+ 13 - 0
daemon/graphdriver/btrfs/version_none.go

@@ -0,0 +1,13 @@
+// +build linux,btrfs_noversion
+
+package btrfs
+
+// TODO(vbatts) remove this work-around once supported linux distros are on
+// btrfs utililties of >= 3.16.1
+
+func BtrfsBuildVersion() string {
+	return "-"
+}
+func BtrfsLibVersion() int {
+	return -1
+}

+ 6 - 0
hack/PACKAGERS.md

@@ -162,6 +162,12 @@ SELinux, you will need to use the `selinux` build tag:
 export DOCKER_BUILDTAGS='selinux'
 ```
 
+If your version of btrfs-progs is < 3.16.1 (also called btrfs-tools), then you
+will need the following tag to not check for btrfs version headers:
+```bash
+export DOCKER_BUILDTAGS='btrfs_noversion'
+```
+
 There are build tags for disabling graphdrivers as well. By default, support
 for all graphdrivers are built in.