Daniel P. Berrange
2011-Feb-11 14:07 UTC
[Libguestfs] [PATCH v2v] Add support for performing automated builds
* .gitignore: Ignore RPM specfile & coverage data * Build.PL: Generate specfile during build * autobuild.sh: Build control file * virt-v2v.spec.PL: RPM specfile * MANIFEST.SKIP: Ignore test coverage data --- .gitignore | 3 + Build.PL | 3 +- MANIFEST | 3 + MANIFEST.SKIP | 1 + autobuild.sh | 65 ++++++++++++++++++++++ virt-v2v.spec.PL | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 234 insertions(+), 1 deletions(-) create mode 100755 autobuild.sh create mode 100644 virt-v2v.spec.PL diff --git a/.gitignore b/.gitignore index 010a3ff..39e8075 100644 --- a/.gitignore +++ b/.gitignore @@ -7,11 +7,14 @@ /blib /Build /MANIFEST.bak +/cover_db +/virt-v2v.spec # Files related to 'Build dist' /META.yml /MYMETA.yml /virt-v2v*.tar.gz +/virt-v2v-v* /ChangeLog # Generated to pod2html diff --git a/Build.PL b/Build.PL index 6403731..b51b381 100644 --- a/Build.PL +++ b/Build.PL @@ -222,7 +222,8 @@ my $build = $class->new ( MailingList => "http://www.redhat.com/mailman/listinfo/libguestfs", }, }, - syntaxcheck_exclude => [ "COPYING", "COPYING.LIB", "README-NLS" ] + syntaxcheck_exclude => [ "COPYING", "COPYING.LIB", "README-NLS" ], + PL_files => [ 'virt-v2v.spec.PL' ], ); $build->add_build_element('confdoc'); diff --git a/MANIFEST b/MANIFEST index 1ff7e9b..9c2a5df 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,5 @@ augeas/README.txt +autobuild.sh Build.PL ChangeLog COPYING @@ -47,5 +48,7 @@ v2v/run-v2v-locally v2v/virt-v2v.conf v2v/virt-v2v.conf.pod v2v/virt-v2v.pl +virt-v2v.spec +virt-v2v.spec.PL windows/firstboot.bat windows/README.txt diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 7307836..93425a8 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -3,6 +3,7 @@ ^Build$ ^blib/ ^virt-v2v-v(\d+(\.\d+)*)(\.tar\.gz$|/) +^cover_db/ ^MYMETA.yml$ # Built translations diff --git a/autobuild.sh b/autobuild.sh new file mode 100755 index 0000000..ade08e2 --- /dev/null +++ b/autobuild.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# +# This script is used to Test::AutoBuild (http://www.autobuild.org) +# to perform automated builds of the virt-v2v module +# +# Copyright (C) 2009 Red Hat, Inc. +# Copyright (C) 2009 Daniel P. Berrange +# +# This program is free software; You can redistribute it and/or modify +# it under the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any +# later version +# +# The file "LICENSE" distributed along with this file provides full +# details of the terms and conditions +# + +NAME=virt-v2v + +set -e + +rm -rf MANIFEST blib _build Build + +perl Build.PL install_base=$AUTOBUILD_INSTALL_ROOT + +./Build +./Build changelog +./Build manifest + + +if [ -z "$USE_COVER" ]; then + perl -MDevel::Cover -e '' 1>/dev/null 2>&1 && USE_COVER=1 || USE_COVER=0 +fi + +if [ -z "$SKIP_TESTS" -o "$SKIP_TESTS" = "0" ]; then + if [ "$USE_COVER" = "1" ]; then + cover -delete + HARNESS_PERL_SWITCHES=-MDevel::Cover ./Build test + cover + mkdir blib/coverage + cp -a cover_db/*.html cover_db/*.css blib/coverage + mv blib/coverage/coverage.html blib/coverage/index.html + else + ./Build test + fi +fi + +./Build install \ + --install_path locale=$AUTOBUILD_INSTALL_ROOT/share/locale \ + --install_path confdoc=$AUTOBUILD_INSTALL_ROOT/share/man/man5 + +rm -f $NAME-*.tar.gz +./Build dist + +if [ -f /usr/bin/rpmbuild ]; then + if [ -n "$AUTOBUILD_COUNTER" ]; then + EXTRA_RELEASE=".auto$AUTOBUILD_COUNTER" + else + NOW=`date +"%s"` + EXTRA_RELEASE=".$USER$NOW" + fi + rpmbuild --nodeps -ta --define "extra_release $EXTRA_RELEASE" --clean $NAME-*.tar.gz +fi + +exit 0 diff --git a/virt-v2v.spec.PL b/virt-v2v.spec.PL new file mode 100644 index 0000000..308d2f4 --- /dev/null +++ b/virt-v2v.spec.PL @@ -0,0 +1,160 @@ +# -*- rpm-spec -*- +# Copyright (C) 2006 Daniel Berrange <dan at berrange.com> +# + +use strict; + +die unless (scalar @ARGV == 1); + +my $VERSION; +open PM, 'lib/Sys/VirtV2V.pm'; +while (<PM>) { + if (/\$Sys::VirtV2V::VERSION\s*=\s*"(.*)"/) { + $VERSION=$1; + } +} + +local $/ = undef; +$_ = <DATA>; +s/\@VERSION\@/$VERSION/g; + +open SPEC, ">$ARGV[0]" or die "$!"; +print SPEC $_; +close SPEC; +__DATA__ +# Automatically generated by virt-v2v.spec.PL + +Name: virt-v2v +Version: @VERSION@ +Release: 2%{?dist}%{?extra_release} +Summary: Convert a virtual machine to run on KVM + +Group: Applications/System +License: GPLv2+ and LGPLv2+ +URL: http://git.fedoraproject.org/git/virt-v2v.git +Source0: https://fedorahosted.org/releases/v/i/virt-v2v/%{name}-v%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +# Unfortunately, despite really being noarch, we have to make virt-v2v arch +# dependent to avoid build failures on architectures where libguestfs isn't +# available. +ExclusiveArch: %{ix86} x86_64 + +# Build system direct requirements +BuildRequires: gettext +BuildRequires: perl +BuildRequires: perl(Module::Build) +BuildRequires: perl(ExtUtils::Manifest) +BuildRequires: perl(Test::More) +BuildRequires: perl(Test::Pod) +BuildRequires: perl(Test::Pod::Coverage) +BuildRequires: perl(Module::Find) + +# Runtime perl modules also required at build time for use_ok test +BuildRequires: perl(DateTime) +BuildRequires: perl(IO::String) +BuildRequires: perl(Locale::TextDomain) +BuildRequires: perl(Module::Pluggable) +BuildRequires: perl(Net::HTTPS) +BuildRequires: perl(Net::SSL) +BuildRequires: perl(Sys::Guestfs) +BuildRequires: perl(Sys::Guestfs::Lib) +BuildRequires: perl(Sys::Virt) +BuildRequires: perl(Term::ProgressBar) +BuildRequires: perl(URI) +BuildRequires: perl(XML::DOM) +BuildRequires: perl(XML::DOM::XPath) +BuildRequires: perl(XML::Writer) + +# Need an explicit package dependency for version requires +BuildRequires: perl-libguestfs >= 1:1.6.0 +BuildRequires: perl-hivex >= 1.2.2 + +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) + +# Need an explicit package dependency for version requires +Requires: perl-libguestfs >= 1:1.6.0 +Requires: perl-hivex >= 1.2.2 + +# Net::SSL is loaded dynamically by Net::HTTPS in Sys::VirtV2V::Transfer::ESX. +# The dependency isn't automatically discovered. +Requires: perl(Net::SSL) + +# Need >= 0.8.1 for rpc fix talking to RHEL 5 libvirt +Requires: libvirt >= 0.8.1 + +# For GuestOS transfer image +Requires: /usr/bin/mkisofs + +%description +virt-v2v is a tool for converting and importing virtual machines to +libvirt-managed KVM, or Red Hat Enterprise Virtualization. It can import a +variety of guest operating systems from libvirt-managed hosts and VMware ESX. + + +%prep +%setup -q -n %{name}-v%{version} + +%build +%{__perl} Build.PL +./Build + +# Perl doesn't need debuginfo +%define debug_package %{nil} + +%install +rm -rf $RPM_BUILD_ROOT +./Build install \ + --destdir $RPM_BUILD_ROOT \ + --installdirs vendor \ + --install_path locale=%{_datadir}/locale \ + --install_path confdoc=%{_mandir}/man5 + +# Create lib directory, used for holding software to be installed in guests +statedir=$RPM_BUILD_ROOT%{_localstatedir}/lib/virt-v2v +mkdir -p $statedir/software + +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir} +cp v2v/virt-v2v.conf $RPM_BUILD_ROOT%{_sysconfdir}/ + +%find_lang %{name} + +# Not clear why this is being created as there is nothing arch-specific in +# virt-v2v. It isn't packaged, though, so we need to delete it. +find $RPM_BUILD_ROOT/%{perl_archlib} -name .packlist -type f | xargs rm + + +%check +./Build test + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files -f %{name}.lang +%defattr(-,root,root,-) + +%doc TODO.txt +%doc META.yml +%doc ChangeLog +%doc COPYING COPYING.LIB + +# For noarch packages: vendorlib +%{perl_vendorlib}/* + +# Man pages +%{_mandir}/man1/*.1* +%{_mandir}/man3/*.3* +%{_mandir}/man5/*.5* + +# Executables +%attr(0755,root,root) %{_bindir}/* + +%dir %{_localstatedir}/lib/virt-v2v + +%config(noreplace) %{_sysconfdir}/virt-v2v.conf +%config(noreplace) %{_localstatedir}/lib/virt-v2v/software + + +%changelog -- 1.7.4
Matthew Booth
2011-Feb-11 14:31 UTC
[Libguestfs] [PATCH v2v] Add support for performing automated builds
On 11/02/11 14:07, Daniel P. Berrange wrote:> * .gitignore: Ignore RPM specfile& coverage data > * Build.PL: Generate specfile during build > * autobuild.sh: Build control file > * virt-v2v.spec.PL: RPM specfile > * MANIFEST.SKIP: Ignore test coverage data > --- > .gitignore | 3 + > Build.PL | 3 +- > MANIFEST | 3 + > MANIFEST.SKIP | 1 + > autobuild.sh | 65 ++++++++++++++++++++++ > virt-v2v.spec.PL | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 6 files changed, 234 insertions(+), 1 deletions(-) > create mode 100755 autobuild.sh > create mode 100644 virt-v2v.spec.PL >ACK. I'll push this later. I'm curious to know why the additional ./Build changelog step is required, though. I think that points at a missing build dep. Happy to leave that for another day, though. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490