From ee6bbaeb6648349ae62735df470e4c5e2ed1f28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Thu, 19 Apr 2012 17:34:10 +0100 Subject: buildsystem.py: Add support for generic Perl build system --- morphlib/buildsystem.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index ab12e730..f5eae027 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -150,10 +150,38 @@ class PythonDistutilsBuildSystem(BuildSystem): return any(exists(x) for x in indicators) +class PerlBuildSystem(BuildSystem): + + '''The Perl build system.''' + + name = 'perl' + + def __init__(self): + self.configure_commands = [ + 'perl Makefile.PL', + ] + self.build_commands = [ + 'make', + ] + self.test_commands = [ + ] + self.install_commands = [ + 'make install', + ] + + def used_by_project(self, exists): + indicators = [ + 'Makefile.PL', + ] + + return any(exists(x) for x in indicators) + + build_systems = [ ManualBuildSystem(), AutotoolsBuildSystem(), PythonDistutilsBuildSystem(), + PerlBuildSystem(), DummyBuildSystem(), ] -- cgit v1.2.1 From 2ff9dd7294f09179813b49920e11b57bbd945cda Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 23 Apr 2012 11:37:37 +0000 Subject: buildsystem: rename Perl build system to CPAN --- morphlib/buildsystem.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index f5eae027..045616e4 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -150,11 +150,11 @@ class PythonDistutilsBuildSystem(BuildSystem): return any(exists(x) for x in indicators) -class PerlBuildSystem(BuildSystem): +class CPANBuildSystem(BuildSystem): - '''The Perl build system.''' + '''The Perl cpan build system.''' - name = 'perl' + name = 'cpan' def __init__(self): self.configure_commands = [ @@ -181,7 +181,7 @@ build_systems = [ ManualBuildSystem(), AutotoolsBuildSystem(), PythonDistutilsBuildSystem(), - PerlBuildSystem(), + CPANBuildSystem(), DummyBuildSystem(), ] -- cgit v1.2.1 From 8a653a535f41249cf0b5cea098a3ca65641962a2 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 23 Apr 2012 13:19:31 +0000 Subject: CPANBuildSystem: use destdir --- morphlib/buildsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index 045616e4..7b000876 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -166,7 +166,7 @@ class CPANBuildSystem(BuildSystem): self.test_commands = [ ] self.install_commands = [ - 'make install', + 'make DESTDIR="$DESTDIR" install', ] def used_by_project(self, exists): -- cgit v1.2.1 From d210fb09bb0becb69975e92f42d16260d4d23933 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 23 Apr 2012 15:23:01 +0000 Subject: tests: add test for build-system: cpan This does some horrible output mangling because where you install perl modules depends on how your perl was compiled and its version. This will still probably fail on some machines --- tests/build-system-cpan.script | 73 ++++++++++++++++++++++++++++++++++++++++++ tests/build-system-cpan.stdout | 19 +++++++++++ 2 files changed, 92 insertions(+) create mode 100755 tests/build-system-cpan.script create mode 100644 tests/build-system-cpan.stdout diff --git a/tests/build-system-cpan.script b/tests/build-system-cpan.script new file mode 100755 index 00000000..cce7eb36 --- /dev/null +++ b/tests/build-system-cpan.script @@ -0,0 +1,73 @@ +#!/bin/sh +# +# Convert the hello-chunk project to perl with CPAN +# +# Copyright (C) 2011, 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" + +git checkout --quiet farrokh + +git rm --quiet hello.c + +cat <hello +#!/usr/bin/perl +print "hello, world\n" +EOF +git add hello + +cat <Makefile.PL +use strict; +use warnings; +use ExtUtils::MakeMaker; +WriteMakefile( + EXE_FILES => ['hello'], +) +EOF +git add Makefile.PL + +cat <hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "cpan" +} +EOF +git add hello.morph + +git commit --quiet -m 'convert hello into a perl cpan project' + +"$SRCDIR/scripts/test-morph" build chunk-repo farrokh hello.morph + +TEMPEXTRACT="$DATADIR/cpanextract" +mkdir -p "$TEMPEXTRACT" + +PERLVERSION=`perl -e 'print $^V' | sed 's|^v\(.*\)|\1|'` +PERLMAJOR=`perl -e 'print $^V' | sed 's|^v\([^\.]*\)\.[^\.]*\.[^\.]*$|\1|'` +ARCH=`perl -V | grep archname | sed 's|^.*archname=\(\S*\).*$|\1|'` + +for chunk in "$DATADIR/cache/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | + sed -e '/^\.\/./s:^\./::' \ + -e s/"$ARCH"/ARCH/ \ + -e s/perl"$PERLMAJOR"/PERLDIR/ \ + -e s/"$PERLVERSION"/PERLVERSION/ +done diff --git a/tests/build-system-cpan.stdout b/tests/build-system-cpan.stdout new file mode 100644 index 00000000..e6e093cc --- /dev/null +++ b/tests/build-system-cpan.stdout @@ -0,0 +1,19 @@ +arch=x86_64-linux major=5 version=5.14.2 +.chunk.hello: +./ +baserock/ +baserock/hello.meta +usr/ +usr/bin/ +usr/bin/hello +usr/lib/ +usr/lib/PERLDIR/ +usr/lib/PERLDIR/PERLVERSION/ +usr/lib/PERLDIR/PERLVERSION/ARCH/ +usr/lib/PERLDIR/PERLVERSION/ARCH/perllocal.pod +usr/lib/PERLDIR/site_perl/ +usr/lib/PERLDIR/site_perl/PERLVERSION/ +usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/ +usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/auto/ +usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/auto/hello.build/ +usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/auto/hello.build/.packlist -- cgit v1.2.1 From de61437aae79c4f9f9f5d0d90b25eda798133b42 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 23 Apr 2012 15:35:15 +0000 Subject: CPANBuildSystem: use $PREFIX --- morphlib/buildsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index 7b000876..799f35cc 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -158,7 +158,7 @@ class CPANBuildSystem(BuildSystem): def __init__(self): self.configure_commands = [ - 'perl Makefile.PL', + 'perl Makefile.PL INSTALL_BASE="$PREFIX"', ] self.build_commands = [ 'make', -- cgit v1.2.1 From 7c496033582027573c135f723e3a468716ce5f88 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 23 Apr 2012 15:37:34 +0000 Subject: tests: cpan use prefix for simpler output --- tests/build-system-cpan.script | 2 +- tests/build-system-cpan.stdout | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/build-system-cpan.script b/tests/build-system-cpan.script index cce7eb36..0a4be35b 100755 --- a/tests/build-system-cpan.script +++ b/tests/build-system-cpan.script @@ -53,7 +53,7 @@ git add hello.morph git commit --quiet -m 'convert hello into a perl cpan project' -"$SRCDIR/scripts/test-morph" build chunk-repo farrokh hello.morph +"$SRCDIR/scripts/test-morph" build --prefix=/ chunk-repo farrokh hello.morph TEMPEXTRACT="$DATADIR/cpanextract" mkdir -p "$TEMPEXTRACT" diff --git a/tests/build-system-cpan.stdout b/tests/build-system-cpan.stdout index e6e093cc..e0c21af1 100644 --- a/tests/build-system-cpan.stdout +++ b/tests/build-system-cpan.stdout @@ -1,19 +1,13 @@ -arch=x86_64-linux major=5 version=5.14.2 .chunk.hello: ./ baserock/ baserock/hello.meta -usr/ -usr/bin/ -usr/bin/hello -usr/lib/ -usr/lib/PERLDIR/ -usr/lib/PERLDIR/PERLVERSION/ -usr/lib/PERLDIR/PERLVERSION/ARCH/ -usr/lib/PERLDIR/PERLVERSION/ARCH/perllocal.pod -usr/lib/PERLDIR/site_perl/ -usr/lib/PERLDIR/site_perl/PERLVERSION/ -usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/ -usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/auto/ -usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/auto/hello.build/ -usr/lib/PERLDIR/site_perl/PERLVERSION/ARCH/auto/hello.build/.packlist +bin/ +bin/hello +lib/ +lib/PERLDIR/ +lib/PERLDIR/ARCH/ +lib/PERLDIR/ARCH/auto/ +lib/PERLDIR/ARCH/auto/hello.build/ +lib/PERLDIR/ARCH/auto/hello.build/.packlist +lib/PERLDIR/ARCH/perllocal.pod -- cgit v1.2.1 From aa204b6f53f7655c7583e2e1fcecf0f0f1bc8fa8 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 23 Apr 2012 15:39:35 +0000 Subject: build-system-cpan test: remove redundant mangling --- tests/build-system-cpan.script | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/build-system-cpan.script b/tests/build-system-cpan.script index 0a4be35b..59017d3f 100755 --- a/tests/build-system-cpan.script +++ b/tests/build-system-cpan.script @@ -58,7 +58,6 @@ git commit --quiet -m 'convert hello into a perl cpan project' TEMPEXTRACT="$DATADIR/cpanextract" mkdir -p "$TEMPEXTRACT" -PERLVERSION=`perl -e 'print $^V' | sed 's|^v\(.*\)|\1|'` PERLMAJOR=`perl -e 'print $^V' | sed 's|^v\([^\.]*\)\.[^\.]*\.[^\.]*$|\1|'` ARCH=`perl -V | grep archname | sed 's|^.*archname=\(\S*\).*$|\1|'` @@ -68,6 +67,5 @@ do tar -tf "$chunk" | LC_ALL=C sort | sed -e '/^\.\/./s:^\./::' \ -e s/"$ARCH"/ARCH/ \ - -e s/perl"$PERLMAJOR"/PERLDIR/ \ - -e s/"$PERLVERSION"/PERLVERSION/ + -e s/perl"$PERLMAJOR"/PERLDIR/ done -- cgit v1.2.1