Changeset 27


Ignore:
Timestamp:
12/09/05 18:13:00 (19 years ago)
Author:
kdeugau
Message:

/trunk

Checkpoint
%files support sort of in place
Basic support for subpackages in place

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r26 r27  
    9494# 10/31/2005 Maybe this should be flatter?  -kgd
    9595my %pkgdata;
     96my @pkglist = ('main'); #sigh
    9697# Files listing.  Embedding this in %pkgdata would be, um, messy.
    9798my %filelist;
     
    141142}
    142143# -> install if -.[ilabs]
    143 if ($cmdopts{stage} =~ /[ilabs]/) {
     144if ($cmdopts{stage} eq 'i' || ($cmdopts{stage} =~ /[labs]/ && $cmdopts{short} ne 'y')) {
     145#if ($cmdopts{stage} =~ /[ilabs]/) {
    144146  install();
    145147}
     
    257259  if ($cmdopts{short} eq 'y' && $cmdopts{stage} =~ /[labs]/) {
    258260    warn "Can't use --short-circuit for $targets{$cmdopts{stage}} stage.  Ignoring.\n";
    259     $cmdopts{short} = 'n';
     261##temp  Allow short-circuit on full builds so we can experiment
     262# with apache pkg without spending hours recompiling repeatedly
     263#    $cmdopts{short} = 'n';
    260264  }
    261265
     
    312316      }
    313317
    314       if (/^\%description/) {
    315         $pkgdata{main}{desc} .= $_;
     318      if (/^\%description(?:\s+(?:-n\s+)?([a-zA-Z0-9_.-]+))?/) {
     319        my $subname = "main";
     320        if ($1) {
     321          if (/-n/) { $subname = $1; } else { $subname = "$pkgdata{main}{name}-$1"; }
     322        }
    316323        while (<SPECFILE>) {
    317324          redo LINE if /^\%/;
    318           $pkgdata{main}{desc} .= " $_";
     325          $pkgdata{$subname}{desc} .= " $_";
    319326        }
     327      }
     328      if (/^\%package\s+(?:-n\s+)?([a-zA-Z0-9_.-]+)/) {
     329        my $subname;
     330        if (/-n/) { $subname = $1; } else { $subname = "$pkgdata{main}{name}-$1"; }
     331        push @pkglist, $subname;
     332        $pkgdata{$subname}{name} = $subname;
     333        $pkgdata{$subname}{version} = $pkgdata{main}{version};
     334        while (<SPECFILE>) {
     335          redo LINE if /^\%/;
     336          if (my ($dname,$dvalue) = (/^(Summary|Group|Version):\s+(.+)$/i)) {
     337            $dname =~ tr/[A-Z]/[a-z]/;
     338            $pkgdata{$subname}{$dname} = $dvalue;
     339          }
     340        }
    320341      }
    321342
     
    427448        if ($1) {
    428449          if (/-n/) { $pkgname = $1; } else { $pkgname = "$pkgdata{main}{name}-$1"; }
    429           # subpackage not based on "main" package
    430           while (<SPECFILE>) {
    431             # need to update this to deal with %dir, %attr, etc
    432             redo LINE if /^\%/;
    433             $filelist{$pkgname} .= $_;
    434           }
     450        }
     451        # subpackage not based on "main" package
     452#print "$pkgname\n";
     453        while (<SPECFILE>) {
     454          # need to update this to deal with %dir, %attr, etc
     455          redo LINE if /^\%/;
     456chomp;
     457#print; print "\n";
     458          $filelist{$pkgname} .= " $_";
     459#print $pkgdata{$pkgname}{files}; print "\n";
    435460        }
    436461        # do we replace \n's with \s in $filelist{$pkgname}?
     
    584609# Writes and executes a shell script to do so.
    585610# Creates miscellaneous files required by dpkg-deb to actually build the package file.
     611# Should handle simple subpackages
    586612sub binpackage {
    587613  # Make sure we have somewhere to write the .deb file
     
    591617  }
    592618
    593   # Gotta do this first, otherwise the control file has nowhere to go.  >:(
    594   mkdir "$buildroot/DEBIAN";
    595 
    596   # create script filename
    597   my $debscriptfile = "$tmpdir/deb-tmp.pkg.".int(rand(99998)+1);
    598   sysopen(DEBSCRIPT, $debscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
     619print "\n\nmoving files for subpackages...\n";
     620##work
     621  foreach my $pkg (@pkglist) {
     622#next if $pkg eq 'sources';
     623print "got here, trying to move files for $pkg...\n";
     624
     625    # Gotta do this first, otherwise we don't have a place to move files from %files
     626    mkdir "$buildroot/$pkg";
     627    my @pkgfilelist = split ' ', $filelist{$pkg};
     628    foreach my $pkgfile (@pkgfilelist) {
     629#print "finding path for $pkgfile\n";
     630      my @filepath = ($pkgfile =~ /(.+)\/([a-zA-Z0-9_\.\+\-]+)$/);
     631      qx { mkdir -p $buildroot/$pkg$filepath[0] }
     632        if $filepath[0] ne '';
     633#print "mkdir -p $buildroot/$pkg$filepath[0]\n";
     634#print "$filepath[0]\n";
     635      qx { mv $buildroot$pkgfile $buildroot/$pkg$filepath[0] };
     636#print "mv $buildroot$pkgfile $buildroot/$pkg$filepath[0]\n";
     637    }
     638#exit 0;
     639    # Gotta do this next, otherwise the control file has nowhere to go.  >:(
     640    mkdir "$buildroot/$pkg/DEBIAN";
     641
     642    # create script filename
     643    my $debscriptfile = "$tmpdir/deb-tmp.pkg.".int(rand(99998)+1);
     644    sysopen(DEBSCRIPT, $debscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
    599645        or die $!;
    600   print DEBSCRIPT $scriptletbase;
    601   print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot $topdir/DEBS/i386/".
    602         "$pkgdata{main}{name}_$pkgdata{main}{version}-$pkgdata{main}{release}_i386.deb\n";
    603     # %$&$%@#@@#%@@@ Debian and their horrible ugly package names.  >:(
    604   close DEBSCRIPT;
    605 
    606   my $control = "Package: $pkgdata{main}{name}\n".
    607         "Version: $pkgdata{main}{version}-$pkgdata{main}{release}\n".
    608         "Section: unknown\n".
     646    print DEBSCRIPT $scriptletbase;
     647    print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot/$pkg $topdir/DEBS/i386/".
     648        "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_i386.deb\n";
     649      # %$&$%@#@@#%@@@ Debian and their horrible ugly package names.  >:(
     650    close DEBSCRIPT;
     651
     652#my $control;
     653#eval {
     654    my $control = "Package: $pkgdata{$pkg}{name}\n".
     655        "Version: $pkgdata{$pkg}{version}-$pkgdata{main}{release}\n".
     656        "Section: $pkgdata{$pkg}{group}\n".
    609657        "Priority: optional\n".
    610658        "Architecture: i386\n".
    611659        "Maintainer: $pkgdata{main}{packager}\n".
    612         "Description: $pkgdata{main}{desc}\n";
    613 
    614   open CONTROL, ">$buildroot/DEBIAN/control";
    615   print CONTROL $control;
    616   close CONTROL;
    617 
    618   if ($preinstscript ne '') {
    619     open PREINST, ">$buildroot/DEBIAN/preinst";
    620     print PREINST "#!/bin/sh\nset -e\n\n";
    621     print PREINST $preinstscript;
    622     close PREINST;
    623     `chmod 0755 $buildroot/DEBIAN/preinst`;
    624   }
    625   if ($postinstscript ne '') {
    626     open POSTINST, ">$buildroot/DEBIAN/postinst";
    627     print POSTINST "#!/bin/sh\nset -e\n\n";
    628     print POSTINST $postinstscript;
    629     close POSTINST;
    630     `chmod 0755 $buildroot/DEBIAN/postinst`;
    631   }
    632   if ($preuninstscript ne '') {
    633     open PREUNINST, ">$buildroot/DEBIAN/prerm";
    634     print PREUNINST "#!/bin/sh\nset -e\n\n";
    635     print PREUNINST $preuninstscript;
    636     close PREUNINST;
    637     `chmod 0755 $buildroot/DEBIAN/prerm`;
    638   }
    639   if ($postuninstscript ne '') {
    640     open POSTUNINST, ">$buildroot/DEBIAN/postrm";
    641     print POSTUNINST "#!/bin/sh\nset -e\n\n";
    642     print POSTUNINST $postuninstscript;
    643     close POSTUNINST;
    644     `chmod 0755 $buildroot/DEBIAN/postrm`;
    645   }
    646 
    647 print `ls -l $buildroot/DEBIAN`;
     660        "Description: $pkgdata{$pkg}{summary}\n";
     661    $control .= "$pkgdata{$pkg}{desc}\n";
     662#};
     663#die "control: $control\n\n $@ \n" if $@;
     664
     665    open CONTROL, ">$buildroot/$pkg/DEBIAN/control";
     666    print CONTROL $control;
     667    close CONTROL;
     668
     669    if ($preinstscript ne '') {
     670      open PREINST, ">$buildroot/$pkg/DEBIAN/preinst";
     671      print PREINST "#!/bin/sh\nset -e\n\n";
     672      print PREINST $preinstscript;
     673      close PREINST;
     674      `chmod 0755 $buildroot/$pkg/DEBIAN/preinst`;
     675    }
     676    if ($postinstscript ne '') {
     677      open POSTINST, ">$buildroot/$pkg/DEBIAN/postinst";
     678      print POSTINST "#!/bin/sh\nset -e\n\n";
     679      print POSTINST $postinstscript;
     680      close POSTINST;
     681      `chmod 0755 $buildroot/$pkg/DEBIAN/postinst`;
     682    }
     683    if ($preuninstscript ne '') {
     684      open PREUNINST, ">$buildroot/$pkg/DEBIAN/prerm";
     685      print PREUNINST "#!/bin/sh\nset -e\n\n";
     686      print PREUNINST $preuninstscript;
     687      close PREUNINST;
     688      `chmod 0755 $buildroot/$pkg/DEBIAN/prerm`;
     689    }
     690    if ($postuninstscript ne '') {
     691      open POSTUNINST, ">$buildroot/$pkg/DEBIAN/postrm";
     692      print POSTUNINST "#!/bin/sh\nset -e\n\n";
     693      print POSTUNINST $postuninstscript;
     694      close POSTUNINST;
     695      `chmod 0755 $buildroot/$pkg/DEBIAN/postrm`;
     696    }
     697
     698#print `ls -l $buildroot/DEBIAN`;
    648699
    649700#Package: httpd
     
    660711# http://home.samfundet.no/~sesse/mpm-itk/.
    661712
    662   # execute
    663   print "Calling package creation script $debscriptfile for $pkgdata{main}{name}...\n";
    664   system("/bin/sh -e $debscriptfile") == 0
     713    # execute
     714    print "Calling package creation script $debscriptfile for $pkgdata{$pkg}{name}...\n";
     715    system("/bin/sh -e $debscriptfile") == 0
    665716        or die "Can't exec: $!\n";
    666717
    667   # and clean up
    668   unlink $debscriptfile;
     718    # and clean up
     719    unlink $debscriptfile;
     720
     721  } # subpackage loop
     722
    669723} # end binpackage()
    670724
Note: See TracChangeset for help on using the changeset viewer.