- Timestamp:
- 11/15/06 17:46:44 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r74 r75 125 125 my $installscript = '[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT'."\n"; 126 126 my $cleanscript = ''; 127 # pre/post (un)install scripts. Note that these will likely barf as-is. :/128 my $preinstscript = '';129 my $postinstscript = '';130 my $preuninstscript = '';131 my $postuninstscript = '';132 127 133 128 die "Not enough arguments\n" if #$argv == 0; … … 526 521 } 527 522 528 # pre/post (un)install scripts 529 if (/^\%pre\b/) { 523 # pre/post (un)install scripts. Note that we expand macros later anyway, so we'll leave them unexpanded here. 524 if (/^\%(pre|post|preun|postun)\b(?:\s+(?:-n\s+)?(.+))?/i) { 525 my $scriptlet = lc $1; 526 my $pkgname = 'main'; 527 if ($2) { # Magic to add entries to the right list of files 528 my $tmp = expandmacros("$2", 'g'); 529 if (/-n/) { $pkgname = $tmp; } else { $pkgname = "$pkgdata{main}{name}-$tmp"; } 530 } 530 531 while (<SPECFILE>) { 531 532 redo LINE if /^\%/; 532 $preinstscript .= $_; 533 } 534 } 535 if (/^\%post\b/) { 536 while (<SPECFILE>) { 537 redo LINE if /^\%/; 538 $postinstscript .= $_; 539 } 540 } 541 if (/^\%preun\b/) { 542 while (<SPECFILE>) { 543 redo LINE if /^\%/; 544 $preuninstscript .= $_; 545 } 546 } 547 if (/^\%postun\b/) { 548 while (<SPECFILE>) { 549 redo LINE if /^\%/; 550 $postuninstscript .= $_; 533 $pkgdata{$pkgname}{$scriptlet} .= $_; 551 534 } 552 535 } … … 890 873 } 891 874 892 # Can't see much point in scripts on subpackages... although since 893 # it's *possible* I should support it at some point. 894 if ($pkg eq 'main') { 895 if ($preinstscript ne '') { 896 $preinstscript = expandmacros($preinstscript,'g'); 897 open PREINST, ">$buildroot/$pkg/DEBIAN/preinst"; 898 print PREINST "#!/bin/sh\nset -e\n\n"; 899 print PREINST $preinstscript; 900 close PREINST; 901 `chmod 0755 $buildroot/$pkg/DEBIAN/preinst`; 902 } 903 if ($postinstscript ne '') { 904 $postinstscript = expandmacros($postinstscript,'g'); 905 open POSTINST, ">$buildroot/$pkg/DEBIAN/postinst"; 906 print POSTINST "#!/bin/sh\nset -e\n\n"; 907 print POSTINST $postinstscript; 908 close POSTINST; 909 `chmod 0755 $buildroot/$pkg/DEBIAN/postinst`; 910 } 911 if ($preuninstscript ne '') { 912 $preuninstscript = expandmacros($preuninstscript,'g'); 913 open PREUNINST, ">$buildroot/$pkg/DEBIAN/prerm"; 914 print PREUNINST "#!/bin/sh\nset -e\n\n"; 915 print PREUNINST $preuninstscript; 916 close PREUNINST; 917 `chmod 0755 $buildroot/$pkg/DEBIAN/prerm`; 918 } 919 if ($postuninstscript ne '') { 920 $postuninstscript = expandmacros($postuninstscript,'g'); 921 open POSTUNINST, ">$buildroot/$pkg/DEBIAN/postrm"; 922 print POSTUNINST "#!/bin/sh\nset -e\n\n"; 923 print POSTUNINST $postuninstscript; 924 close POSTUNINST; 925 `chmod 0755 $buildroot/$pkg/DEBIAN/postrm`; 926 } 875 # found the point of scripts on subpackages. 876 if ($pkgdata{$pkg}{'pre'}) { 877 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'pre'},'gp'); 878 open PREINST, ">$buildroot/$pkg/DEBIAN/preinst"; 879 print PREINST "#!/bin/sh\nset -e\n\n"; 880 print PREINST $pkgdata{$pkg}{'pre'}; 881 close PREINST; 882 `chmod 0755 $buildroot/$pkg/DEBIAN/preinst`; 883 } 884 if ($pkgdata{$pkg}{'post'}) { 885 $pkgdata{$pkg}{'post'} = expandmacros($pkgdata{$pkg}{'post'},'gp'); 886 open PREINST, ">$buildroot/$pkg/DEBIAN/postinst"; 887 print PREINST "#!/bin/sh\nset -e\n\n"; 888 print PREINST $pkgdata{$pkg}{'post'}; 889 close PREINST; 890 `chmod 0755 $buildroot/$pkg/DEBIAN/postinst`; 891 } 892 if ($pkgdata{$pkg}{'preun'}) { 893 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'preun'},'gp'); 894 open PREINST, ">$buildroot/$pkg/DEBIAN/prerm"; 895 print PREINST "#!/bin/sh\nset -e\n\n"; 896 print PREINST $pkgdata{$pkg}{'preun'}; 897 close PREINST; 898 `chmod 0755 $buildroot/$pkg/DEBIAN/prerm`; 899 } 900 if ($pkgdata{$pkg}{'postun'}) { 901 $pkgdata{$pkg}{'postun'} = expandmacros($pkgdata{$pkg}{'postun'},'gp'); 902 open PREINST, ">$buildroot/$pkg/DEBIAN/postrm"; 903 print PREINST "#!/bin/sh\nset -e\n\n"; 904 print PREINST $pkgdata{$pkg}{'postun'}; 905 close PREINST; 906 `chmod 0755 $buildroot/$pkg/DEBIAN/postrm`; 927 907 } 928 908
Note:
See TracChangeset
for help on using the changeset viewer.