Changeset 136
- Timestamp:
- 11/07/07 15:17:21 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r135 r136 73 73 ); 74 74 my $topdir = "/usr/src/debian"; 75 my $buildroot = "%{_tmppath}/%{name}-%{version}-%{release}.root".int(rand(99998)+1); 75 #my $specglobals{buildroot} = "%{_tmppath}/%{name}-%{version}-%{release}.root".int(rand(99998)+1); 76 $specglobals{buildroot} = ''; 76 77 77 78 # "Constants" … … 569 570 if (/^\%{echo:(.+)}/) { 570 571 my $output = expandmacros($1, 'gp'); 571 print "$output \n";572 print "$output"; 572 573 } 573 574 … … 862 863 $pkgdata{main}{packager} = $1; 863 864 } elsif (/^buildroot:\s*(.+)/i) { 864 $ buildroot= $1;865 $specglobals{buildroot} = $1; 865 866 } elsif (/^source0?:\s*(.+)/i) { 866 867 $pkgdata{main}{source} = $1; … … 914 915 $cleanscript = expandmacros($cleanscript,'gp'); 915 916 916 $ buildroot= $cmdbuildroot if $cmdbuildroot;917 $ buildroot = expandmacros($buildroot,'gp');917 $specglobals{buildroot} = $cmdbuildroot if $cmdbuildroot; 918 $specglobals{buildroot} = expandmacros($specglobals{buildroot},'gp'); 918 919 919 920 close SPECFILE; … … 1009 1010 # done here cuz I don't grok shell well 1010 1011 # should probably error-check all kinds of things. <g> 1011 if (opendir MANROOT, "$ buildroot/usr/share/man") {1012 if (opendir MANROOT, "$specglobals{buildroot}/usr/share/man") { 1012 1013 my @mansects = readdir MANROOT; 1013 1014 closedir MANROOT; 1014 1015 foreach my $mandir (@mansects) { 1015 1016 next if $mandir !~ /^man/; 1016 opendir MANPAGES, "$ buildroot/usr/share/man/$mandir";1017 opendir MANPAGES, "$specglobals{buildroot}/usr/share/man/$mandir"; 1017 1018 my @pagelist = readdir MANPAGES; 1018 1019 closedir MANPAGES; # Slightly safer to to this; no accidental recursion. O_o 1019 1020 foreach my $manpage (@pagelist) { 1020 $manpage = "$ buildroot/usr/share/man/$mandir/$manpage";1021 $manpage = "$specglobals{buildroot}/usr/share/man/$mandir/$manpage"; 1021 1022 if ( -f $manpage) { 1022 1023 if ($manpage =~ /^(.+)\.(?:Z|gz|bz2)\n?$/) { … … 1041 1042 1042 1043 ## binpackage() 1043 # Creates the binary .deb package from the installed tree in $ buildroot.1044 # Creates the binary .deb package from the installed tree in $specglobals{buildroot}. 1044 1045 # Writes and executes a shell script to do so. 1045 1046 # Creates miscellaneous files required by dpkg-deb to actually build the package file. … … 1063 1064 1064 1065 # Gotta do this first, otherwise we don't have a place to move files from %files 1065 mkdir "$ buildroot/$pkg";1066 mkdir "$specglobals{buildroot}/$pkg"; 1066 1067 1067 1068 # Eliminate any lingering % macros … … 1075 1076 if ($pkgfile =~ m|/usr/share/man/man|) { 1076 1077 # need to check to see if manpage is gzipped 1077 if (-e "$ buildroot$pkgfile") {1078 if (-e "$specglobals{buildroot}$pkgfile") { 1078 1079 if ($pkgfile !~ m|\.gz$|) { 1079 qx { gzip $ buildroot$pkgfile };1080 qx { gzip $specglobals{buildroot}$pkgfile }; 1080 1081 $pkgfile .= ".gz"; 1081 1082 } … … 1085 1086 } else { 1086 1087 $pkgfile =~ s/\.gz$//; 1087 qx { gzip $ buildroot$pkgfile };1088 qx { gzip $specglobals{buildroot}$pkgfile }; 1088 1089 $pkgfile .= ".gz"; 1089 1090 } … … 1092 1093 1093 1094 my ($fpath,$fname) = ($pkgfile =~ m|(.+?/?)?([^/]+/?)$|); # We don't need $fname now, but we might. 1094 qx { mkdir -p $ buildroot/$pkg$fpath }1095 qx { mkdir -p $specglobals{buildroot}/$pkg$fpath } 1095 1096 if $fpath && $fpath ne ''; 1096 qx { mv $ buildroot$pkgfile $buildroot/$pkg$fpath };1097 qx { mv $specglobals{buildroot}$pkgfile $specglobals{buildroot}/$pkg$fpath }; 1097 1098 } 1098 1099 … … 1100 1101 # comma and space here (if needed) in case there were "Requires" specified 1101 1102 # in the spec file - those would precede these. 1102 $pkgdata{$pkg}{requires} .= getreqs("$ buildroot/$pkg") if ! $NoAutoReq;1103 $pkgdata{$pkg}{requires} .= getreqs("$specglobals{buildroot}/$pkg") if ! $NoAutoReq; 1103 1104 1104 1105 # magic needed to properly version dependencies... … … 1154 1155 1155 1156 # Gotta do this next, otherwise the control file has nowhere to go. >:( 1156 mkdir "$ buildroot/$pkg/DEBIAN";1157 mkdir "$specglobals{buildroot}/$pkg/DEBIAN"; 1157 1158 1158 1159 # Hack the filename for the package into a Debian-tool-compatible format. GRRRRRR!!!!! … … 1165 1166 or die $!; 1166 1167 print DEBSCRIPT $scriptletbase; 1167 print DEBSCRIPT "fakeroot dpkg-deb -b $ buildroot/$pkg $topdir/DEBS/$pkgdata{$pkg}{arch}/".1168 print DEBSCRIPT "fakeroot dpkg-deb -b $specglobals{buildroot}/$pkg $topdir/DEBS/$pkgdata{$pkg}{arch}/". 1168 1169 "$pkgdata{$pkg}{name}_". 1169 1170 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : ''). … … 1189 1190 $control .= "$pkgdata{$pkg}{desc}\n"; 1190 1191 1191 open CONTROL, ">$ buildroot/$pkg/DEBIAN/control";1192 open CONTROL, ">$specglobals{buildroot}/$pkg/DEBIAN/control"; 1192 1193 print CONTROL $control; 1193 1194 close CONTROL; … … 1196 1197 # in so dpkg-deb can tag them. 1197 1198 if ($pkgdata{$pkg}{conffiles}) { 1198 open CONFLIST, ">$ buildroot/$pkg/DEBIAN/conffiles";1199 open CONFLIST, ">$specglobals{buildroot}/$pkg/DEBIAN/conffiles"; 1199 1200 foreach my $conffile (@{$pkgdata{$pkg}{conflist}}) { 1200 1201 $conffile = expandmacros($conffile, 'g'); 1201 my @tmp = glob "$ buildroot/$pkg/$conffile";1202 my @tmp = glob "$specglobals{buildroot}/$pkg/$conffile"; 1202 1203 foreach (@tmp) { 1203 s|$ buildroot/$pkg/||g; # nrgl. gotta be a better way to do this...1204 s|$specglobals{buildroot}/$pkg/||g; # nrgl. gotta be a better way to do this... 1204 1205 s/\s+/\n/g; # Not gonna support spaces in filenames. Ewww. 1205 1206 print CONFLIST "$_\n"; … … 1212 1213 if ($pkgdata{$pkg}{'pre'}) { 1213 1214 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'pre'},'gp'); 1214 open PREINST, ">$ buildroot/$pkg/DEBIAN/preinst";1215 open PREINST, ">$specglobals{buildroot}/$pkg/DEBIAN/preinst"; 1215 1216 print PREINST "#!/bin/sh\nset -e\n\n"; 1216 1217 print PREINST $pkgdata{$pkg}{'pre'}; 1217 1218 close PREINST; 1218 chmod 0755, "$ buildroot/$pkg/DEBIAN/preinst";1219 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/preinst"; 1219 1220 } 1220 1221 if ($pkgdata{$pkg}{'post'}) { 1221 1222 $pkgdata{$pkg}{'post'} = expandmacros($pkgdata{$pkg}{'post'},'gp'); 1222 open POSTINST, ">$ buildroot/$pkg/DEBIAN/postinst";1223 open POSTINST, ">$specglobals{buildroot}/$pkg/DEBIAN/postinst"; 1223 1224 print POSTINST "#!/bin/sh\nset -e\n\n"; 1224 1225 print POSTINST $pkgdata{$pkg}{'post'}; 1225 1226 close POSTINST; 1226 chmod 0755, "$ buildroot/$pkg/DEBIAN/postinst";1227 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/postinst"; 1227 1228 } 1228 1229 if ($pkgdata{$pkg}{'preun'}) { 1229 1230 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'preun'},'gp'); 1230 open PREUNINST, ">$ buildroot/$pkg/DEBIAN/prerm";1231 open PREUNINST, ">$specglobals{buildroot}/$pkg/DEBIAN/prerm"; 1231 1232 print PREUNINST "#!/bin/sh\nset -e\n\n"; 1232 1233 print PREUNINST $pkgdata{$pkg}{'preun'}; 1233 1234 close PREUNINST; 1234 chmod 0755, "$ buildroot/$pkg/DEBIAN/prerm";1235 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/prerm"; 1235 1236 } 1236 1237 if ($pkgdata{$pkg}{'postun'}) { 1237 1238 $pkgdata{$pkg}{'postun'} = expandmacros($pkgdata{$pkg}{'postun'},'gp'); 1238 open POSTUNINST, ">$ buildroot/$pkg/DEBIAN/postrm";1239 open POSTUNINST, ">$specglobals{buildroot}/$pkg/DEBIAN/postrm"; 1239 1240 print POSTUNINST "#!/bin/sh\nset -e\n\n"; 1240 1241 print POSTUNINST $pkgdata{$pkg}{'postun'}; 1241 1242 close POSTUNINST; 1242 chmod 0755, "$ buildroot/$pkg/DEBIAN/postrm";1243 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/postrm"; 1243 1244 } 1244 1245 … … 1486 1487 1487 1488 # To allow the FHS-ish %configure and %makeinstall to work The Right Way. 1488 # (Without clobbering the global $ buildroot.)1489 # (Without clobbering the global $specglobals{buildroot}.) 1489 1490 my $prefix = ''; 1490 1491 … … 1514 1515 } # done make 1515 1516 1517 # %makeinstall expands with recursive macros in rpm. whee. 1516 1518 if ($section =~ /i/) { 1517 1519 # This is where we need to mangle $prefix. 1518 $macrostring =~ s'%makeinstall'make %{fhs} install'; 1519 $prefix = $buildroot; 1520 $macrostring =~ s'%makeinstall'make \ 1521 prefix=%{?buildroot:%{buildroot}}%{_prefix} \ 1522 exec_prefix=%{?buildroot:%{buildroot}}%{_exec_prefix} \ 1523 bindir=%{?buildroot:%{buildroot}}%{_bindir} \ 1524 sbindir=%{?buildroot:%{buildroot}}%{_sbindir} \ 1525 sysconfdir=%{?buildroot:%{buildroot}}%{_sysconfdir} \ 1526 datadir=%{?buildroot:%{buildroot}}%{_datadir} \ 1527 includedir=%{?buildroot:%{buildroot}}%{_includedir} \ 1528 libdir=%{?buildroot:%{buildroot}}%{_libdir} \ 1529 libexecdir=%{?buildroot:%{buildroot}}%{_libexecdir} \ 1530 localstatedir=%{?buildroot:%{buildroot}}%{_localstatedir} \ 1531 sharedstatedir=%{?buildroot:%{buildroot}}%{_sharedstatedir} \ 1532 mandir=%{?buildroot:%{buildroot}}%{_mandir} \ 1533 infodir=%{?buildroot:%{buildroot}}%{_infodir} \ 1534 install '; 1535 $prefix = $specglobals{buildroot}; 1520 1536 } # done %install and/or %makeinstall 1521 1537 … … 1566 1582 # Package data 1567 1583 if ($section =~ /p/) { 1568 $macrostring =~ s/\%\{buildroot\}/$ buildroot/gi;1584 $macrostring =~ s/\%\{buildroot\}/$specglobals{buildroot}/gi; 1569 1585 foreach my $source (keys %{$pkgdata{sources}}) { 1570 1586 $macrostring =~ s/\%\{source$source\}/$topdir\/SOURCES\/$pkgdata{sources}{$source}/gi; … … 1610 1626 # support for **some** %if constructs. Note that this breaks somewhat if 1611 1627 # there's no value specified... but so does rpm. 1612 my $tmpcount = 0; 1613 while ($macrostring =~ /\%\{(!\?|\?!|\?)([a-z0-9_.-]+)(?:\:([a-z0-9_.-]+))?\}/g) { #Whew.... 1628 1629 my $tmpcount = 0; # runaway shutdown. Not really sure how else to avoid getting stuck. 1630 while ($macrostring =~ m/\%\{([?!]+)([a-z0-9_.-]+)(?:\:([a-z0-9_.\/\-\\]+)?)?\}/g) { #Whew.... 1614 1631 my $qex = $1; 1615 1632 my $macro = $2; 1616 my $value = $3;1633 my $value = (defined($3) ? $3 : ''); 1617 1634 1618 1635 my $neg = '1' if $qex =~ /\!/; … … 1622 1639 $value = '' if !$neg; 1623 1640 } 1624 $macrostring =~ s/\%\{ !?\?\!?[a-z0-9_.-]+(?:\:[a-z0-9_.-]+)?\}/$value/;1641 $macrostring =~ s/\%\{[?!]+[a-z0-9_.-]+(?:\:([a-z0-9_.\/\-\\]+)?)?\}/$value/; 1625 1642 1626 1643 # not certain about this, but I don't want to run away. It *can* happen if planned carefully. :/ 1627 1644 $tmpcount++; 1628 die "excessive recursive macro replacement; dying.\n" if $tmpcount > 6; 1645 # %makeinstall has 13 occurrences. D'Oh! 1646 die "excessive recursive macro replacement; dying.\n" if $tmpcount > 14; 1629 1647 1630 1648 } # while()
Note:
See TracChangeset
for help on using the changeset viewer.