summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create-recipe (renamed from scripts/autospectacle.pl)117
1 files changed, 103 insertions, 14 deletions
diff --git a/scripts/autospectacle.pl b/scripts/create-recipe
index bb9f8dc39b..aba9ac37d9 100755
--- a/scripts/autospectacle.pl
+++ b/scripts/create-recipe
@@ -1,5 +1,7 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl -w
2 2
3# Copyright (C) 2012 Wind River Systems, Inc.
4#
3# Copyright (C) 2010 Intel Corporation 5# Copyright (C) 2010 Intel Corporation
4# 6#
5# 7#
@@ -29,6 +31,7 @@
29use File::Temp qw(tempdir); 31use File::Temp qw(tempdir);
30use File::Path qw(mkpath rmtree); 32use File::Path qw(mkpath rmtree);
31use File::Spec (); 33use File::Spec ();
34use File::Basename qw(basename dirname);
32 35
33 36
34my $name = ""; 37my $name = "";
@@ -42,6 +45,10 @@ my @sources;
42my @mainfiles; 45my @mainfiles;
43my @patches; 46my @patches;
44 47
48my $md5sum = "";
49my $sh256sum = "";
50my @inherits;
51
45my $printed_subpackages = 0; 52my $printed_subpackages = 0;
46my $fulldir = ""; 53my $fulldir = "";
47 54
@@ -70,6 +77,7 @@ my %failed_headers;
70 77
71my %licenses; 78my %licenses;
72my @license; 79my @license;
80my %lic_files;
73 81
74sub setup_licenses 82sub setup_licenses
75{ 83{
@@ -115,8 +123,14 @@ sub guess_license_from_file {
115 if (defined($licenses{$sha1})) { 123 if (defined($licenses{$sha1})) {
116 my $lic = $licenses{$sha1}; 124 my $lic = $licenses{$sha1};
117 push(@license, $lic); 125 push(@license, $lic);
126
127 my $md5output = `md5sum $copying`;
128 $md5output =~ /^([a-zA-Z0-9]*) /;
129 my $md5 = $1;
130 chomp($md5);
131 $lic_files{$copying} = $md5
118 } 132 }
119 133
120 # 134 #
121 # We also must make sure that the COPYING/etc files 135 # We also must make sure that the COPYING/etc files
122 # end up in the main package as %doc.. 136 # end up in the main package as %doc..
@@ -124,7 +138,7 @@ sub guess_license_from_file {
124 $copying =~ s/$fulldir//g; 138 $copying =~ s/$fulldir//g;
125 $copying =~ s/^\///g; 139 $copying =~ s/^\///g;
126 $copying = "\"\%doc " . $copying ."\""; 140 $copying = "\"\%doc " . $copying ."\"";
127 141
128 push(@mainfiles, $copying); 142 push(@mainfiles, $copying);
129} 143}
130 144
@@ -1522,7 +1536,7 @@ sub guess_name_from_url {
1522 } 1536 }
1523 my $tarfile = $spliturl[0]; 1537 my $tarfile = $spliturl[0];
1524 1538
1525 if ($tarfile =~ /(.*?)\-([0-9\.\-\~]+)\.tar/) { 1539 if ($tarfile =~ /(.*?)\-([0-9\.\-\~]+)[-\.].*?\.tar/) {
1526 $name = $1; 1540 $name = $1;
1527 $version = $2; 1541 $version = $2;
1528 $version =~ s/\-/\_/g; 1542 $version =~ s/\-/\_/g;
@@ -1650,7 +1664,7 @@ sub write_yaml
1650 write_makefile(); 1664 write_makefile();
1651 write_changelog(); 1665 write_changelog();
1652 1666
1653 system("rm $name.spec"); 1667 system("rm $name.spec 2>/dev/null");
1654 system("specify &> /dev/null"); 1668 system("specify &> /dev/null");
1655 if ($oscmode > 0) { 1669 if ($oscmode > 0) {
1656 system("osc addremove"); 1670 system("osc addremove");
@@ -1659,6 +1673,65 @@ sub write_yaml
1659 1673
1660} 1674}
1661 1675
1676sub write_bbfile
1677{
1678 open(BBFILE, ">${name}_$version.bb");
1679 print BBFILE "SUMMARY = \"$summary\"\n";
1680 print BBFILE "DESCRIPTION = \"$description\"\n";
1681
1682 print BBFILE "LICENSE = \"@license\"\n";
1683 print BBFILE "LIC_FILES_CHKSUM = \"";
1684 foreach (keys %lic_files) {
1685 print BBFILE "file://" . basename($_) . ";md5=$lic_files{$_} \\\n";
1686 }
1687 print BBFILE "\"\n\n";
1688
1689 if (@license <= 0) {
1690 print "Can NOT get license from package itself.\n";
1691 print "Please update the license and license file manually.\n";
1692 }
1693
1694 if (@buildreqs > 0) {
1695 my %saw;
1696 my @out = grep(!$saw{$_}++,@buildreqs);
1697 print BBFILE "DEPENDS = \"@out\"\n\n";
1698 };
1699
1700 print BBFILE 'PR = "r0"' . "\n\n";
1701 print BBFILE "SRC_URI = \"";
1702 foreach (@sources) {
1703 print BBFILE "$_ \\\n";
1704 }
1705 print BBFILE "\"\n\n";
1706 print BBFILE "SRC_URI[md5sum] = \"$md5sum\"\n";
1707 print BBFILE "SRC_URI[sha256sum] = \"$sha256sum\"\n";
1708
1709 if (@inherits) {
1710 print BBFILE "inherit ";
1711 foreach (@inherits) {
1712 print BBFILE "$_ ";
1713 }
1714 }
1715
1716 close(BBFILE);
1717
1718 my $curdir = `pwd`;
1719 chomp($curdir);
1720 print "Create bb file: $curdir/${name}_$version.bb\n";
1721}
1722
1723sub calculate_sums
1724{
1725 @_ = basename $dir;
1726 my $md5output = `md5sum @_`;
1727 $md5output =~ /^([a-zA-Z0-9]*) /;
1728 $md5sum = $1;
1729 chomp($md5sum);
1730 my $sha256output = `sha256sum @_`;
1731 $sha256output =~ /^([a-zA-Z0-9]*) /;
1732 $sha256sum = $1;
1733 chomp($sha256sum);
1734}
1662 1735
1663############################################################################ 1736############################################################################
1664# 1737#
@@ -1696,33 +1769,40 @@ $dir = $ARGV[0];
1696guess_name_from_url($dir); 1769guess_name_from_url($dir);
1697push(@sources, $dir); 1770push(@sources, $dir);
1698 1771
1699
1700#system("cd $tmpdir; curl -s -O $dir"); 1772#system("cd $tmpdir; curl -s -O $dir");
1701$orgdir = `pwd`; 1773$orgdir = `pwd`;
1702chomp($orgdir); 1774chomp($orgdir);
1775my $outputdir = $name;
1776if (! $name) {
1777 $outputdir = basename $dir;
1778}
1779mkpath($outputdir);
1780chdir($outputdir);
1703print "Downloading package: $dir\n"; 1781print "Downloading package: $dir\n";
1704system("wget --quiet $dir"); 1782system("wget --quiet $dir") == 0 or die "Download $dir failed.";
1783
1784calculate_sums($outputdir);
1785
1705print "Unpacking to : $tmpdir\n"; 1786print "Unpacking to : $tmpdir\n";
1706 1787
1707my @tgzfiles = <$orgdir/*.tgz>; 1788my @tgzfiles = <$orgdir/$outputdir/*.tgz>;
1708foreach (@tgzfiles) { 1789foreach (@tgzfiles) {
1709 my $tgz = $_; 1790 my $tgz = basename $_;
1710 my $tar = $tgz; 1791 my $tar = $tgz;
1711 $tar =~ s/tgz/tar\.gz/g; 1792 $tar =~ s/tgz/tar\.gz/g;
1712 $dir =~ s/tgz/tar\.gz/g; 1793 $dir =~ s/tgz/tar\.gz/g;
1713 system("mv $tgz $tar"); 1794 system("mv $orgdir/$outputdir/$tgz $orgdir/$outputdir/$tar");
1714 guess_name_from_url($dir); 1795 guess_name_from_url($dir);
1715} 1796}
1716 1797
1717
1718# 1798#
1719# I really really hate the fact that meego deleted the -a option from tar. 1799# I really really hate the fact that meego deleted the -a option from tar.
1720# this is a step backwards in time that is just silly. 1800# this is a step backwards in time that is just silly.
1721# 1801#
1722 1802
1723 1803
1724system("cd $tmpdir; tar -jxf $orgdir/*\.tar\.bz2"); 1804system("cd $tmpdir; tar -jxf $orgdir/$outputdir/*\.tar\.bz2 &>/dev/null");
1725system("cd $tmpdir; tar -zxf $orgdir/*\.tar\.gz"); 1805system("cd $tmpdir; tar -zxf $orgdir/$outputdir/*\.tar\.gz &>/dev/null");
1726print "Parsing content ....\n"; 1806print "Parsing content ....\n";
1727my @dirs = <$tmpdir/*>; 1807my @dirs = <$tmpdir/*>;
1728foreach (@dirs) { 1808foreach (@dirs) {
@@ -1734,11 +1814,13 @@ $fulldir = $dir;
1734if ( -e "$dir/autogen.sh" ) { 1814if ( -e "$dir/autogen.sh" ) {
1735 $configure = "autogen"; 1815 $configure = "autogen";
1736 $uses_configure = 1; 1816 $uses_configure = 1;
1817 push(@inherits, "autotools");
1737} 1818}
1738if ( -e "$dir/BUILD-CMAKE" ) { 1819if ( -e "$dir/BUILD-CMAKE" ) {
1739 $configure = "cmake"; 1820 $configure = "cmake";
1740 push(@buildreqs, "cmake"); 1821 push(@buildreqs, "cmake");
1741 $uses_configure = 1; 1822 $uses_configure = 1;
1823 push(@inherits, "cmake");
1742} 1824}
1743 1825
1744if ( -e "$dir/configure" ) { 1826if ( -e "$dir/configure" ) {
@@ -1747,7 +1829,7 @@ if ( -e "$dir/configure" ) {
1747 1829
1748my @files = <$dir/configure.*>; 1830my @files = <$dir/configure.*>;
1749 1831
1750my $findoutput = `find $dir -name "configure.ac"`; 1832my $findoutput = `find $dir -name "configure.ac" 2>/dev/null`;
1751my @findlist = split(/\n/, $findoutput); 1833my @findlist = split(/\n/, $findoutput);
1752foreach (@findlist) { 1834foreach (@findlist) {
1753 push(@files, $_); 1835 push(@files, $_);
@@ -1756,7 +1838,7 @@ foreach (@files) {
1756 process_configure_ac("$_"); 1838 process_configure_ac("$_");
1757} 1839}
1758 1840
1759$findoutput = `find $dir -name "*.pro"`; 1841$findoutput = `find $dir -name "*.pro" 2>/dev/null`;
1760@findlist = split(/\n/, $findoutput); 1842@findlist = split(/\n/, $findoutput);
1761foreach (@findlist) { 1843foreach (@findlist) {
1762 process_qmake_pro("$_"); 1844 process_qmake_pro("$_");
@@ -1765,6 +1847,7 @@ foreach (@findlist) {
1765if (-e "$dir/$name.pro") { 1847if (-e "$dir/$name.pro") {
1766 $builder = "qmake"; 1848 $builder = "qmake";
1767 push_pkgconfig_buildreq("Qt"); 1849 push_pkgconfig_buildreq("Qt");
1850 push(@inherits, "qmake2");
1768} 1851}
1769 1852
1770 1853
@@ -1804,6 +1887,12 @@ foreach (@files) {
1804 1887
1805guess_description($dir); 1888guess_description($dir);
1806 1889
1890#
1891# Output of bbfile file
1892#
1893write_bbfile();
1894chdir($orgdir);
1895exit 0;
1807 1896
1808# 1897#
1809# Output of the yaml file 1898# Output of the yaml file