diff options
-rwxr-xr-x | scripts/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 @@ | |||
29 | use File::Temp qw(tempdir); | 31 | use File::Temp qw(tempdir); |
30 | use File::Path qw(mkpath rmtree); | 32 | use File::Path qw(mkpath rmtree); |
31 | use File::Spec (); | 33 | use File::Spec (); |
34 | use File::Basename qw(basename dirname); | ||
32 | 35 | ||
33 | 36 | ||
34 | my $name = ""; | 37 | my $name = ""; |
@@ -42,6 +45,10 @@ my @sources; | |||
42 | my @mainfiles; | 45 | my @mainfiles; |
43 | my @patches; | 46 | my @patches; |
44 | 47 | ||
48 | my $md5sum = ""; | ||
49 | my $sh256sum = ""; | ||
50 | my @inherits; | ||
51 | |||
45 | my $printed_subpackages = 0; | 52 | my $printed_subpackages = 0; |
46 | my $fulldir = ""; | 53 | my $fulldir = ""; |
47 | 54 | ||
@@ -70,6 +77,7 @@ my %failed_headers; | |||
70 | 77 | ||
71 | my %licenses; | 78 | my %licenses; |
72 | my @license; | 79 | my @license; |
80 | my %lic_files; | ||
73 | 81 | ||
74 | sub setup_licenses | 82 | sub 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 | ||
1676 | sub 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 | |||
1723 | sub 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]; | |||
1696 | guess_name_from_url($dir); | 1769 | guess_name_from_url($dir); |
1697 | push(@sources, $dir); | 1770 | push(@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`; |
1702 | chomp($orgdir); | 1774 | chomp($orgdir); |
1775 | my $outputdir = $name; | ||
1776 | if (! $name) { | ||
1777 | $outputdir = basename $dir; | ||
1778 | } | ||
1779 | mkpath($outputdir); | ||
1780 | chdir($outputdir); | ||
1703 | print "Downloading package: $dir\n"; | 1781 | print "Downloading package: $dir\n"; |
1704 | system("wget --quiet $dir"); | 1782 | system("wget --quiet $dir") == 0 or die "Download $dir failed."; |
1783 | |||
1784 | calculate_sums($outputdir); | ||
1785 | |||
1705 | print "Unpacking to : $tmpdir\n"; | 1786 | print "Unpacking to : $tmpdir\n"; |
1706 | 1787 | ||
1707 | my @tgzfiles = <$orgdir/*.tgz>; | 1788 | my @tgzfiles = <$orgdir/$outputdir/*.tgz>; |
1708 | foreach (@tgzfiles) { | 1789 | foreach (@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 | ||
1724 | system("cd $tmpdir; tar -jxf $orgdir/*\.tar\.bz2"); | 1804 | system("cd $tmpdir; tar -jxf $orgdir/$outputdir/*\.tar\.bz2 &>/dev/null"); |
1725 | system("cd $tmpdir; tar -zxf $orgdir/*\.tar\.gz"); | 1805 | system("cd $tmpdir; tar -zxf $orgdir/$outputdir/*\.tar\.gz &>/dev/null"); |
1726 | print "Parsing content ....\n"; | 1806 | print "Parsing content ....\n"; |
1727 | my @dirs = <$tmpdir/*>; | 1807 | my @dirs = <$tmpdir/*>; |
1728 | foreach (@dirs) { | 1808 | foreach (@dirs) { |
@@ -1734,11 +1814,13 @@ $fulldir = $dir; | |||
1734 | if ( -e "$dir/autogen.sh" ) { | 1814 | if ( -e "$dir/autogen.sh" ) { |
1735 | $configure = "autogen"; | 1815 | $configure = "autogen"; |
1736 | $uses_configure = 1; | 1816 | $uses_configure = 1; |
1817 | push(@inherits, "autotools"); | ||
1737 | } | 1818 | } |
1738 | if ( -e "$dir/BUILD-CMAKE" ) { | 1819 | if ( -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 | ||
1744 | if ( -e "$dir/configure" ) { | 1826 | if ( -e "$dir/configure" ) { |
@@ -1747,7 +1829,7 @@ if ( -e "$dir/configure" ) { | |||
1747 | 1829 | ||
1748 | my @files = <$dir/configure.*>; | 1830 | my @files = <$dir/configure.*>; |
1749 | 1831 | ||
1750 | my $findoutput = `find $dir -name "configure.ac"`; | 1832 | my $findoutput = `find $dir -name "configure.ac" 2>/dev/null`; |
1751 | my @findlist = split(/\n/, $findoutput); | 1833 | my @findlist = split(/\n/, $findoutput); |
1752 | foreach (@findlist) { | 1834 | foreach (@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); |
1761 | foreach (@findlist) { | 1843 | foreach (@findlist) { |
1762 | process_qmake_pro("$_"); | 1844 | process_qmake_pro("$_"); |
@@ -1765,6 +1847,7 @@ foreach (@findlist) { | |||
1765 | if (-e "$dir/$name.pro") { | 1847 | if (-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 | ||
1805 | guess_description($dir); | 1888 | guess_description($dir); |
1806 | 1889 | ||
1890 | # | ||
1891 | # Output of bbfile file | ||
1892 | # | ||
1893 | write_bbfile(); | ||
1894 | chdir($orgdir); | ||
1895 | exit 0; | ||
1807 | 1896 | ||
1808 | # | 1897 | # |
1809 | # Output of the yaml file | 1898 | # Output of the yaml file |