From b03f4b7051ca274143b6cfac3b54542617df3842 Mon Sep 17 00:00:00 2001 From: David Nyström Date: Mon, 17 Dec 2012 16:16:37 +0100 Subject: Added ability to parse python sources to create-recipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, Added python source parsing abilities to create-recipe. (From OE-Core rev: 417357cbcd3ecc7a2e43f87c618c8fdfe04a9d33) Signed-off-by: David Nyström Signed-off-by: Saul Wold Signed-off-by: Richard Purdie --- scripts/create-recipe | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/create-recipe b/scripts/create-recipe index 776c91dd9d..a556e39dd1 100755 --- a/scripts/create-recipe +++ b/scripts/create-recipe @@ -40,6 +40,8 @@ my $version = $predef_version; my $description = ""; my $summary = ""; my $url = ""; +my $homepage; +my @rdepends; my $configure = ""; my $localename = ""; my @sources; @@ -1679,6 +1681,7 @@ sub write_bbfile open(BBFILE, ">${name}_$version.bb"); print BBFILE "SUMMARY = \"$summary\"\n"; print BBFILE "DESCRIPTION = \"$description\"\n"; + print BBFILE "HOMEPAGE = \"$homepage\"\n"; print BBFILE "LICENSE = \"@license\"\n"; print BBFILE "LIC_FILES_CHKSUM = \""; @@ -1698,6 +1701,10 @@ sub write_bbfile print BBFILE "DEPENDS = \"@out\"\n\n"; }; + if (@rdepends > 0) { + print BBFILE "RDEPENDS_\$\{PN\} += \"@rdepends\"\n"; + } + print BBFILE 'PR = "r0"' . "\n\n"; print BBFILE "SRC_URI = \""; foreach (@sources) { @@ -1734,6 +1741,7 @@ sub calculate_sums chomp($sha256sum); } + ############################################################################ # # Main program @@ -1820,6 +1828,40 @@ foreach (@dirs) { $fulldir = $dir; +if ( -e "$dir/setup.py" ) { + $python = 1; + push(@inherits, "distutils"); + + system("cd $dir ; python setup.py build sdist &> /dev/null"); + + $templic = `sed '/^License: */!d; s///;q' $dir/*.egg-info/PKG-INFO`; + chomp($templic); + push(@license, $templic); + $summary = `sed '/^Name: */!d; s///;q' $dir/*.egg-info/PKG-INFO`; + chomp($summary); + $description = `sed '/^Summary: */!d; s///;q' $dir/*.egg-info/PKG-INFO`; + chomp($description); + $homepage = `sed '/^Home-page: */!d; s///;q' $dir/*.egg-info/PKG-INFO`; + chomp($homepage); + $findoutput = `find $dir/*.egg-info/ -name "requires.txt" 2>/dev/null`; + @findlist = split(/\n/, $findoutput); + foreach (@findlist) { + # Adding dependency do buildreqs should be removed when + # distutils is unbroken, i.e. blocks setup.py install from + # downloading and installing dependencies. + push(@buildreqs, `sed 's/[^a-zA-Z]//g' $dir/*.egg-info/requires.txt`); + chomp(@buildreqs); + foreach $item (@buildreqs) { + $item = "python-" . $item + } + push(@rdepends, `sed 's/[^a-zA-Z]//g' $dir/*.egg-info/requires.txt`); + chomp(@rdepends); + foreach $item (@rdepends) { + $item = "python-" . $item + } + } +} + if ( -e "$dir/autogen.sh" ) { $configure = "autogen"; $uses_configure = 1; @@ -1859,7 +1901,6 @@ if (-e "$dir/$name.pro") { push(@inherits, "qmake2"); } - # # This is a good place to generate configure.in # @@ -1868,6 +1909,8 @@ if (length($configure) > 2) { system("cd $dir ; ./autogen.sh &> /dev/null"); } } + + @files = <$dir/configure>; foreach (@files) { process_configure("$_"); @@ -1893,8 +1936,10 @@ foreach (@files) { guess_license_from_file("$_"); } - -guess_description($dir); + +if ($python != 1) { + guess_description($dir); +} # # Output of bbfile file -- cgit v1.2.3-54-g00ecf