From: Mike <mi...@mi...> - 2004-08-05 00:23:59
|
On Mon, 02 Aug 2004, David Clissold wrote: > On Mon, Aug 02, 2004 at 03:29:36PM -0500, Mike wrote: > > I can build these things, but I like the idea of the *.rpm to keep > > separate those things that come as part of the BOS and those things > > that I've added on. The differences between installp and rpm do > > that nicely. > > Mike -- want to try an experiment? > > Suppose that you want a package which is not in the Toolbox, but you find that > it is pre-built at the UCLA site. Their image is just a compressed tarball, > and you'd rather it be in rpm format, but you also aren't particularly excited > about building it yourself. > > So -- how about converting their tarball into an installable rpm image without > actually building anything? You could do this without really having to know > much about rpm builds, using the file below. > > Visit http://aixpdslib.seas.ucla.edu and find the package you want, then > download it. Save the file below (and edit it if a different package is > desired). Then run: "rpm -bb net-snmp.spec" assuming net-snmp.spec is the > name of the saved file. Conventionally you'd put this file in > /opt/freeware/src/packages/SPECS, but you could store it anywhere. > > This method ought to work with pretty much any of the UCLA images. Note > that theirs are built based in /usr/local, so if you use that directory for > your own other uses, take care that you don't overwrite any of your own files > that you might have copied there. If this is a concern, list the files > in the package (rpm -qlp <rpmname>) after you create the package but before > you install it. > > -- > David Clissold > cl...@au... Submitted for your enjoyment: (change USER below to your account name) ------------------------------------------------------ #!/usr/bin/perl # $Id$ # $Log$ # read a file of packages to get from the UCLA AIX site # if the package already exists, go to the next # pull the package, run a spec file on it to create the rpm file # send a notification of a new package use Net::FTP; use strict; use warnings; my @packages; my @pulled; my %files; my %archversions; my $cfgfn = shift || 'ucla-tarball-rpm.cfg'; my %cfg; my @a; system("rm -f store/lsof*.Z"); # read the config file #open(CFG, "<$cfgfn") or die "$0: unable to read '$cfgfn': $!"; while(<DATA>) { next if /^#/o; next if /^\s*$/o; chomp; @a = split(' '); if($a[0] eq 'package') { push(@packages, $a[1]); } else { $cfg{$a[0]} = $a[1]; } } #close(CFG); # make sure the storage place exists mkdir $cfg{'store'} unless -d $cfg{'store'}; chdir $cfg{'store'}; # pull the tarball packages my $ftp = Net::FTP->new($cfg{'host'}) or die "$0: unable to reach host '$cfg{'host'}': $!"; $ftp->login($cfg{'user'}, $cfg{'pass'}, Debug => 9); my $dir = $cfg{'dir'}; my $pkgdir = $dir; $ftp->cwd($dir); foreach my $package (@packages) { $pkgdir = $dir . '/' . $package; $ftp->cwd($pkgdir); if($ftp->pwd ne $pkgdir) { print "package $package not found\n"; next; } $pkgdir .= '/RISC'; $ftp->cwd($pkgdir); my @files = $ftp->dir or next; shift(@files); # get rid of the first line @a = split(' ', $files[0]); my $highest = $a[$#a] || 'UNK'; foreach my $file (@files) { # get highest OS version @a = split(' ', $file); $highest = $highest < $a[$#a] ? $a[$#a] : $highest; } next if $highest eq 'UNK'; $pkgdir .= '/' . $highest . '/exec'; $ftp->cwd($pkgdir); if($ftp->pwd ne $pkgdir) { print "package $package not found\n"; next; } @files = $ftp->dir; shift(@files); foreach my $file (@files) { @a = split(' ', $files[0]); $file = $a[$#a]; $archversions{$file} = $highest; print "looking for $file\n"; if(! -f $file) { print "getting $file\n"; $ftp->binary; $ftp->get($file); push(@pulled, $file); $files{$file} = $package; } } $ftp->cwd($dir); } $ftp->quit; # if $HOME/.rpmmacros exists # read it, parse it, and create the necessary directories if(-f "$ENV{'HOME'}/.rpmmacros") { open(RPM, "<$ENV{'HOME'}/.rpmmacros") or die "$0: unable to open ~/.rpmmacros: $!"; while(<RPM>) { next unless /topdir/; @a = split(' '); $cfg{'topdir'} = $a[1]; } close RPM; $cfg{'topdir'} = '/opt/freeware/src/packages' unless $cfg{'topdir'}; $cfg{'rpmbuild'} = "$cfg{'topdir'}/BUILD"; $cfg{'rpmrpms'} = "$cfg{'topdir'}/RPMS"; $cfg{'rpmsrpms'} = "$cfg{'topdir'}/SRPMS"; $cfg{'rpmsources'} = "$cfg{'topdir'}/SOURCES"; system("mkdir -p $cfg{'rpmbuild'}"); system("mkdir -p $cfg{'rpmrpms'}"); system("mkdir -p $cfg{'rpmsrpms'}"); system("mkdir -p $cfg{'rpmsources'}"); } # create rpm packages from the pulled tarball packages foreach my $file (@pulled) { my $date = scalar(localtime); my $package = $files{$file}; my $pkgversion = $file; $pkgversion =~ s/^$package[-.]//; $pkgversion =~ s/.tar.gz$//o; $pkgversion =~ s/.tar.Z$//o; my $archversion = $archversions{$file} || '5.1'; print "pulled $file for package $package\n"; system("mkdir -p $cfg{'rpmsources'}"); system("cp $file $cfg{'rpmsources'}"); open(SPEC, ">$package.spec") or die "$0: unable to create file '$package.spec': $!"; print SPEC <<EOF; ############################################################################ # Download desired tarball from http://aixpdslib.seas.ucla.edu # Place the tarball in /opt/freeware/src/packages/SOURCES # Edit "Summary:", "Name:", and "Version:" below to set package name/version. # Edit "Source0:" to match the filename of the compressed tarball. # Edit "License:" to indicate type of license; It's up to you to read the # license and agree to it. USE THIS IMAGE AT YOUR OWN RISK! # Edit "\%description" section to describe package as you like. # Edit "\%changelog" and follow the format as desired. (Optional; you could # remove this section if you want). # Save this file and use rpm to build an installable rpm image. For example, # if this file is named "net-snmp.spec": # \$ rpm -bb net-snmp.spec # After a few minutes, this should finish and the rpm image should appear # in directory /opt/freeware/src/packages/RPMS/ppc. # Try "rpm -qip <filename>" and "rpm -qlp <filename>" to examine it before # installing. # # If the 'rpm -bb' fails, you probably need more space in /var/tmp. ############################################################################ Summary: $package from http://aixpdslib.seas.ucla.edu Name: $package Version: $pkgversion Source0: ${package}.${pkgversion}.tar.Z Release: 1 License: BSD-like Group: UCLA/Prebuilt Prefix: /usr/local BuildRoot: %{_tmppath}/%{name}-root %description This is $package pulled as file $file from $cfg{'host'}. Pulled from the AIX $archversion directory on $date. \%install [[ \$RPM_BUILD_ROOT != "/" ]] && rm -rf \$RPM_BUILD_ROOT mkdir -p \$RPM_BUILD_ROOT cd \$RPM_BUILD_ROOT uncompress -c \%{SOURCE0} | tar -xf - # Optional. Would be nice to have the binaries stripped. /usr/bin/strip .\%{prefix}/bin/* .\%{prefix}/sbin/* 2>/dev/null || : \%clean [[ \$RPM_BUILD_ROOT != "/" ]] && rm -rf \$RPM_BUILD_ROOT \%files \%defattr(-,bin,bin) \%{prefix}/* EOF close SPEC; system("rpm -bb $package.spec"); } __DATA__ # connection settings host aixpdslib.seas.ucla.edu user anonymous pass ai...@so... dir /pub store /home/USER/ucla/store rpmsources /opt/freeware/src/packages/SOURCES # packages to pull package apache package autoconf package automake package bison package cdrecord package cfengine package cvs package db package expect package flex package gnuplot package gzip package indent package jabber package less package lsof package make package mkisofs package mysql package mutt package net-snmp package openldap package openssl package rcs package rdist package readline package samba package screen package sudo package tk package tcl package tcltk package tcsh package unzip package zip ------------------------------------------------------ |