summaryrefslogtreecommitdiffstats
path: root/tools/create-debian-pkglist.pl
blob: 1567f5aa20ed05f889b56d0f80e14f5e2fea8dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/perl

#some quicksetup to make sure everything is in place
system('mkdir -p /disks/tmp/bcfg2-packagelists' );


#pull the correct package lists from the security sites. 
#this needs to be abstracted better
system( "wget http://security.debian.org/dists/stable/updates/main/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/security-main.Packages -q" );
system( "wget http://security.debian.org/dists/stable/updates/contrib/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/security-contrib.Packages -q" );
system( "wget http://security.debian.org/dists/stable/updates/non-free/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/security-nonfree.Packages -q" );

system('cat /disks/tmp/bcfg2-packagelists/security-main.Packages /disks/tmp/bcfg2-packagelists/security-contrib.Packages /disks/tmp/bcfg2-packagelists/security-nonfree.Packages > /disks/tmp/bcfg2-packagelists/debian-stable-security.Packages');
system('rm /disks/tmp/bcfg2-packagelists/security-main.Packages /disks/tmp/bcfg2-packagelists/security-contrib.Packages /disks/tmp/bcfg2-packagelists/security-nonfree.Packages');

#pull the correct package lists from the security sites. 
#this needs to be abstracted better
system( "wget http://volatile.debian.net/debian-volatile/dists/stable/volatile/main/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/volatile-main.Packages -q" );
system( "wget http://volatile.debian.net/debian-volatile/dists/stable/volatile/contrib/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/volatile-contrib.Packages -q" );
system( "wget http://volatile.debian.net/debian-volatile/dists/stable/volatile/non-free/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/volatile-nonfree.Packages -q" );

system('cat /disks/tmp/bcfg2-packagelists/volatile-main.Packages /disks/tmp/bcfg2-packagelists/volatile-contrib.Packages /disks/tmp/bcfg2-packagelists/volatile-nonfree.Packages > /disks/tmp/bcfg2-packagelists/debian-stable-volatile.Packages');
system('rm /disks/tmp/bcfg2-packagelists/volatile-main.Packages /disks/tmp/bcfg2-packagelists/volatile-contrib.Packages /disks/tmp/bcfg2-packagelists/volatile-nonfree.Packages');

#pull the correct package lists from the security sites. 
#this needs to be abstracted better
system( "wget ftp://ftp.nerim.net/debian-marillat/dists/sarge/main/binary-i386/Packages -O /disks/tmp/bcfg2-packagelists/debian-sarge-mplayer.Packages -q" );

#this is to fix local files so that my naming hack thing will playout.
system('cp /disks/debian/sarge/Packages /disks/tmp/bcfg2-packagelists/debian-sarge-local.Packages');

system('cat /disks/distro/debian/dists/sarge/main/binary-i386/Packages /disks/distro/debian/dists/sarge/contrib/binary-i386/Packages /disks/distro/debian/dists/sarge/non-free/binary-i386/Packages > /disks/tmp/bcfg2-packagelists/debian-sarge-distro.Packages');

system('cat /disks/distro/debian-non-US/dists/sarge/non-US/main/binary-i386/Packages /disks/distro/debian-non-US/dists/sarge/non-US/contrib/binary-i386/Packages /disks/distro/debian-non-US/dists/sarge/non-US/non-free/binary-i386/Packages > /disks/tmp/bcfg2-packagelists/debian-sarge-nonUS.Packages');

#this is currently still a hack, because ordering is important.
#for future refernce you must do security and then local.. then the rest.. 

@files = ( 
  "/disks/tmp/bcfg2-packagelists/debian-stable-volatile.Packages",
  "/disks/tmp/bcfg2-packagelists/debian-stable-security.Packages", 
  "/disks/tmp/bcfg2-packagelists/debian-sarge-local.Packages",
  "/disks/tmp/bcfg2-packagelists/debian-sarge-mplayer.Packages",
  "/disks/tmp/bcfg2-packagelists/debian-sarge-distro.Packages", 
  "/disks/tmp/bcfg2-packagelists/debian-sarge-nonUS.Packages",
);

$priority = 89;
@tmpfiles = ();

#first come the security fixes
foreach $file ( @files ){

  push( @tmpfiles, $file );  
  #first we open up the imput file
  open( INFILE, "$file" ) or die("could not open $file\n");
  
  #then we change the name and open the output file.
  $file =~ s/Packages/xml/ ;
  #print "Opening $file for writing\n";
  open( OUTFILE, ">$file" );


  #start by putting in the default stuff 
  print OUTFILE "<PackageList uri='http://netzero.mcs.anl.gov:8080/' type='deb' priority='".$priority."'>\n";
  print OUTFILE "<Group name='debian-sarge'>\n";

  #decrement the priority since we are going highest to lowest
  $priority = $priority - 10;

  
  #the loop that builds the actually file.
  $known_package=0;
  while( $line = <INFILE> ){
    if( $line =~ /^Package:/ ){
      ($filler,$basename)=split( ' ', $line );
      
      #Now to find the version of the package.
      $found = 0;
      while( !$found ){
	$line = <INFILE>;
	if( $line =~ /^Version:/ ){
	  ($filler,$version)=split( ' ', $line );
	  if ( ! $known_package ){
	    print OUTFILE "\t<Package name=\"".$basename."\" version=\"".$version."\"/>\n" ;
	    push @mypackages, $basename;	  }
	  $found =1;
	}
      }
    }
    #end of file builder loop

  }
  close( INFILE );
  print OUTFILE "</Group>\n</PackageList>\n";
  close( OUTFILE );
}


#this is where I do clean up and set up for distributing the files to other
#servers.

#clean up the temp files
foreach $file (@tmpfiles){
  #print "removing file: $file\n";
  system("rm -f $file");
}

#get rid of old tarball
#print "Removing old tarball\n";
system('rm -f /disks/debian/pkglists/bcfg2-packagelists.tgz');

#create new tarball for distribution
#print "Creating new tarball\n";
system('cd /disks/tmp/ ; tar czf /disks/debian/pkglists/bcfg2-packagelists.tgz bcfg2-packagelists 2&>1 >/dev/null' );

#move the files into place on the local machine
#for testing purposes and also until we get netzero converted to 0.8
#system('mv /disks/tmp/bcfg2-packagelists/*.xml /disks/tmp/bcfg2/Pkgmgr/');
#for real
system('mv /disks/tmp/bcfg2-packagelists/*.xml /disks/bcfg2/Pkgmgr/');

#final clean up
system('rmdir /disks/tmp/bcfg2-packagelists' );