Changeset 16 for trunk


Ignore:
Timestamp:
11/09/05 16:41:04 (19 years ago)
Author:
kdeugau
Message:

/trunk

Checkpoint
Added processing for %pre, %post, %preun, %postun scriptlets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r15 r16  
    9999my $installscript;
    100100my $cleanscript;
     101# pre/post (un)install scripts.  Note that these will likely barf as-is.  :/
     102my $preinstscript = '';
     103my $postinstscript = '';
     104my $preuninstscript = '';
     105my $postuninstscript = '';
    101106
    102107die "Not enough arguments\n" if #$argv == 0;
     
    381386        $cleanscript = expandmacros($cleanscript,'gp');
    382387      }
    383       if (/^\%post/) {
    384       }
    385       if (/^\%preun/) {
     388    # pre/post (un)install scripts
     389      if (/^\%pre\b/) {
     390        while (<SPECFILE>) {
     391          redo LINE if /^\%/;
     392          $preinstscript .= $_;
     393        }
     394      }
     395      if (/^\%post\b/) {
     396        while (<SPECFILE>) {
     397          redo LINE if /^\%/;
     398          $postinstscript .= $_;
     399        }
     400      }
     401      if (/^\%preun\b/) {
     402        while (<SPECFILE>) {
     403          redo LINE if /^\%/;
     404          $preuninstscript .= $_;
     405        }
     406      }
     407      if (/^\%postun\b/) {
     408        while (<SPECFILE>) {
     409          redo LINE if /^\%/;
     410          $postuninstscript .= $_;
     411        }
    386412      }
    387413      if (/^\%files/) {
     
    439465  $buildroot = expandmacros($buildroot,'gp');
    440466
     467  close SPECFILE;
    441468} # end parse_spec()
    442469
     
    534561        or die $!;
    535562  print DEBSCRIPT $scriptletbase;
    536   print DEBSCRIPT "tree $buildroot\n".
    537         "fakeroot dpkg-deb -b $buildroot $topdir/DEBS/i386/$pkgdata{main}{name}_$pkgdata{main}{version}-$pkgdata{main}{release}_i386.deb\n";
     563  print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot $topdir/DEBS/i386/".
     564        "$pkgdata{main}{name}_$pkgdata{main}{version}-$pkgdata{main}{release}_i386.deb\n";
    538565    # %$&$%@#@@#%@@@ Debian and their horrible ugly package names.  >:(
    539566  close DEBSCRIPT;
     
    550577  print CONTROL $control;
    551578  close CONTROL;
     579
     580  if ($preinstscript ne '') {
     581    open PREINST, ">$buildroot/DEBIAN/preinst";
     582    print PREINST "#!/bin/sh\nset -e\n\n";
     583    print PREINST $preinstscript;
     584    close PREINST;
     585    `chmod 0755 $buildroot/DEBIAN/preinst`;
     586  }
     587  if ($postinstscript ne '') {
     588    open POSTINST, ">$buildroot/DEBIAN/postinst";
     589    print POSTINST "#!/bin/sh\nset -e\n\n";
     590    print POSTINST $postinstscript;
     591    close POSTINST;
     592    `chmod 0755 $buildroot/DEBIAN/postinst`;
     593  }
     594  if ($preuninstscript ne '') {
     595    open PREUNINST, ">$buildroot/DEBIAN/prerm";
     596    print PREUNINST "#!/bin/sh\nset -e\n\n";
     597    print PREUNINST $preuninstscript;
     598    close PREUNINST;
     599    `chmod 0755 $buildroot/DEBIAN/prerm`;
     600  }
     601  if ($postuninstscript ne '') {
     602    open POSTUNINST, ">$buildroot/DEBIAN/postrm";
     603    print POSTUNINST "#!/bin/sh\nset -e\n\n";
     604    print POSTUNINST $postuninstscript;
     605    close POSTUNINST;
     606    `chmod 0755 $buildroot/DEBIAN/postrm`;
     607  }
     608
     609print `ls -l $buildroot/DEBIAN`;
    552610
    553611#Package: httpd
     
    565623
    566624  # execute
    567   print "Creating .deb for $pkgdata{main}{name}...\n";
     625  print "Calling package creation script $debscriptfile for $pkgdata{main}{name}...\n";
    568626  system("/bin/sh -e $debscriptfile") == 0
    569627        or die "Can't exec: $!\n";
Note: See TracChangeset for help on using the changeset viewer.