From 997d83ab664d95cd31cfe3aa7ebba2fb98ca78b6 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 9 Jul 2013 14:14:34 +0100 Subject: [PATCH] Add upstream patch to fix golang bindings. --- ...-it-builds-if-libguestfs-is-not-inst.patch | 61 +++++++++++++++++++ libguestfs.spec | 9 ++- 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 0001-golang-Fix-it-so-it-builds-if-libguestfs-is-not-inst.patch diff --git a/0001-golang-Fix-it-so-it-builds-if-libguestfs-is-not-inst.patch b/0001-golang-Fix-it-so-it-builds-if-libguestfs-is-not-inst.patch new file mode 100644 index 0000000..4c8e312 --- /dev/null +++ b/0001-golang-Fix-it-so-it-builds-if-libguestfs-is-not-inst.patch @@ -0,0 +1,61 @@ +From 0bc729e85b11262e5c1a38aff1602c960277c2b4 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 9 Jul 2013 13:59:52 +0100 +Subject: [PATCH] golang: Fix it so it builds if libguestfs is not installed. + +It was using the installed copy of libguestfs not the local copy. + +We can't encode the paths in guestfs.go, since this source file gets +copied into the install directory where those paths would not make +sense. Instead we have to use CGO_CFLAGS and CGO_LDFLAGS to +communicate the right flags to go when doing the local build and test. +--- + generator/golang.ml | 6 +++--- + run.in | 12 ++++++++++++ + 2 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/generator/golang.ml b/generator/golang.ml +index f7010bc..82c1a0d 100644 +--- a/generator/golang.ml ++++ b/generator/golang.ml +@@ -37,11 +37,11 @@ let generate_golang_go () = + package guestfs + + /* +-#cgo CFLAGS: -I../src -DGUESTFS_PRIVATE=1 +-#cgo LDFLAGS: -L../src/.libs -lguestfs ++#cgo CFLAGS: -DGUESTFS_PRIVATE=1 ++#cgo LDFLAGS: -lguestfs + #include + #include +-#include ++#include \"guestfs.h\" + + // cgo can't deal with variable argument functions. + static guestfs_h * +diff --git a/run.in b/run.in +index 46cd71f..5d9ad75 100755 +--- a/run.in ++++ b/run.in +@@ -171,6 +171,18 @@ else + GOPATH="$b/golang:$GOPATH" + fi + export GOPATH ++if [ -z "$CGO_CFLAGS" ]; then ++ CGO_CFLAGS="-I$s/src" ++else ++ CGO_CFLAGS="$CGO_CFLAGS -I$s/src" ++fi ++export CGO_CFLAGS ++if [ -z "$CGO_LDFLAGS" ]; then ++ CGO_LDFLAGS="-L$b/src/.libs" ++else ++ CGO_LDFLAGS="$CGO_LDFLAGS -L$b/src/.libs" ++fi ++export CGO_LDFLAGS + + # For GObject, Javascript and friends. + export GJS=@GJS@ +-- +1.8.3.1 + diff --git a/libguestfs.spec b/libguestfs.spec index b1c9e45..2ef434b 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -12,13 +12,15 @@ Summary: Access and modify virtual machine disk images Name: libguestfs Epoch: 1 Version: 1.23.8 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ # Source and patches. URL: http://libguestfs.org/ Source0: http://libguestfs.org/download/1.23-development/%{name}-%{version}.tar.gz +Patch1: 0001-golang-Fix-it-so-it-builds-if-libguestfs-is-not-inst.patch + # Basic build requirements: BuildRequires: perl(Pod::Simple) BuildRequires: perl(Pod::Man) @@ -534,6 +536,8 @@ for %{name}. %prep %setup -q +%patch1 -p1 + if [ "$(getenforce | tr '[A-Z]' '[a-z]')" != "disabled" ]; then # For sVirt to work, the local temporary directory we use in the # tests must be labelled the same way as /tmp. @@ -906,9 +910,10 @@ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/libguestfs %changelog -* Tue Jul 9 2013 Richard W.M. Jones - 1:1.23.8-1 +* Tue Jul 9 2013 Richard W.M. Jones - 1:1.23.8-2 - New upstream version 1.23.8. - Try enabling golang bindings. +- Add upstream patch to fix golang bindings. * Wed Jul 3 2013 Richard W.M. Jones - 1:1.23.7-1 - New upstream version 1.23.7.