[virt-tools-list] [PATCH 46/47] Add formal RPM build infrastructure

Daniel P. Berrange berrange at redhat.com
Wed Aug 25 19:37:41 UTC 2010


* autogen.sh: Rewrite to use gnome-autogen.sh
* autobuild.sh: Automated RPM build control script
* configure.ac: Generate RPM specfiles
* Makefile.am: Distribute RPM specfile templates
* libosinfo.spec.in, mingw32-libosinfo.spec.in: RPM specs
* osinfo/Makefile.am, osinfo/libosinfo.syms: Fix Win32
  portability problem
---
 Makefile.am               |    4 +-
 autobuild.sh              |   59 +++++++++++++++++++++++++++
 autogen.sh                |   25 +++++++++---
 configure.ac              |    2 +
 libosinfo.spec.in         |   98 +++++++++++++++++++++++++++++++++++++++++++++
 mingw32-libosinfo.spec.in |   68 +++++++++++++++++++++++++++++++
 osinfo/Makefile.am        |    5 +-
 osinfo/libosinfo.syms     |    2 +-
 8 files changed, 253 insertions(+), 10 deletions(-)
 create mode 100755 autobuild.sh
 create mode 100644 libosinfo.spec.in
 create mode 100644 mingw32-libosinfo.spec.in

diff --git a/Makefile.am b/Makefile.am
index 8a8548e..bf67f14 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,9 @@
 SUBDIRS = osinfo test
 
 EXTRA_DIST = \
-  data/libosinfo-dummy-data.xml
+  data/libosinfo-dummy-data.xml \
+  libosinfo.spec.in \
+  mingw32-libosinfo.spec.in
 
 
 ACLOCAL_AMFLAGS = -I m4
diff --git a/autobuild.sh b/autobuild.sh
new file mode 100755
index 0000000..bf012da
--- /dev/null
+++ b/autobuild.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+set -e
+set -v
+
+# Make things clean.
+test -f Makefile && make -k distclean || :
+
+rm -rf build
+mkdir build
+cd build
+
+../autogen.sh --prefix=$AUTOBUILD_INSTALL_ROOT \
+    --enable-compile-warnings=error
+
+make
+make install
+
+rm -f *.tar.gz
+make dist
+
+if [ -n "$AUTOBUILD_COUNTER" ]; then
+  EXTRA_RELEASE=".auto$AUTOBUILD_COUNTER"
+else
+  NOW=`date +"%s"`
+  EXTRA_RELEASE=".$USER$NOW"
+fi
+
+if [ -f /usr/bin/rpmbuild ]; then
+  rpmbuild --nodeps \
+     --define "extra_release $EXTRA_RELEASE" \
+     --define "_sourcedir `pwd`" \
+     -ba --clean libosinfo.spec
+fi
+
+if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
+  make distclean
+
+  PKG_CONFIG_PATH="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig:/usr/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig" \
+  CC="i686-pc-mingw32-gcc" \
+  ../configure \
+    --build=$(uname -m)-pc-linux \
+    --host=i686-pc-mingw32 \
+    --enable-introspection=no \
+    --prefix="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw" \
+
+  make
+  make install
+
+  #set -o pipefail
+  #make check 2>&1 | tee "$RESULTS"
+
+  if [ -f /usr/bin/rpmbuild ]; then
+    rpmbuild --nodeps \
+       --define "extra_release $EXTRA_RELEASE" \
+       --define "_sourcedir `pwd`" \
+       -ba --clean mingw32-libosinfo.spec
+  fi
+fi
diff --git a/autogen.sh b/autogen.sh
index de14206..a532485 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,7 +1,20 @@
 #!/bin/sh
-libtoolize
-aclocal
-autoheader
-autoconf --force
-automake --add-missing
-./configure
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+PKG_NAME="libosinfo"
+
+(test -f $srcdir/osinfo/osinfo_db.c) || {
+    echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
+    echo " top-level $PKG_NAME directory"
+    exit 1
+}
+
+which gnome-autogen.sh || {
+    echo "You need to install gnome-common from the GNOME git"
+    exit 1
+}
+
+ACLOCAL_FLAGS="$ACLOCAL_FLAGS" USE_GNOME2_MACROS=1 . gnome-autogen.sh
diff --git a/configure.ac b/configure.ac
index f179904..f7f0abf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,8 @@ AM_CONDITIONAL([WITH_GOBJECT_INTROSPECTION], [test "x$enable_introspection" = "x
 
 AC_CONFIG_FILES([
 	Makefile
+	libosinfo.spec
+	mingw32-libosinfo.spec
 	osinfo/Makefile
 	osinfo/libosinfo-1.0.pc
 	test/Makefile
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
new file mode 100644
index 0000000..e60b8ab
--- /dev/null
+++ b/libosinfo.spec.in
@@ -0,0 +1,98 @@
+# -*- rpm-spec -*-
+
+# Plugin isn't ready for real world use yet - it needs
+# a security audit at very least
+%define with_plugin 0
+
+%define with_gir 0
+
+%if 0%{fedora} >= 12
+%define with_gir 1
+%endif
+
+Summary: A library for managing OS information for virtualization
+Name: libosinfo
+Version: @VERSION@
+Release: 1%{?dist}%{?extra_release}
+License: LGPLv2+
+Group: Development/Libraries
+Source: %{name}-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+URL: https://fedorahosted.org/libosinfo/
+BuildRequires: glib2-devel
+BuildRequires: libxml2-devel >= 2.6.0
+%if %{with_gir}
+BuildRequires: gobject-introspection-devel
+%if 0%{?fedora} < 14
+BuildRequires: gir-repository-devel
+%endif
+%endif
+
+%description
+libosinfo is a library that allows virtualization provisioning tools to
+determine the optimal device settings for a hypervisor/operating system
+combination.
+
+%package devel
+Summary: Libraries, includes, etc. to compile with the libosinfo library
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: pkgconfig
+Requires: glib2-devel
+
+%description devel
+libosinfo is a library that allows virtualization provisioning tools to
+determine the optimal device settings for a hypervisor/operating system
+combination.
+
+Libraries, includes, etc. to compile with the libosinfo library
+
+%prep
+%setup -q
+
+%build
+%if %{with_gir}
+%define gir_arg --enable-introspection=yes
+%else
+%define gir_arg --enable-introspection=no
+%endif
+
+%configure %{gir_arg}
+%__make %{?_smp_mflags} V=1
+
+%install
+rm -fr %{buildroot}
+%__make install DESTDIR=%{buildroot}
+rm -f %{buildroot}%{_libdir}/*.a
+rm -f %{buildroot}%{_libdir}/*.la
+#find_lang %{name}
+
+%clean
+rm -fr %{buildroot}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-, root, root)
+%doc AUTHORS ChangeLog COPYING NEWS README
+%{_libdir}/%{name}-1.0.so.*
+%if %{with_gir}
+%{_libdir}/girepository-1.0/Libosinfo-1.0.typelib
+%endif
+
+%files devel
+%defattr(-, root, root)
+%{_libdir}/%{name}-1.0.so
+%dir %{_includedir}/%{name}-1.0/
+%dir %{_includedir}/%{name}-1.0/osinfo/
+%{_includedir}/%{name}-1.0/osinfo/*.h
+%{_libdir}/pkgconfig/%{name}-1.0.pc
+%if %{with_gir}
+%{_datadir}/gir-1.0/Libosinfo-1.0.gir
+%endif
+
+%changelog
+* Wed Aug 25 2010 Daniel P. Berrange <berrange at redhat.com> - 0.2.0-1
+- Initial package
diff --git a/mingw32-libosinfo.spec.in b/mingw32-libosinfo.spec.in
new file mode 100644
index 0000000..35e8113
--- /dev/null
+++ b/mingw32-libosinfo.spec.in
@@ -0,0 +1,68 @@
+%define __strip %{_mingw32_strip}
+%define __objdump %{_mingw32_objdump}
+%define _use_internal_dependency_generator 0
+%define __find_requires %{_mingw32_findrequires}
+%define __find_provides %{_mingw32_findprovides}
+
+Name: mingw32-libosinfo
+Version: @VERSION@
+Release: 1%{?dist}%{?extra_release}
+Summary: MinGW Windows port of a library for managing OS information for virtualization
+License: LGPLv2+
+Group: Development/Libraries
+Source: libosinfo-%{version}.tar.gz
+URL: https://fedorahosted.org/libosinfo/
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch: noarch
+
+BuildRequires: mingw32-filesystem >= 40
+BuildRequires: mingw32-gcc
+BuildRequires: mingw32-binutils
+
+BuildRequires: mingw32-glib2
+BuildRequires: mingw32-libxml2
+BuildRequires: pkgconfig
+
+Requires: pkgconfig
+
+%description
+libosinfo is a library that allows virtualization provisioning tools to
+determine the optimal device settings for a hypervisor/operating system
+combination.
+
+%prep
+%setup -q -n libosinfo-%{version}
+
+%build
+%{_mingw32_configure} --enable-introspection=no
+make
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+
+# Remove static libraries but DON'T remove *.dll.a files.
+rm -f $RPM_BUILD_ROOT%{_mingw32_libdir}/libosinfo-1.0.a
+
+#find_lang libosinfo
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root)
+%{_mingw32_bindir}/libosinfo-1.0-0.dll
+%{_mingw32_libdir}/libosinfo-1.0.dll.a
+%{_mingw32_libdir}/libosinfo-1.0.la
+%{_mingw32_libdir}/pkgconfig/libosinfo-1.0.pc
+%dir %{_mingw32_includedir}/libosinfo-1.0/
+%dir %{_mingw32_includedir}/libosinfo-1.0/osinfo
+%{_mingw32_includedir}/libosinfo-1.0/osinfo/*.h
+
+%changelog
+* Wed Aug 25 2010 Daniel P. Berrange <berrange at redhat.com> - 0.2.0-1
+- Initial package
+
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index fa4348c..254a2be 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -8,12 +8,12 @@ BUILT_SOURCES = $(LIBOSINFO_VERSION_FILE)
 %.def: %.syms
 	$(AM_V_GEN)rm -f -- $@-tmp $@ ; \
 	printf 'EXPORTS\n' > $@-tmp && \
-	sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; s/[ \t]*\(.*\)\;/    \1/g' $^ >> $@-tmp && \
+	sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBOSINFO_/d; s/[ \t]*\(.*\)\;/    \1/g' $^ >> $@-tmp && \
 	chmod a-w $@-tmp && \
 	mv $@-tmp $@
 
 else
-LIBOSINFO_VERSION_FILE = libosinfo.syms
+LIBOSINFO_VERSION_FILE = $(srcdir)/libosinfo.syms
 endif
 
 pkgconfigdir = $(libdir)/pkgconfig
@@ -37,6 +37,7 @@ libosinfo_1_0_la_LDFLAGS = \
 libosinfo_1_0_includedir = $(includedir)/libosinfo-1.0/osinfo
 
 libosinfo_1_0_include_HEADERS = 		\
+  osinfo.h		\
   osinfo_db.h		\
   osinfo_device.h		\
   osinfo_devicelist.h		\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index e407d47..244282f 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -80,7 +80,7 @@ LIBOSINFO_0.0.1 {
 
   LIBOSINFO_0.0.2 {
     global:
-      ...
+
   } LIBOSINFO_0.0.1;
 
 */
-- 
1.7.2.1




More information about the virt-tools-list mailing list