create-recipe 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071
  1. #!/usr/bin/perl -w
  2. # Copyright (C) 2012 Wind River Systems, Inc.
  3. #
  4. # Copyright (C) 2010 Intel Corporation
  5. #
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # As a special exception, you may create a larger work that contains
  20. # part or all of the autospectacle output and distribute that work
  21. # under terms of your choice.
  22. # Alternatively, if you modify or redistribute autospectacle itself,
  23. # you may (at your option) remove this special exception.
  24. #
  25. # This special exception was modeled after the bison exception
  26. # (as done by the Free Software Foundation in version 2.2 of Bison)
  27. #
  28. use File::Temp qw(tempdir);
  29. use File::Path qw(mkpath rmtree);
  30. use File::Spec ();
  31. use File::Basename qw(basename dirname);
  32. my $name = "";
  33. my $predef_version = "TO BE FILLED IN";
  34. my $version = $predef_version;
  35. my $pversion = $predef_version;
  36. my $description = "";
  37. my $summary = "";
  38. my $url = "";
  39. my $homepage = "";
  40. my @depends;
  41. my @rdepends;
  42. my @rawpythondeps;
  43. my $configure = "";
  44. my $localename = "";
  45. my @sources;
  46. my @mainfiles;
  47. my @patches;
  48. my $md5sum = "";
  49. my $sh256sum = "";
  50. my @inherits;
  51. my $printed_subpackages = 0;
  52. my $fulldir = "";
  53. my $builder = "";
  54. my $oscmode = 0;
  55. my $python = 0;
  56. my @banned_pkgconfig;
  57. my %failed_commands;
  58. my %failed_libs;
  59. my %failed_headers;
  60. ######################################################################
  61. #
  62. # License management
  63. #
  64. # We store the sha1sum of common COPYING files in an associative array
  65. # %licenses.
  66. #
  67. # For all matching sha1's in the tarball, we then push the result
  68. # in the @license array (which we'll dedupe at the time of printing).
  69. #
  70. my %licenses;
  71. my @license;
  72. my %lic_files;
  73. sub setup_licenses
  74. {
  75. $licenses{"06877624ea5c77efe3b7e39b0f909eda6e25a4ec"} = "GPLv2";
  76. $licenses{"075d599585584bb0e4b526f5c40cb6b17e0da35a"} = "GPLv2";
  77. $licenses{"10782dd732f42f49918c839e8a5e2894c508b079"} = "GPLv2";
  78. $licenses{"2d29c273fda30310211bbf6a24127d589be09b6c"} = "GPLv2";
  79. $licenses{"4df5d4b947cf4e63e675729dd3f168ba844483c7"} = "LGPLv2.1";
  80. $licenses{"503df7650052cf38efde55e85f0fe363e59b9739"} = "GPLv2";
  81. $licenses{"5405311284eab5ab51113f87c9bfac435c695bb9"} = "GPLv2";
  82. $licenses{"5fb362ef1680e635fe5fb212b55eef4db9ead48f"} = "LGPLv2";
  83. $licenses{"68c94ffc34f8ad2d7bfae3f5a6b996409211c1b1"} = "GPLv2";
  84. $licenses{"66c77efd1cf9c70d4f982ea59487b2eeb6338e26"} = "LGPLv2.1";
  85. $licenses{"74a8a6531a42e124df07ab5599aad63870fa0bd4"} = "GPLv2";
  86. $licenses{"8088b44375ef05202c0fca4e9e82d47591563609"} = "LGPLv2.1";
  87. $licenses{"8624bcdae55baeef00cd11d5dfcfa60f68710a02"} = "GPLv3";
  88. $licenses{"8e57ffebd0ed4417edc22e3f404ea3664d7fed27"} = "MIT";
  89. $licenses{"99b5245b4714b9b89e7584bfc88da64e2d315b81"} = "BSD";
  90. $licenses{"aba8d76d0af67d57da3c3c321caa59f3d242386b"} = "MPLv1.1";
  91. $licenses{"bf50bac24e7ec325dbb09c6b6c4dcc88a7d79e8f"} = "LGPLv2";
  92. $licenses{"caeb68c46fa36651acf592771d09de7937926bb3"} = "LGPLv2.1";
  93. $licenses{"dfac199a7539a404407098a2541b9482279f690d"} = "GPLv2";
  94. $licenses{"e60c2e780886f95df9c9ee36992b8edabec00bcc"} = "LGPLv2.1";
  95. $licenses{"c931aad3017d975b7f20666cde0953234a9efde3"} = "GPLv2";
  96. }
  97. sub guess_license_from_file {
  98. my ($copying) = @_;
  99. if (!-e $copying) {
  100. return;
  101. }
  102. my $sha1output = `sha1sum $copying`;
  103. $sha1output =~ /^([a-zA-Z0-9]*) /;
  104. my $sha1 = $1;
  105. chomp($sha1);
  106. #
  107. # if sha1 matches.. push there result
  108. #
  109. if (defined($licenses{$sha1})) {
  110. my $lic = $licenses{$sha1};
  111. push(@license, $lic);
  112. my $md5output = `md5sum $copying`;
  113. $md5output =~ /^([a-zA-Z0-9]*) /;
  114. my $md5 = $1;
  115. chomp($md5);
  116. $lic_files{$copying} = $md5
  117. }
  118. #
  119. # if file is found, and licence of python
  120. # package is already aquired, add file.
  121. #
  122. if ($python == 1 && @license != 0) {
  123. my $md5output = `md5sum $copying`;
  124. $md5output =~ /^([a-zA-Z0-9]*) /;
  125. my $md5 = $1;
  126. chomp($md5);
  127. $lic_files{$copying} = $md5
  128. }
  129. #
  130. # We also must make sure that the COPYING/etc files
  131. # end up in the main package as %doc..
  132. #
  133. $copying =~ s/$fulldir//g;
  134. $copying =~ s/^\///g;
  135. $copying = "\"\%doc " . $copying ."\"";
  136. push(@mainfiles, $copying);
  137. }
  138. sub print_license
  139. {
  140. my $count = @license;
  141. if ($count == 0) {
  142. print OUTFILE "License: TO BE FILLED IN\n";
  143. return;
  144. }
  145. # remove dupes
  146. undef %saw;
  147. @saw{@license} = ();
  148. @out = sort keys %saw;
  149. print OUTFILE "License : ";
  150. foreach (@out) {
  151. print OUTFILE "$_ ";
  152. }
  153. print OUTFILE "\n";
  154. }
  155. # end of license section
  156. #
  157. #######################################################################
  158. ######################################################################
  159. #
  160. # Package group management
  161. #
  162. # We set up an associative array of regexp patterns, where the content
  163. # of the array is the name of the group.
  164. #
  165. # These are "strings of regexps", which means one needs to escape
  166. # everything, and if you want the actual regexp to have a \,
  167. # it needs to be a \\ in this string.
  168. my %group_patterns;
  169. my @groups;
  170. my $group = "TO_BE/FILLED_IN";
  171. sub setup_group_rules
  172. {
  173. $group_patterns{"^\\/usr\\/lib\\/.*so"} = "System/Libraries";
  174. $group_patterns{"^\\/lib\\/.*so"} = "System/Libraries";
  175. $group_patterns{"^\\/bin\\/.*"} = "Applications/System";
  176. $group_patterns{"^\\/sbin\\/.*"} = "Applications/System";
  177. $group_patterns{"^\\/usr\\/sbin\\/.*"} = "Applications/System";
  178. }
  179. sub guess_group_from_file
  180. {
  181. my ($filename) = @_;
  182. while (($key,$value) = each %group_patterns) {
  183. if ($filename =~ /$key/) {
  184. push(@groups, $value);
  185. }
  186. }
  187. }
  188. # end of group section
  189. #
  190. ######################################################################
  191. ######################################################################
  192. #
  193. # Files and package section
  194. #
  195. # This section creates the %files section, but also decides which
  196. # subpackages (devel and/or doc) we need to have.
  197. #
  198. # We start out with the @allfiles array, which will contain all the
  199. # files installed by the %build phase of the package. The task is
  200. # to sort these into @mainfiles, @develfiles and @docfiles.
  201. # In addition, an attempt is made to compress the files list by
  202. # replacing full filenames with "*" patterns.
  203. #
  204. # For this we use a set of regexps from the @files_match array,
  205. # which are then used as index to three associative arrays:
  206. # %files_target : numerical index for which package the regexp
  207. # would place the file at hand.
  208. # 0 - main package
  209. # 1 - devel package
  210. # 2 - doc package
  211. # 99 - don't package this at all
  212. #
  213. # %files_from: regexp to match the file against for filename-wildcarding
  214. # %files_to : pattern to append to the ()'d part of %files_from to end up
  215. # with the filename-wildcard.
  216. my @allfiles;
  217. my @develfiles;
  218. my @docfiles;
  219. my @files_match;
  220. my %files_target;
  221. my %files_from;
  222. my %files_to;
  223. my $totaldocs = 0;
  224. sub add_files_rule
  225. {
  226. my ($match, $target, $from, $to) =@_;
  227. push(@files_match, $match);
  228. $files_target{"$match"} = $target;
  229. if (length($from) > 0) {
  230. $files_from{"$match"} = $from;
  231. }
  232. if (length($to) > 0) {
  233. $files_to{"$match"} = $to;
  234. }
  235. }
  236. sub setup_files_rules
  237. {
  238. #
  239. # Files for the Main package
  240. #
  241. add_files_rule("^\\/usr\\/lib\\/[a-z0-9A-Z\\_\\-\\.]+\\.so\\.", 0,
  242. "(\\/usr\\/lib\\/.*\\.so\\.).*", "\*");
  243. add_files_rule("^\\/usr\\/share\\/omf\\/", 0,
  244. "(\\/usr\\/share\\/omf\\/.*?\\/).*", "\*");
  245. #
  246. # Files for the Devel subpackage
  247. #
  248. add_files_rule("^\\/usr\\/share\\/gir-1\\.0\\/[a-z0-9A-Z\\_\\-\\.]+\\.gir\$", 1,
  249. "(\\/usr\\/share\\/gir-1\\.0\/).*", "\*\.gir");
  250. add_files_rule("^\\/usr\\/lib\\/girepository-1\\.0\\/[a-z0-9A-Z\\_\\-\\.]+\\.typelib\$", 1,
  251. "(\\/usr\\/lib\\/girepository-1\\.0\/).*", "\*\.typelib");
  252. add_files_rule("^\\/usr\\/include\\/[a-z0-9A-Z\\_\\-\\.]+\\.h\$", 1,
  253. "(\\/usr\\/include\/).*", "\*\.h");
  254. add_files_rule("^\\/usr\\/include\\/[a-z0-9A-Z\\_\\-\\.]+\\/.*?\\.h\$", 1,
  255. "(\\/usr\\/include\\/[a-z0-9A-Z\\_\\-\\.]+\\/.*?)[a-z0-9A-Z\\_\\-\\.]+\\.h", "\*\.h");
  256. add_files_rule("^\\/usr\\/lib\\/[a-z0-9A-Z\\_\\-\\.]+\\.so\$", 1,
  257. "(\\/usr\\/lib\\/).*\\.so\$", "\*.so");
  258. add_files_rule("^\\/usr\\/lib\\/pkgconfig\\/[a-z0-9A-Z\\_\\-\\.\+]+\\.pc\$", 1,
  259. "(\\/usr\\/lib\\/pkgconfig\\/).*\\.pc\$", "\*.pc");
  260. add_files_rule("^\\/usr\\/share\\/aclocal", 1, "", "");
  261. add_files_rule("^\\/usr\\/lib\\/qt4\\/mkspecs/", 1, "", "");
  262. #
  263. # Files for the documentation subpackage
  264. #
  265. add_files_rule("^\\/usr\\/share\\/gtk\-doc\\/html\\/[a-z0-9A-Z\\_\\-\\.]+\\/.\*", 2,
  266. "(\\/usr\\/share\\/gtk\-doc\\/html\\/[a-z0-9A-Z\\_\\-\\.]+\\/).\*", "\*");
  267. add_files_rule("^\\/usr\\/share\\/doc\\/[a-zA-Z0-9\-]*", 2,
  268. "(\\/usr\\/share\\/doc\\/[a-zA-Z0-9\-]+\\/).*", "\*");
  269. add_files_rule("^\\/usr\\/share\\/man\\/man[0-9]\\/[a-zA-Z0-9\-]*", 2,
  270. "(\\/usr\\/share\\/man\\/man[0-9]\\/[a-zA-Z0-9\-]+\\/).*", "\*");
  271. add_files_rule("^\\/usr\\/share\\/gnome\\/help\\/", 2,
  272. "(\\/usr\\/share\\/gnome\\/help\\/.*?\\/.*?\\/).*", "\*");
  273. #
  274. # Files to just not package at all (picked up by other things)
  275. #
  276. add_files_rule("^\\/usr\\/share\\/locale", 99, "", "");
  277. # compiled python things will get auto cleaned by rpm
  278. # add_files_rule("\.pyo\$", 99, "", "");
  279. # add_files_rule("\.pyc\$", 99, "", "");
  280. }
  281. sub apply_files_rules
  282. {
  283. my $filenumber = @allfiles;
  284. if ($filenumber == 0) {
  285. return;
  286. }
  287. while (@allfiles > 0) {
  288. my $filename = $allfiles[0];
  289. my $destname = $filename;
  290. my $handled = 0;
  291. #
  292. # while we're here, try to guess what group our package is
  293. #
  294. guess_group_from_file($filename);
  295. foreach (@files_match) {
  296. my $match = $_;
  297. if ($filename =~ /$match/) {
  298. #
  299. # First try to see if we can turn the full filename into a
  300. # wildcard based filename
  301. #
  302. if (defined($files_from{$match}) && defined($files_to{$match})) {
  303. $from = $files_from{$match};
  304. $to = $files_to{$match};
  305. $destname =~ s/$from/$1$to/;
  306. # print "changing $filename to $destname\n";
  307. }
  308. # devel package
  309. if ($files_target{$match} == 1) {
  310. $handled = 1;
  311. push(@develfiles, $destname);
  312. }
  313. # doc rules.. also prepend %doc
  314. if ($files_target{$match} == 2) {
  315. $handled = 1;
  316. $destname = "\"%doc " . $destname . "\"";
  317. push(@docfiles, $destname);
  318. $totaldocs = $totaldocs + 1;
  319. }
  320. # don't package
  321. if ($files_target{$match} == 99) {
  322. $handled = 1;
  323. if ($filename =~ /\/usr\/share\/locale\/.*?\/LC_MESSAGES\/(.*)\.mo/) {
  324. $localename = $1;
  325. }
  326. }
  327. }
  328. }
  329. #
  330. # if the destination name contains our package version,
  331. # use %version instead for future maintenance
  332. #
  333. $destname =~ s/$version/\%\{version\}/g;
  334. if ($handled == 0) {
  335. push(@mainfiles, $destname);
  336. }
  337. shift(@allfiles);
  338. }
  339. #
  340. # Now.. if we have less than 5 documentation files, just stick them in the main package
  341. #
  342. $filenumber = @docfiles;
  343. if ($filenumber <= 5) {
  344. while (@docfiles > 0) {
  345. my $filename = $docfiles[0];
  346. push(@mainfiles, $filename);
  347. shift(@docfiles);
  348. }
  349. }
  350. }
  351. sub print_files
  352. {
  353. my $count = @mainfiles;
  354. if ($count == 0) {
  355. return;
  356. }
  357. # remove dupes
  358. undef %saw;
  359. @saw{@mainfiles} = ();
  360. @out = sort keys %saw;
  361. print OUTFILE "Files:\n";
  362. foreach (@out) {
  363. print OUTFILE " - $_\n";
  364. }
  365. }
  366. sub print_devel
  367. {
  368. my $count = @develfiles;
  369. if ($count == 0) {
  370. return;
  371. }
  372. print OUTFILE "SubPackages:\n";
  373. $printed_subpackages = 1;
  374. print OUTFILE " - Name: devel\n";
  375. print OUTFILE " Summary: Development components for the $name package\n";
  376. print OUTFILE " Group: Development/Libraries\n";
  377. print OUTFILE " Description:\n";
  378. print OUTFILE " - Development files for the $name package\n";
  379. # remove dupes
  380. undef %saw;
  381. @saw{@develfiles} = ();
  382. @out = sort keys %saw;
  383. print OUTFILE " Files:\n";
  384. foreach (@out) {
  385. print OUTFILE " - $_\n";
  386. }
  387. }
  388. sub print_doc
  389. {
  390. my $count = @docfiles;
  391. if ($count == 0) {
  392. return;
  393. }
  394. if ($printed_subpackages == 0) {
  395. print OUTFILE "SubPackages:\n";
  396. $printed_subpackages = 1;
  397. }
  398. print OUTFILE " - Name: docs\n";
  399. print OUTFILE " Summary: Documentation components for the $name package\n";
  400. print OUTFILE " Group: Documentation\n";
  401. # remove dupes
  402. undef %saw;
  403. @saw{@docfiles} = ();
  404. @out = sort keys %saw;
  405. print OUTFILE " Files:\n";
  406. foreach (@out) {
  407. print OUTFILE " - $_\n";
  408. }
  409. }
  410. # end of %files section
  411. #
  412. ######################################################################
  413. ######################################################################
  414. #
  415. # What we can learn from configure.ac/configure
  416. #
  417. # - pkgconfig requirements
  418. # - regular build requirements
  419. # - package name / version
  420. sub setup_pkgconfig_ban
  421. {
  422. push(@banned_pkgconfig, "^dnl\$");
  423. push(@banned_pkgconfig, "^hal\$"); # we don't have nor want HAL
  424. push(@banned_pkgconfig, "tslib-0.0"); # we don't want tslib-0.0 (legacy touchscreen interface)
  425. push(@banned_pkgconfig, "intel-gen4asm");
  426. push(@banned_pkgconfig, "^xp\$"); # xprint - deprecated and not in meego
  427. push(@banned_pkgconfig, "^directfb\$"); # we use X, not directfb
  428. push(@banned_pkgconfig, "^gtkmm-2.4\$"); # we use X, not directfb
  429. push(@banned_pkgconfig, "^evil\$");
  430. push(@banned_pkgconfig, "^directfb");
  431. push(@banned_pkgconfig, "^sdl ");
  432. }
  433. sub setup_failed_commands
  434. {
  435. $failed_commands{"doxygen"} = "doxygen";
  436. $failed_commands{"scrollkeeper-config"} = "rarian-compat";
  437. $failed_commands{"dot"} = "graphviz";
  438. $failed_commands{"flex"} = "flex";
  439. $failed_commands{"lex"} = "flex";
  440. $failed_commands{"freetype-config"} = "freetype-devel";
  441. $failed_commands{"makeinfo"} = "texinfo";
  442. $failed_commands{"desktop-file-install"} = "desktop-file-utils";
  443. $failed_commands{"deflateBound in -lz"} = "zlib-devel";
  444. $failed_commands{"gconftool-2"} = "GConf-dbus";
  445. $failed_commands{"jpeglib.h"} = "libjpeg-devel";
  446. $failed_commands{"expat.h"} = "expat-devel";
  447. $failed_commands{"bison"} = "bison";
  448. $failed_commands{"msgfmt"} = "gettext";
  449. $failed_commands{"curl-config"} = "libcurl-devel";
  450. $failed_commands{"doxygen"} = "doxygen";
  451. $failed_commands{"X"} = "pkgconfig(x11)";
  452. $failed_commands{"gawk"} = "gawk";
  453. $failed_commands{"xbkcomp"} = "xkbcomp";
  454. $failed_commands{"Vorbis"} = "libvorbis-devel";
  455. # checking Expat 1.95.x... no
  456. $failed_commands{"Expat 1.95.x"} = "expat-devel";
  457. $failed_commands{"xml2-config path"} = "libxml2-devel";
  458. $failed_libs{"-lz"} = "zlib-devel";
  459. $failed_libs{"-lncursesw"} = "ncurses-devel";
  460. $failed_libs{"-ltiff"} = "libtiff-devel";
  461. $failed_libs{"-lasound"} = "alsa-lib-devel";
  462. $failed_libs{"Curses"} = "ncurses-devel";
  463. $failed_headers{"X11/extensions/randr.h"} = "xrandr";
  464. $failed_headers{"X11/Xlib.h"} = "x11";
  465. $failed_headers{"X11/extensions/XShm.h"} = "xext";
  466. $failed_headers{"X11/extensions/shape.h"} = "xext";
  467. $failed_headers{"ncurses.h"} = "ncursesw";
  468. $failed_headers{"curses.h"} = "ncursesw";
  469. $failed_headers{"pci/pci.h"} = "libpci";
  470. $failed_headers{"xf86.h"} = "xorg-server";
  471. $failed_headers{"sqlite.h"} = "sqlite3";
  472. $failed_headers{"X11/extensions/XIproto.h"} = "xi";
  473. $failed_headers{"QElapsedTimer"} = "";
  474. }
  475. my @package_configs;
  476. my @buildreqs;
  477. my $uses_configure = 0;
  478. sub push_pkgconfig_buildreq
  479. {
  480. my ($pr) = @_;
  481. $pr =~ s/\s+//g;
  482. # remove collateral ] ) etc damage in the string
  483. $pr =~ s/\"//g;
  484. $pr =~ s/\)//g;
  485. $pr =~ s/\]//g;
  486. $pr =~ s/\[//g;
  487. # first, undo the space packing
  488. $pr =~ s/\>\=/ \>\= /g;
  489. $pr =~ s/\<\=/ \<\= /g;
  490. $pr =~ s/\<1.1.1/ /g;
  491. # don't show configure variables, we can't deal with them
  492. if ($pr =~ /^\$/) {
  493. return;
  494. }
  495. if ($pr =~ /AC_SUBST/) {
  496. return;
  497. }
  498. # process banned pkgconfig options for things that we don't
  499. # have or don't want.
  500. # remore versions that are macros or strings, not numbers
  501. $pr =~ s/\s\>\= \$.*//g;
  502. $pr =~ s/\s\>\= [a-zA-Z]+.*//g;
  503. # don't show configure variables, we can't deal with them
  504. if ($pr =~ /\$/) {
  505. return;
  506. }
  507. foreach (@banned_pkgconfig) {
  508. my $ban = $_;
  509. if ($pr =~ /$ban/) {
  510. return;
  511. }
  512. }
  513. push(@package_configs, $pr);
  514. }
  515. #
  516. # detect cases where we require both a generic pkgconfig, and a version specific
  517. # case
  518. #
  519. sub uniquify_pkgconfig
  520. {
  521. # first remove real dupes
  522. undef %saw;
  523. @saw{@package_configs} = ();
  524. @out = sort keys %saw;
  525. my $count = 0;
  526. while ($count < @out) {
  527. my $entry = $out[$count];
  528. foreach(@out) {
  529. my $compare = $_;
  530. if ($entry eq $compare) {
  531. next;
  532. }
  533. $compare =~ s/ \>\=.*//g;
  534. if ($entry eq $compare) {
  535. $out[$count] = "";
  536. }
  537. }
  538. $count = $count + 1;
  539. }
  540. @package_configs = @out;
  541. }
  542. sub process_configure_ac
  543. {
  544. my ($filename) = @_;
  545. my $line = "";
  546. my $depth = 0;
  547. my $keepgoing = 1;
  548. my $buffer = "";
  549. if (!-e $filename) {
  550. return;
  551. }
  552. $uses_configure = 1;
  553. open(CONFIGURE, "$filename") || die "Couldn't open $filename\n";
  554. seek(CONFIGURE, 0,0) or die "seek : $!";
  555. while ($keepgoing && !eof(CONFIGURE)) {
  556. $buffer = getc(CONFIGURE);
  557. if ($buffer eq "(") {
  558. $depth = $depth + 1;
  559. }
  560. if ($buffer eq ")" && $depth > 0) {
  561. $depth = $depth - 1;
  562. }
  563. if (!($buffer eq "\n")) {
  564. $line = $line . $buffer;
  565. }
  566. if (!($buffer eq "\n") || $depth > 0) {
  567. redo unless eof(CONFIGURE);
  568. }
  569. if ($line =~ /PKG_CHECK_MODULES\((.*)\)/) {
  570. my $match = $1;
  571. $match =~ s/\s+/ /g;
  572. $match =~ s/, /,/g;
  573. my @pkgs = split(/,/, $match);
  574. my $pkg;
  575. if (defined($pkgs[1])) {
  576. $pkg = $pkgs[1];
  577. } else {
  578. next;
  579. }
  580. if ($pkg =~ /\[(.*)\]/) {
  581. $pkg = $1;
  582. }
  583. $pkg =~ s/\s+/ /g;
  584. # deal with versioned pkgconfig's by removing the spaces around >= 's
  585. $pkg =~ s/\>\=\s/\>\=/g;
  586. $pkg =~ s/\s\>\=/\>\=/g;
  587. $pkg =~ s/\=\s/\=/g;
  588. $pkg =~ s/\s\=/\=/g;
  589. $pkg =~ s/\<\=\s/\<\=/g;
  590. $pkg =~ s/\<\s/\</g;
  591. $pkg =~ s/\s\<\=/\<\=/g;
  592. $pkg =~ s/\s\</\</g;
  593. @words = split(/ /, $pkg);
  594. foreach(@words) {
  595. push_pkgconfig_buildreq($_);
  596. }
  597. }
  598. if ($line =~ /PKG_CHECK_EXISTS\((.*)\)/) {
  599. my $match = $1;
  600. $match =~ s/\s+/ /g;
  601. $match =~ s/, /,/g;
  602. my @pkgs = split(/,/, $match);
  603. my $pkg = $pkgs[0];
  604. if ($pkg =~ /\[(.*)\]/) {
  605. $pkg = $1;
  606. }
  607. $pkg =~ s/\s+/ /g;
  608. # deal with versioned pkgconfig's by removing the spaces around >= 's
  609. $pkg =~ s/\>\=\s/\>\=/g;
  610. $pkg =~ s/\s\>\=/\>\=/g;
  611. $pkg =~ s/\<\=\s/\<\=/g;
  612. $pkg =~ s/\<\s/\</g;
  613. $pkg =~ s/\s\<\=/\<\=/g;
  614. $pkg =~ s/\s\</\</g;
  615. $pkg =~ s/\=\s/\=/g;
  616. $pkg =~ s/\s\=/\=/g;
  617. @words = split(/ /, $pkg);
  618. foreach(@words) {
  619. push_pkgconfig_buildreq($_);
  620. }
  621. }
  622. if ($line =~ /XDT_CHECK_PACKAGE\(.*?,.*?\[(.*?)\].*\)/) {
  623. my $pkg = $1;
  624. $pkg =~ s/\s+/ /g;
  625. # deal with versioned pkgconfig's by removing the spaces around >= 's
  626. $pkg =~ s/\>\=\s/\>\=/g;
  627. $pkg =~ s/\s\>\=/\>\=/g;
  628. $pkg =~ s/\=\s/\=/g;
  629. $pkg =~ s/\s\=/\=/g;
  630. @words = split(/ /, $pkg);
  631. foreach(@words) {
  632. push_pkgconfig_buildreq($_);
  633. }
  634. }
  635. if ($line =~ /XDT_CHECK_OPTIONAL_PACKAGE\(.*?,.*?\[(.*?)\].*\)/) {
  636. my $pkg = $1;
  637. $pkg =~ s/\s+/ /g;
  638. # deal with versioned pkgconfig's by removing the spaces around >= 's
  639. $pkg =~ s/\>\=\s/\>\=/g;
  640. $pkg =~ s/\s\>\=/\>\=/g;
  641. $pkg =~ s/\=\s/\=/g;
  642. $pkg =~ s/\s\=/\=/g;
  643. @words = split(/ /, $pkg);
  644. foreach(@words) {
  645. push_pkgconfig_buildreq($_);
  646. }
  647. }
  648. if ($line =~ /AC_CHECK_LIB\(\[expat\]/) {
  649. push(@buildreqs, "expat-devel");
  650. }
  651. if ($line =~ /AC_CHECK_FUNC\(\[tgetent\]/) {
  652. push(@buildreqs, "ncurses-devel");
  653. }
  654. if ($line =~ /_PROG_INTLTOOL/) {
  655. push(@buildreqs, "intltool");
  656. }
  657. if ($line =~ /GETTEXT_PACKAGE/) {
  658. push(@buildreqs, "gettext");
  659. }
  660. if ($line =~ /GTK_DOC_CHECK/) {
  661. push_pkgconfig_buildreq("gtk-doc");
  662. }
  663. if ($line =~ /GNOME_DOC_INIT/) {
  664. push(@buildreqs, "gnome-doc-utils");
  665. }
  666. if ($line =~ /AM_GLIB_GNU_GETTEXT/) {
  667. push(@buildreqs, "gettext");
  668. }
  669. if ($line =~ /AC_INIT\((.*)\)/) {
  670. my $match = $1;
  671. $match =~ s/\s+/ /g;
  672. @acinit = split(/,/, $match);
  673. # $name = $acinit[0];
  674. if ($name =~ /\[(.*)\]/) {
  675. # $name = $1;
  676. }
  677. if (defined($acinit[3])) {
  678. # $name = $acinit[3];
  679. if ($name =~ /\[(.*)\]/) {
  680. # $name = $1;
  681. }
  682. }
  683. if (defined($acinit[1]) and $version eq $predef_version) {
  684. my $ver = $acinit[1];
  685. $ver =~ s/\[//g;
  686. $ver =~ s/\]//g;
  687. if ($ver =~ /\$/){} else {
  688. $version = $ver;
  689. $version =~ s/\s+//g;
  690. }
  691. }
  692. }
  693. if ($line =~ /AM_INIT_AUTOMAKE\((.*)\)/) {
  694. my $match = $1;
  695. $match =~ s/\s+/ /g;
  696. @acinit = split(/,/, $match);
  697. # $name = $acinit[0];
  698. if ($name =~ /\[(.*)\]/) {
  699. # $name = $1;
  700. }
  701. if (defined($acinit[3])) {
  702. # $name = $acinit[3];
  703. if ($name =~ /\[(.*)\]/) {
  704. # $name = $1;
  705. }
  706. }
  707. if (defined($acinit[1]) and $version eq $predef_version) {
  708. my $ver = $acinit[1];
  709. $ver =~ s/\[//g;
  710. $ver =~ s/\]//g;
  711. if ($ver =~ /\$/){} else {
  712. $version = $ver;
  713. $version =~ s/\s+//g;
  714. }
  715. }
  716. }
  717. $line = "";
  718. }
  719. close(CONFIGURE);
  720. }
  721. sub process_qmake_pro
  722. {
  723. my ($filename) = @_;
  724. my $line = "";
  725. my $depth = 0;
  726. my $keepgoing = 1;
  727. my $buffer = "";
  728. my $prev_char = "";
  729. if (!-e $filename) {
  730. return;
  731. }
  732. open(CONFIGURE, "$filename") || die "Couldn't open $filename\n";
  733. seek(CONFIGURE, 0,0) or die "seek : $!";
  734. while ($keepgoing && !eof(CONFIGURE)) {
  735. $buffer = getc(CONFIGURE);
  736. if ($buffer eq "(") {
  737. $depth = $depth + 1;
  738. }
  739. if ($buffer eq ")" && $depth > 0) {
  740. $depth = $depth - 1;
  741. }
  742. if (!($buffer eq "\n")) {
  743. $line = $line . $buffer;
  744. }
  745. if (!($buffer eq "\n") || ($prev_char eq "\\") ) {
  746. $prev_char = $buffer;
  747. redo unless eof(CONFIGURE);
  748. }
  749. $prev_char = " ";
  750. if ($line =~ /PKGCONFIG.*?\=(.*)/) {
  751. my $l = $1;
  752. my @pkgs;
  753. $l =~ s/\\//g;
  754. $l =~ s/\s/ /g;
  755. @pkgs = split(/ /, $l);
  756. foreach (@pkgs) {
  757. if (length($_)>1) {
  758. push_pkgconfig_buildreq($_);
  759. }
  760. }
  761. }
  762. $line = "";
  763. }
  764. close(CONFIGURE);
  765. }
  766. #
  767. # We also check configure if it exists, it's nice for some things
  768. # because various configure.ac macros have been expanded for us already.
  769. #
  770. sub process_configure
  771. {
  772. my ($filename) = @_;
  773. my $line = "";
  774. my $depth = 0;
  775. my $keepgoing = 1;
  776. if (!-e $filename) {
  777. return;
  778. }
  779. $uses_configure = 1;
  780. open(CONFIGURE, "$filename") || die "Couldn't open $filename\n";
  781. seek(CONFIGURE, 0,0) or die "seek : $!";
  782. while ($keepgoing && !eof(CONFIGURE)) {
  783. $buffer = getc(CONFIGURE);
  784. if ($buffer eq "(") {
  785. $depth = $depth + 1;
  786. }
  787. if ($buffer eq ")" && $depth > 0) {
  788. $depth = $depth - 1;
  789. }
  790. if (!($buffer eq "\n")) {
  791. $line = $line . $buffer;
  792. }
  793. if (!($buffer eq "\n") || $depth > 0) {
  794. redo unless eof(CONFIGURE);
  795. }
  796. if ($line =~ /^PACKAGE_NAME=\'(.*?)\'/) {
  797. $name = $1;
  798. }
  799. if ($line =~ /^PACKAGE_TARNAME=\'(.*?)\'/) {
  800. $name = $1;
  801. }
  802. if ($line =~ /^PACKAGE_VERSION=\'(.*?)\'/) {
  803. $version = $1;
  804. $version =~ s/\s+//g;
  805. }
  806. if ($line =~ /^PACKAGE_URL=\'(.*?)\'/) {
  807. if (length($1) > 2) {
  808. $url = $1;
  809. }
  810. }
  811. $line = "";
  812. }
  813. close(CONFIGURE);
  814. }
  815. sub print_pkgconfig
  816. {
  817. my $count = @package_configs;
  818. if ($count == 0) {
  819. return;
  820. }
  821. uniquify_pkgconfig();
  822. print OUTFILE "PkgConfigBR:\n";
  823. foreach (@out) {
  824. $line = $_;
  825. $line =~ s/^\s+//g;
  826. if (length($line) > 1) {
  827. print OUTFILE " - $line\n";
  828. }
  829. }
  830. }
  831. sub print_buildreq
  832. {
  833. my $count = @buildreqs;
  834. if ($count == 0) {
  835. return;
  836. }
  837. # remove dupes
  838. undef %saw;
  839. @saw{@buildreqs} = ();
  840. @out = sort keys %saw;
  841. print OUTFILE "PkgBR:\n";
  842. foreach (@out) {
  843. print OUTFILE " - $_\n";
  844. }
  845. }
  846. # end of configure section
  847. #
  848. ######################################################################
  849. ######################################################################
  850. #
  851. # Guessing the Description and Summary for a package
  852. #
  853. # We'll look at various sources of information for this:
  854. # - spec files in the package
  855. # - debain files in the package
  856. # - DOAP files in the package
  857. # - pkgconfig files in the package
  858. # - the README file in the package
  859. # - freshmeat.net online
  860. #
  861. sub guess_description_from_spec {
  862. my ($specfile) = @_;
  863. my $state = 0;
  864. my $cummul = "";
  865. open(SPEC, $specfile);
  866. while (<SPEC>) {
  867. my $line = $_;
  868. if ($state == 1 && $line =~ /^\%/) {
  869. $state = 2;
  870. }
  871. if ($state == 1) {
  872. $cummul = $cummul . $line;
  873. }
  874. if ($state==0 && $line =~ /\%description/) {
  875. $state = 1;
  876. }
  877. if ($line =~ /Summary:\s*(.*)/ && length($summary) < 2) {
  878. $summary = $1;
  879. }
  880. if ($line =~ /URL:\s*(.*)/ && length($url) < 2) {
  881. $url = $1;
  882. }
  883. }
  884. close(SPEC);
  885. if (length($cummul) > 4) {
  886. $description = $cummul;
  887. }
  888. }
  889. #
  890. # DOAP is a project to create an XML/RDF vocabulary to describe software projects, and in particular open source.
  891. # so if someone ships a .doap file... we can learn from it.
  892. #
  893. sub guess_description_from_doap {
  894. my ($doapfile) = @_;
  895. open(DOAP, $doapfile);
  896. while (<DOAP>) {
  897. my $line = $_;
  898. # <shortdesc xml:lang="en">Virtual filesystem implementation for gio</shortdesc>
  899. if ($line =~ /\<shortdesc .*?\>(.*)\<\/shortdesc\>/) {
  900. $summary = $1;
  901. }
  902. if ($line =~ /\<homepage .*?resource=\"(.*)\"\s*\/>/) {
  903. $url = $1;
  904. }
  905. }
  906. close(DOAP);
  907. }
  908. #
  909. # Debian control files have some interesting fields we can glean information
  910. # from as well.
  911. #
  912. sub guess_description_from_debian_control {
  913. my ($file) = @_;
  914. my $state = 0;
  915. my $cummul = "";
  916. $file = $file . "/debian/control";
  917. open(FILE, $file) || return;
  918. while (<FILE>) {
  919. my $line = $_;
  920. if ($state == 1 && length($line) < 2) {
  921. $state = 2;
  922. }
  923. if ($state == 1) {
  924. $cummul = $cummul . $line;
  925. }
  926. if ($state==0 && $line =~ /\Description: (.*)/) {
  927. $state = 1;
  928. $cummul = $1;
  929. }
  930. }
  931. close(FILE);
  932. if (length($cummul) > 4) {
  933. $description = $cummul;
  934. }
  935. }
  936. #
  937. # the pkgconfig files have often a one line description
  938. # of the software... good for Summary
  939. #
  940. sub guess_description_from_pkgconfig {
  941. my ($file) = @_;
  942. open(FILE, $file);
  943. while (<FILE>) {
  944. my $line = $_;
  945. if ($line =~ /Description:\s*(.*)/ && length($summary) < 2) {
  946. $summary = $1;
  947. }
  948. }
  949. close(FILE);
  950. }
  951. #
  952. # Freshmeat can provide us with a good one paragraph description
  953. # of the software..
  954. #
  955. sub guess_description_from_freshmeat {
  956. my ($tarname) = @_;
  957. my $cummul = "";
  958. my $state = 0;
  959. open(HTML, "curl -s http://freshmeat.net/projects/$tarname |");
  960. while (<HTML>) {
  961. my $line = $_;
  962. if ($state == 1) {
  963. $cummul = $cummul . $line;
  964. }
  965. if ($state == 0 && $line =~ /\<div class\=\"project-detail\"\>/) {
  966. $state = 1;
  967. }
  968. if ($state == 1 && $line =~/\<\/p\>/) {
  969. $state = 2;
  970. }
  971. }
  972. close(HTML);
  973. $cummul =~ s/\<p\>//g;
  974. $cummul =~ s/\r//g;
  975. $cummul =~ s/\<\/p\>//g;
  976. $cummul =~ s/^\s*//g;
  977. if (length($cummul)>10) {
  978. $description = $cummul;
  979. }
  980. }
  981. #
  982. # If all else fails, just take the first paragraph of the
  983. # readme file
  984. #
  985. sub guess_description_from_readme {
  986. my ($file) = @_;
  987. my $state = 0;
  988. my $cummul = "";
  989. open(FILE, $file);
  990. while (<FILE>) {
  991. my $line = $_;
  992. if ($state == 1 && $line =~ /^\n/ && length($cummul) > 80) {
  993. $state = 2;
  994. }
  995. if ($state == 0 && length($line)>1) {
  996. $state = 1;
  997. }
  998. if ($state == 1) {
  999. $cummul = $cummul . $line;
  1000. }
  1001. if ($line =~ /(http\:\/\/.*$name.*\.org)/) {
  1002. my $u = $1;
  1003. if ($u =~ /bug/ || length($url) > 1) {
  1004. } else {
  1005. $url = $u;
  1006. }
  1007. }
  1008. }
  1009. close(FILE);
  1010. if (length($cummul) > 4 && length($description)<3) {
  1011. $description = $cummul;
  1012. }
  1013. }
  1014. #
  1015. # Glue all the guesses together
  1016. #
  1017. sub guess_description {
  1018. my ($directory) = @_;
  1019. @files = <$directory/README*>;
  1020. foreach (@files) {
  1021. guess_description_from_readme($_);
  1022. }
  1023. if (length($name)>2) {
  1024. guess_description_from_freshmeat($name);
  1025. }
  1026. @files = <$directory/*.spec*>;
  1027. foreach (@files) {
  1028. guess_description_from_spec($_);
  1029. }
  1030. guess_description_from_debian_control($directory);
  1031. $name =~ s/ //g;
  1032. @files = <$directory/$name.pc*>;
  1033. foreach (@files) {
  1034. guess_description_from_pkgconfig($_);
  1035. }
  1036. @files = <$directory/*.pc.*>;
  1037. foreach (@files) {
  1038. guess_description_from_pkgconfig($_);
  1039. }
  1040. @files = <$directory/*.pc>;
  1041. foreach (@files) {
  1042. guess_description_from_pkgconfig($_);
  1043. }
  1044. @files = <$directory/*.doap>;
  1045. foreach (@files) {
  1046. guess_description_from_doap($_);
  1047. }
  1048. if (length($summary) < 2) {
  1049. $summary = $description;
  1050. $summary =~ s/\n/ /g;
  1051. $summary =~ s/\s+/ /g;
  1052. if ($summary =~ /(.*?)\./) {
  1053. $summary = $1;
  1054. }
  1055. }
  1056. }
  1057. # end of Description / Summary section
  1058. #
  1059. ######################################################################
  1060. #
  1061. # Build the package, and wait for rpm to complain about unpackaged
  1062. # files.... which we then use as basis for our %files section
  1063. #
  1064. sub guess_files_from_rpmbuild {
  1065. my $infiles = 0;
  1066. open(OUTPUTF, "rpmbuild --nodeps --define \"\%_sourcedir $orgdir \" -ba $name.spec 2>&1 |");
  1067. while (<OUTPUTF>) {
  1068. my $line2 = $_;
  1069. if ($infiles == 1 && $line2 =~ /RPM build errors/) {
  1070. $infiles = 2;
  1071. }
  1072. if ($infiles == 1 && $line2 =~ /^Building/) {
  1073. $infiles = 2;
  1074. }
  1075. if ($infiles == 1) {
  1076. $line2 =~ s/\s*//g;
  1077. push(@allfiles, $line2);
  1078. }
  1079. if ($line2 =~ / Installed \(but unpackaged\) file\(s\) found\:/) {
  1080. $infiles = 1;
  1081. }
  1082. }
  1083. close(OUTPUTF);
  1084. if (@allfiles == 0) {
  1085. print "Build failed ... stopping here.\n";
  1086. exit(0);
  1087. }
  1088. }
  1089. sub guess_files_from_oscbuild {
  1090. my $infiles = 0;
  1091. my $restart = 0;
  1092. my $mustrestart = 0;
  1093. my $rcount = 0;
  1094. my $done_python = 0;
  1095. system("osc addremove &> /dev/null");
  1096. system("osc ci -m \"Initial import by autospectacle\" &> /dev/null");
  1097. retry:
  1098. if ($restart > 0) {
  1099. write_yaml();
  1100. print "Restarting the build\n";
  1101. }
  1102. $restart = 0;
  1103. $infiles = 0;
  1104. $mustrestart = 0;
  1105. open(OUTPUTF, "osc build --no-verify $name.spec 2>&1 |");
  1106. while (<OUTPUTF>) {
  1107. my $line2 = $_;
  1108. # print "line is $line2\n";
  1109. if ($infiles == 1 && $line2 =~ /RPM build errors/) {
  1110. $infiles = 2;
  1111. }
  1112. if ($infiles == 1 && $line2 =~ /^Building/) {
  1113. $infiles = 2;
  1114. }
  1115. if ($infiles == 1) {
  1116. $line2 =~ s/\s*//g;
  1117. push(@allfiles, $line2);
  1118. }
  1119. if ($line2 =~ /No package \'(.*)\' found/) {
  1120. push_pkgconfig_buildreq("$1");
  1121. $restart = $restart + 1;
  1122. print " Adding pkgconfig($1) requirement\n";
  1123. }
  1124. if ($line2 =~ /Package requirements \((.*?)\) were not met/) {
  1125. $pkg = $1;
  1126. # deal with versioned pkgconfig's by removing the spaces around >= 's
  1127. $pkg =~ s/\>\=\s/\>\=/g;
  1128. $pkg =~ s/\s\>\=/\>\=/g;
  1129. $pkg =~ s/\=\s/\=/g;
  1130. $pkg =~ s/\s\=/\=/g;
  1131. my @req = split(/ /,$pkg);
  1132. foreach (@req) {
  1133. push_pkgconfig_buildreq("$_");
  1134. $restart = $restart + 1;
  1135. print " Adding pkgconfig($_) requirement\n";
  1136. }
  1137. }
  1138. if ($line2 =~ /which: no qmake/) {
  1139. $restart += 1;
  1140. push_pkgconfig_buildreq("Qt");
  1141. print " Adding Qt requirement\n";
  1142. }
  1143. if ($line2 =~ /Cannot find development files for any supported version of libnl/) {
  1144. $restart += 1;
  1145. push_pkgconfig_buildreq("libnl-1");
  1146. print " Adding libnl requirement\n";
  1147. }
  1148. if ($line2 =~ /<http:\/\/www.cmake.org>/) {
  1149. $restart += 1;
  1150. push(@buildreqs, "cmake");
  1151. print " Adding cmake requirement\n";
  1152. }
  1153. if ($line2 =~ /checking for (.*?)\.\.\. not_found/ || $line2 =~ /checking for (.*?)\.\.\. no/ || $line2 =~ /checking (.*?)\.\.\. no/) {
  1154. $pkg = $1;
  1155. while (($key,$value) = each %failed_commands) {
  1156. if ($pkg eq $key) {
  1157. push(@buildreqs, $value);
  1158. print " Adding $value requirement\n";
  1159. $restart += $restart + 1;
  1160. $mustrestart = 1;
  1161. }
  1162. }
  1163. }
  1164. if ($line2 =~ /checking for [a-zA-Z0-9\_]+ in (.*?)\.\.\. no/) {
  1165. $pkg = $1;
  1166. while (($key,$value) = each %failed_libs) {
  1167. if ($pkg eq $key) {
  1168. push(@buildreqs, $value);
  1169. print " Adding $value requirement\n";
  1170. $restart += $restart + 1;
  1171. $mustrestart = 1;
  1172. }
  1173. }
  1174. }
  1175. if ($line2 =~ /-- Could NOT find ([a-zA-Z0-9]+)/) {
  1176. $pkg = $1;
  1177. while (($key,$value) = each %failed_libs) {
  1178. if ($pkg eq $key) {
  1179. push(@buildreqs, $value);
  1180. print " Adding $value requirement\n";
  1181. $restart += $restart + 1;
  1182. $mustrestart = 1;
  1183. }
  1184. }
  1185. }
  1186. if ($line2 =~ /fatal error\: (.*)\: No such file or directory/) {
  1187. $pkg = $1;
  1188. while (($key,$value) = each %failed_headers) {
  1189. if ($pkg eq $key) {
  1190. push_pkgconfig_buildreq($value);
  1191. print " Adding $value requirement\n";
  1192. $restart += $restart + 1;
  1193. }
  1194. }
  1195. }
  1196. if ($line2 =~ /checking for UDEV\.\.\. no/) {
  1197. print " Adding pkgconfig(udev) requirement\n";
  1198. push_pkgconfig_buildreq("udev");
  1199. }
  1200. if ($line2 =~ /checking for Apache .* module support/) {
  1201. print " Adding pkgconfig(httpd-devel) requirement\n";
  1202. push(@buildreqs, "httpd-devel");
  1203. if ($rcount < 3) {
  1204. $restart = $restart + 1;
  1205. }
  1206. }
  1207. if ($line2 =~ /([a-zA-Z0-9\-\_]*)\: command not found/i) {
  1208. my $cmd = $1;
  1209. my $found = 0;
  1210. while (($key,$value) = each %failed_commands) {
  1211. if ($cmd eq $key) {
  1212. push(@buildreqs, $value);
  1213. print " Adding $value requirement\n";
  1214. $restart += $restart + 1;
  1215. $mustrestart = 1;
  1216. $found = 1;
  1217. }
  1218. }
  1219. if ($found < 1) {
  1220. print " Command $cmd not found!\n";
  1221. }
  1222. }
  1223. if ($line2 =~ /checking for.*in -ljpeg... no/) {
  1224. push(@buildreqs, "libjpeg-devel");
  1225. print " Adding libjpeg-devel requirement\n";
  1226. $restart = $restart + 1;
  1227. }
  1228. if ($line2 =~ /fatal error\: zlib\.h\: No such file or directory/) {
  1229. push(@buildreqs, "zlib-devel");
  1230. print " Adding zlib-devel requirement\n";
  1231. $restart = $restart + 1;
  1232. }
  1233. if ($line2 =~ /error\: xml2-config not found/) {
  1234. push_pkgconfig_buildreq("libxml-2.0");
  1235. print " Adding libxml2-devel requirement\n";
  1236. $restart = $restart + 1;
  1237. }
  1238. if ($line2 =~ /checking \"location of ncurses\.h file\"/) {
  1239. push(@buildreqs, "ncurses-devel");
  1240. print " Adding ncurses-devel requirement\n";
  1241. $restart = $restart + 1;
  1242. }
  1243. if (($line2 =~ / \/usr\/include\/python2\.6$/ || $line2 =~ / to compile python extensions/) && $done_python == 0) {
  1244. push(@buildreqs, "python-devel");
  1245. print " Adding python-devel requirement\n";
  1246. $restart = $restart + 1;
  1247. $done_python = 1;
  1248. }
  1249. if ($line2 =~ /error: must install xorg-macros 1.6/) {
  1250. push_pkgconfig_buildreq("xorg-macros");
  1251. print " Adding xorg-macros requirement\n";
  1252. $restart = $restart + 1;
  1253. }
  1254. if ($line2 =~ /installing .*?.gmo as [a-zA-Z0-9\-\.\/\_]+?\/([a-zA-Z0-9\-\_\.]+)\.mo$/) {
  1255. my $loc = $1;
  1256. if ($loc eq $localename) {} else {
  1257. print " Changing localename from $localename to $loc\n";
  1258. $localename = $loc;
  1259. $restart = $restart + 1;
  1260. }
  1261. }
  1262. if ($infiles == 0 && $line2 =~ / Installed \(but unpackaged\) file\(s\) found\:/) {
  1263. $infiles = 1;
  1264. }
  1265. }
  1266. close(OUTPUTF);
  1267. if (@allfiles == 0 || $mustrestart > 0) {
  1268. if ($restart >= 1)
  1269. {
  1270. $rcount = $rcount + 1;
  1271. if ($rcount < 10) {
  1272. goto retry;
  1273. }
  1274. }
  1275. print "Build failed ... stopping here.\n";
  1276. exit(0);
  1277. }
  1278. }
  1279. sub process_rpmlint {
  1280. my $infiles = 0;
  1281. if ($oscmode == 0) {
  1282. return;
  1283. }
  1284. print "Verifying package ....\n";
  1285. system("osc addremove &> /dev/null");
  1286. system("osc ci -m \"Final import by autospectacle\" &> /dev/null");
  1287. open(OUTPUTF, "osc build --no-verify $name.spec 2>&1 |");
  1288. while (<OUTPUTF>) {
  1289. my $line2 = $_;
  1290. # print "line is $line2\n";
  1291. if ($infiles == 1 && $line2 =~ /RPM build errors/) {
  1292. $infiles = 2;
  1293. }
  1294. if ($infiles == 1 && $line2 =~ /^Building/) {
  1295. $infiles = 2;
  1296. }
  1297. if ($infiles == 1) {
  1298. $line2 =~ s/\s*//g;
  1299. push(@allfiles, $line2);
  1300. }
  1301. if ($infiles == 0 && $line2 =~ / Installed \(but unpackaged\) file\(s\) found\:/) {
  1302. $infiles = 1;
  1303. }
  1304. }
  1305. close(OUTPUTF);
  1306. }
  1307. sub guess_name_from_url {
  1308. my ($bigurl) = @_;
  1309. @spliturl = split(/\//, $bigurl);
  1310. while (@spliturl > 1) {
  1311. shift(@spliturl);
  1312. }
  1313. my $tarfile = $spliturl[0];
  1314. # Ensure correct name resolution from .zip&tgz archives
  1315. $tarfile =~ s/\.zip/\.tar/;
  1316. $tarfile =~ s/\.tgz/\.tar/;
  1317. $tarfile =~ s/\_/\-/g;
  1318. if ($tarfile =~ /(.*?)\-([0-9\.\-\~]+.*?)\.tar/) {
  1319. $name = $1;
  1320. $version = $2;
  1321. $version =~ s/\-/\_/g;
  1322. }
  1323. }
  1324. ############################################################################
  1325. #
  1326. # Output functions
  1327. #
  1328. sub print_name_and_description
  1329. {
  1330. my @lines;
  1331. print OUTFILE "Name : $name\n";
  1332. print OUTFILE "Version : $version\n";
  1333. print OUTFILE "Release : 1\n";
  1334. # remove dupes
  1335. undef %saw;
  1336. @saw{@groups} = ();
  1337. @out = sort keys %saw;
  1338. if (@out == 1) {
  1339. foreach (@out) {
  1340. print OUTFILE "Group : $_\n";
  1341. }
  1342. } else {
  1343. print OUTFILE "Group : $group\n";
  1344. }
  1345. #
  1346. # Work around spectacle bug
  1347. $summary =~ s/\:\s/ /g;
  1348. $summary =~ s/^([a-z])/\u$1/ig;
  1349. $summary =~ s/\@//g;
  1350. $summary = substr($summary, 0, 79);
  1351. $summary =~ s/\.^//g;
  1352. if (length($summary) < 1) {
  1353. $summary = "TO BE FILLED IN";
  1354. }
  1355. #
  1356. print OUTFILE "Summary : $summary\n";
  1357. print OUTFILE "Description: |\n";
  1358. $description =~ s/&quot;/\"/g;
  1359. $description =~ s/\@//g;
  1360. @lines = split(/\n/, $description);
  1361. foreach (@lines) {
  1362. print OUTFILE " $_\n";
  1363. }
  1364. if (length($url)>1) {
  1365. print OUTFILE "URL : $url\n";
  1366. }
  1367. # remove dupes
  1368. undef %saw;
  1369. @saw{@sources} = ();
  1370. @out = sort keys %saw;
  1371. print OUTFILE "Sources : \n";
  1372. foreach (@out) {
  1373. $source = $_;
  1374. $source =~ s/$version/\%\{version\}/g;
  1375. print OUTFILE " - $source\n";
  1376. }
  1377. if (@patches > 0) {
  1378. print OUTFILE "Patches: \n";
  1379. foreach (@patches) {
  1380. my $patch = $_;
  1381. print OUTFILE " - $patch\n";
  1382. }
  1383. }
  1384. print OUTFILE "\n";
  1385. if (length($configure)>2) {
  1386. print OUTFILE "Configure : $configure\n";
  1387. }
  1388. if (length($localename) > 2) {
  1389. print OUTFILE "LocaleName : $localename\n";
  1390. }
  1391. if (length($builder) > 2) {
  1392. print OUTFILE "Builder : $builder\n";
  1393. }
  1394. }
  1395. sub write_makefile
  1396. {
  1397. open(MAKEFILE, ">Makefile");
  1398. print MAKEFILE "PKG_NAME := $name\n";
  1399. print MAKEFILE "SPECFILE = \$(addsuffix .spec, \$(PKG_NAME))\n";
  1400. print MAKEFILE "YAMLFILE = \$(addsuffix .yaml, \$(PKG_NAME))\n";
  1401. print MAKEFILE "\n";
  1402. print MAKEFILE "include /usr/share/packaging-tools/Makefile.common\n";
  1403. close(MAKEFILE);
  1404. }
  1405. sub write_changelog
  1406. {
  1407. open(CHANGELOG, ">$name.changes");
  1408. $date = ` date +"%a %b %d %Y"`;
  1409. chomp($date);
  1410. print CHANGELOG "* $date - Autospectacle <autospectacle\@meego.com> - $version\n";
  1411. print CHANGELOG "- Initial automated packaging\n";
  1412. close(CHANGELOG);
  1413. }
  1414. sub write_yaml
  1415. {
  1416. open(OUTFILE, ">$name.yaml");
  1417. print_name_and_description();
  1418. print_license();
  1419. print_pkgconfig();
  1420. print_buildreq();
  1421. print_files();
  1422. print_devel();
  1423. print_doc();
  1424. close(OUTFILE);
  1425. write_makefile();
  1426. write_changelog();
  1427. system("rm $name.spec 2>/dev/null");
  1428. system("specify &> /dev/null");
  1429. if ($oscmode > 0) {
  1430. system("osc addremove");
  1431. system("osc ci -m \"Import by autospectacle\" &> /dev/null");
  1432. }
  1433. }
  1434. sub write_bbfile
  1435. {
  1436. my $curdir = `pwd`;
  1437. chomp($curdir);
  1438. if ($python == 1) {
  1439. $name =~ s/python-//;
  1440. $name = lc("python-" . $name);
  1441. }
  1442. if (-e "$curdir/${name}_$version.bb") {
  1443. print "Wont overwrite file:";
  1444. print "$curdir/${name}_$version.bb, exiting\n";
  1445. return;
  1446. }
  1447. open(BBFILE, ">${name}_$version.bb");
  1448. print BBFILE "SUMMARY = \"$summary\"\n";
  1449. print BBFILE "DESCRIPTION = \"$description\"\n";
  1450. print BBFILE "HOMEPAGE = \"$homepage\"\n";
  1451. if ($python == 1) {
  1452. print BBFILE "SRCNAME = \"$summary\"\n";
  1453. }
  1454. print BBFILE "LICENSE = \"@license\"\n";
  1455. print BBFILE "LIC_FILES_CHKSUM = \"";
  1456. foreach (keys %lic_files) {
  1457. print BBFILE "file://" . basename($_) . ";md5=$lic_files{$_} \\\n";
  1458. }
  1459. print BBFILE "\"\n\n";
  1460. if (@license <= 0) {
  1461. print "Can NOT get license from package source files.\n";
  1462. print "Please update the LICENSE and LIC_FILES_CHKSUM manually.\n";
  1463. }
  1464. if (@buildreqs > 0) {
  1465. my %saw;
  1466. my @out = grep(!$saw{$_}++,@buildreqs);
  1467. print BBFILE "DEPENDS = \"@out\"\n\n";
  1468. };
  1469. if (@rdepends > 0) {
  1470. print BBFILE "RDEPENDS_\$\{PN\} += \"";
  1471. foreach (@rdepends) {
  1472. print BBFILE "$_ \\\n\t";
  1473. }
  1474. print BBFILE "\"\n";
  1475. }
  1476. if ($python == 1) {
  1477. print BBFILE "PV = \"$pversion\"\n\n";
  1478. }
  1479. print BBFILE "SRC_URI = \"";
  1480. foreach (@sources) {
  1481. print BBFILE "$_ \\\n";
  1482. }
  1483. print BBFILE "\"\n\n";
  1484. print BBFILE "SRC_URI[md5sum] = \"$md5sum\"\n";
  1485. print BBFILE "SRC_URI[sha256sum] = \"$sha256sum\"\n\n";
  1486. if ($python == 1) {
  1487. print BBFILE "S = \"\${WORKDIR}/\${SRCNAME}-\${PV}\"\n";
  1488. }
  1489. if (@inherits) {
  1490. print BBFILE "inherit ";
  1491. foreach (@inherits) {
  1492. print BBFILE "$_ ";
  1493. }
  1494. print BBFILE "\n";
  1495. }
  1496. close(BBFILE);
  1497. print "Create bb file: $curdir/${name}_$version.bb\n";
  1498. }
  1499. sub calculate_sums
  1500. {
  1501. @_ = basename $dir;
  1502. my $md5output = `md5sum @_`;
  1503. $md5output =~ /^([a-zA-Z0-9]*) /;
  1504. $md5sum = $1;
  1505. chomp($md5sum);
  1506. my $sha256output = `sha256sum @_`;
  1507. $sha256output =~ /^([a-zA-Z0-9]*) /;
  1508. $sha256sum = $1;
  1509. chomp($sha256sum);
  1510. }
  1511. ############################################################################
  1512. #
  1513. # Main program
  1514. #
  1515. if ( @ARGV < 1 || $ARGV[0] eq "--help" ) {
  1516. print "Usage: $0 [-r] <url-of-source-tarballs>\n";
  1517. exit(1);
  1518. }
  1519. # Recusive parsing of python dependencies using
  1520. # easy_install
  1521. my $recurse_python = 0;
  1522. if ($ARGV[0] eq "-r") {
  1523. $recurse_python = 1;
  1524. shift @ARGV;
  1525. }
  1526. if (@ARGV > 1) {
  1527. my $i = 1;
  1528. while ($i < @ARGV) {
  1529. my $patch = $ARGV[$i];
  1530. print "Adding patch $patch\n";
  1531. push(@patches, $patch);
  1532. $i++;
  1533. }
  1534. }
  1535. setup_licenses();
  1536. setup_files_rules();
  1537. setup_group_rules();
  1538. setup_pkgconfig_ban();
  1539. setup_failed_commands();
  1540. if (-e ".osc/_packages") {
  1541. $oscmode = 1;
  1542. }
  1543. my $tmpdir = tempdir();
  1544. $dir = $ARGV[0];
  1545. guess_name_from_url($dir);
  1546. push(@sources, $dir);
  1547. #system("cd $tmpdir; curl -s -O $dir");
  1548. $orgdir = `pwd`;
  1549. chomp($orgdir);
  1550. my $outputdir = $name;
  1551. if (! $name) {
  1552. $outputdir = basename $dir;
  1553. }
  1554. mkpath($outputdir);
  1555. chdir($outputdir);
  1556. print "Downloading package: $dir\n";
  1557. system("wget --quiet $dir") == 0 or die "Download $dir failed.";
  1558. calculate_sums($outputdir);
  1559. print "Unpacking to : $tmpdir\n";
  1560. my @tgzfiles = <$orgdir/$outputdir/*.tgz>;
  1561. foreach (@tgzfiles) {
  1562. my $tgz = basename $_;
  1563. my $tar = $tgz;
  1564. $tar =~ s/tgz/tar\.gz/g;
  1565. $dir =~ s/tgz/tar\.gz/g;
  1566. system("mv $orgdir/$outputdir/$tgz $orgdir/$outputdir/$tar");
  1567. guess_name_from_url($dir);
  1568. }
  1569. #
  1570. # I really really hate the fact that meego deleted the -a option from tar.
  1571. # this is a step backwards in time that is just silly.
  1572. #
  1573. my @sourcetars = <$orgdir/$outputdir/*\.tar\.bz2 $orgdir/$outputdir/*\.tar\.gz $orgdir/$outputdir/*\.zip>;
  1574. if (scalar(@sourcetars) == 0) {
  1575. print "Can NOT find source tarball. Exiting...\n";
  1576. exit (1);
  1577. }
  1578. if (defined($sourcetars[0]) and $sourcetars[0] =~ ".*\.tar\.bz2") {
  1579. system("cd $tmpdir; tar -jxf $sourcetars[0] &>/dev/null");
  1580. } elsif (defined($sourcetars[0]) and $sourcetars[0] =~ ".*\.tar\.gz") {
  1581. system("cd $tmpdir; tar -zxf $sourcetars[0] &>/dev/null");
  1582. } elsif (defined($sourcetars[0]) and $sourcetars[0] =~ ".*\.zip") {
  1583. system("cd $tmpdir; unzip $sourcetars[0] &>/dev/null");
  1584. }
  1585. print "Parsing content ....\n";
  1586. my @dirs = <$tmpdir/*>;
  1587. foreach (@dirs) {
  1588. $dir = $_;
  1589. }
  1590. $fulldir = $dir;
  1591. if ( -e "$dir/setup.py" ) {
  1592. $python = 1;
  1593. $tmp_stools = `grep -r setuptools $dir/setup.py`;
  1594. if (length($tmp_stools) > 2) {
  1595. push(@inherits, "setuptools");
  1596. } else {
  1597. push(@inherits, "distutils");
  1598. }
  1599. $templic = `cd $dir; python setup.py --license;`;
  1600. $templic =~ s/[\r\n]+//g;
  1601. push(@license, $templic);
  1602. $summary = `cd $dir; python setup.py --name`;
  1603. $summary =~ s/[\r\n]+//g;
  1604. $description = `cd $dir; python setup.py --description`;
  1605. $description =~ s/[\r\n]+//g;
  1606. $homepage = `cd $dir; python setup.py --url`;
  1607. $homepage =~ s/[\r\n]+//g;
  1608. $pversion = `cd $dir; python setup.py -V`;
  1609. $pversion =~ s/[\r\n]+//g;
  1610. # $findoutput = `cd $dir; python setup.py --requires`;
  1611. # if (length($findoutput) < 3) {
  1612. $findoutput = `find $dir/*.egg-info/ -name "requires.txt" 2>/dev/null`;
  1613. # }
  1614. @findlist = split(/\n/, $findoutput);
  1615. foreach (@findlist) {
  1616. push(@rawpythondeps, `sed -e '/^\$/d' "$_" | sed '/^\\[/d'`);
  1617. chomp(@rawpythondeps);
  1618. push(@rdepends, `sed -e 's/python-//g' "$_" | sed '/^\\[/d'`);
  1619. chomp(@rdepends);
  1620. if ($recurse_python == 1) {
  1621. foreach (@rawpythondeps) {
  1622. my $ptempdir = tempdir();
  1623. $purl = `easy_install -aeb $ptempdir "$_" 2>/dev/null`;
  1624. $purl =~ s/#.*//g;
  1625. @purllist = $purl =~ m/Downloading (.*:\/\/.*\n)/g;
  1626. chomp(@purllist);
  1627. # Remove empty lines
  1628. @purllist = grep(/\S/, @purllist);
  1629. # Recursively create recipes for dependencies
  1630. if (@purllist != 0) {
  1631. if (fork) {
  1632. # Parent, do nothing
  1633. } else {
  1634. # child, execute
  1635. print "Recursively creating recipe for: $purllist[0]\n";
  1636. exec("cd .. ; create-recipe -r $purllist[0]");
  1637. }
  1638. }
  1639. }
  1640. wait;
  1641. }
  1642. foreach $item (@rdepends) {
  1643. @pyclean = split(/(\=|\<|\>).*/, $item);
  1644. if (defined($pyclean[0])) {
  1645. $item = lc("python-" . $pyclean[0]);
  1646. }
  1647. }
  1648. }
  1649. }
  1650. if ( -e "$dir/autogen.sh" ) {
  1651. $configure = "autogen";
  1652. $uses_configure = 1;
  1653. push(@inherits, "autotools");
  1654. }
  1655. if ( -e "$dir/BUILD-CMAKE" ) {
  1656. $configure = "cmake";
  1657. push(@buildreqs, "cmake");
  1658. $uses_configure = 1;
  1659. push(@inherits, "cmake");
  1660. }
  1661. if ( -e "$dir/configure" ) {
  1662. $configure = "";
  1663. }
  1664. my @files = <$dir/configure\.*>;
  1665. my $findoutput = `find $dir -name "configure.ac" 2>/dev/null`;
  1666. my @findlist = split(/\n/, $findoutput);
  1667. foreach (@findlist) {
  1668. push(@files, $_);
  1669. }
  1670. foreach (@files) {
  1671. process_configure_ac("$_");
  1672. }
  1673. $findoutput = `find $dir -name "*.pro" 2>/dev/null`;
  1674. @findlist = split(/\n/, $findoutput);
  1675. foreach (@findlist) {
  1676. process_qmake_pro("$_");
  1677. }
  1678. if (-e "$dir/$name.pro") {
  1679. $builder = "qmake";
  1680. push_pkgconfig_buildreq("Qt");
  1681. push(@inherits, "qmake2");
  1682. }
  1683. #
  1684. # This is a good place to generate configure.in
  1685. #
  1686. if (length($configure) > 2) {
  1687. if ($configure eq "autogen") {
  1688. system("cd $dir ; ./autogen.sh &> /dev/null");
  1689. }
  1690. }
  1691. @files = <$dir/configure>;
  1692. foreach (@files) {
  1693. process_configure("$_");
  1694. }
  1695. if ($uses_configure == 0) {
  1696. $configure = "none";
  1697. }
  1698. @files = <$dir/docs/license.txt>;
  1699. foreach (@files) {
  1700. guess_license_from_file("$_");
  1701. }
  1702. @files = <$dir/COPY*>;
  1703. foreach (@files) {
  1704. guess_license_from_file("$_");
  1705. }
  1706. @files = <$dir/LICENSE*>;
  1707. foreach (@files) {
  1708. guess_license_from_file("$_");
  1709. }
  1710. @files = <$dir/GPL*>;
  1711. foreach (@files) {
  1712. guess_license_from_file("$_");
  1713. }
  1714. if ($python != 1) {
  1715. guess_description($dir);
  1716. }
  1717. #
  1718. # Output of bbfile file
  1719. #
  1720. write_bbfile();
  1721. chdir($orgdir);
  1722. exit 0;
  1723. #
  1724. # Output of the yaml file
  1725. #
  1726. if ($oscmode == 1) {
  1727. print "Creating OBS project $name ...\n";
  1728. system("osc mkpac $name &> /dev/null");
  1729. system("mkdir $name &> /dev/null");
  1730. chdir($name);
  1731. system("mv ../$name*\.tar\.* .");
  1732. }
  1733. write_yaml();
  1734. print "Building package ....\n";
  1735. if ($oscmode == 0) {
  1736. guess_files_from_rpmbuild();
  1737. } else {
  1738. guess_files_from_oscbuild();
  1739. }
  1740. apply_files_rules();
  1741. $printed_subpackages = 0;
  1742. write_yaml();
  1743. process_rpmlint();
  1744. print "Spectacle creation complete.\n";