Revision: 4503 http://gar.svn.sourceforge.net/gar/?rev=4503&view=rev Author: dmichelsen Date: 2009-04-27 12:41:23 +0000 (Mon, 27 Apr 2009)
Log Message: ----------- gal2: Add legacy build description from Michael Gernoth Added Paths: ----------- csw/mgar/pkg/gal2/ csw/mgar/pkg/gal2/trunk/ csw/mgar/pkg/gal2/trunk/legacy/ csw/mgar/pkg/gal2/trunk/legacy/scripts/ csw/mgar/pkg/gal2/trunk/legacy/scripts/analyzer.pl csw/mgar/pkg/gal2/trunk/legacy/scripts/human.pl csw/mgar/pkg/gal2/trunk/legacy/scripts/pkghelper.pl csw/mgar/pkg/gal2/trunk/legacy/sources/ csw/mgar/pkg/gal2/trunk/legacy/specs/ csw/mgar/pkg/gal2/trunk/legacy/specs/Makefile csw/mgar/pkg/gal2/trunk/legacy/specs/gal2 Added: csw/mgar/pkg/gal2/trunk/legacy/scripts/analyzer.pl =================================================================== --- csw/mgar/pkg/gal2/trunk/legacy/scripts/analyzer.pl (rev 0) +++ csw/mgar/pkg/gal2/trunk/legacy/scripts/analyzer.pl 2009-04-27 12:41:23 UTC (rev 4503) @@ -0,0 +1,22 @@ +#!/usr/bin/perl -w + +use strict; + +my %counter; + +while (<>) { + if (/\"GET (\/csw\/.*) HTTP\/.\..\"/) { + # print "match: $1\n"; + my $path = $1; + + if ($path =~ /\/csw\/(unstable|stable)\/(sparc|i386)\/5\.(8|9|10)\/([^-]*)-.*\.pkg.gz/) { + # print "real match: $1 $2 $3 $4\n"; + $counter{$4}++; + } + + } +} + +foreach my $pkg (reverse(sort {$counter{$a} <=> $counter{$b} or $b cmp $a} (keys(%counter)))) { + printf "% 20.20s -> %d\n", $pkg, $counter{$pkg}; +} Added: csw/mgar/pkg/gal2/trunk/legacy/scripts/human.pl =================================================================== --- csw/mgar/pkg/gal2/trunk/legacy/scripts/human.pl (rev 0) +++ csw/mgar/pkg/gal2/trunk/legacy/scripts/human.pl 2009-04-27 12:41:23 UTC (rev 4503) @@ -0,0 +1,315 @@ +#!/usr/bin/perl -w +# +# $Id: human.pl,v 1.1 2004/03/09 10:21:13 simigern Exp $ +# +# Copyright (c) 2000-2001, Jeremy Mates. This script is free +# software; you can redistribute it and/or modify it under the same +# terms as Perl itself. +# +# Run perldoc(1) on this file for additional documentation. +# +###################################################################### +# +# REQUIREMENTS + +require 5; + +use strict; + +###################################################################### +# +# MODULES + +use Carp; # better error reporting +use Getopt::Std; # command line option processing + +###################################################################### +# +# VARIABLES + +my $VERSION; +($VERSION = '$Revision: 1.1 $ ') =~ s/[^0-9.]//g; + +my (%opts, $base, $regex); + +# various parameters that adjust how the humanization is done +# these really should be able to be specified on the command line, or +# read in from a prefs file somewhere, as nobody will agree as to what +# "proper" human output should look like... :) +my %format = ( + # include decimals in output? (e.g. 25.8 K vs. 26 K) + 'decimal' => 1, + # include .0 in decmail output? + 'decimal_zero' => 1, + # what to divide file sizes down by + # 1024 is generally "Kilobytes," while 1000 is + # "kilobytes," technically + 'factor' => 1024, + # percentage above which will be bumped up + # (e.g. 999 bytes -> 1 K as within 5% of 1024) + # set to undef to turn off + 'fudge' => 0.95, + # lengths above which decimals will not be included + # for better readability + 'max_human_length' => 2, + # list of suffixes for human readable output + 'suffix' => [ '', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' ], + ); + +# default conversion to do nothing +$base = 1; + +# default to working on runs of 4 or more digits +$regex = '(?:(?<=\s)|(?<=^))(-?\d{4,})(?:\.\d*){0,1}(?=$|\s)'; + +###################################################################### +# +# MAIN + +# parse command-line options +getopts('h?kb:m:', \%opts); + +help() if exists $opts{'h'} or exists $opts{'?'}; + +# set the base conversion factor +if (exists $opts{'b'}) { + ($base) = $opts{'b'} =~ m/(\d+)/; + die "Error: base should be a positive integer\n" unless $base; +} + +$base = 1024 if exists $opts{'k'}; + +# set different regex if requried, add matching parens if none +# detected in input, as we need to match *something* +$regex = $opts{'m'} if exists $opts{'m'}; +$regex = '(' . $regex . ')' unless $regex =~ m/\(.+\)/; + +while (<STDIN>) { + s/$regex/humanize($1)/ego; + print; +} + +exit; + +###################################################################### +# +# SUBROUTINES + +# Inspired from GNU's df -h output, which fixes 133456345 bytes +# to be something human readable. +# +# takes a number, returns formatted string. +sub humanize { + my $num = shift; + + # error checking on input... + return $num unless $num =~ m/^-?\d+$/; + + # some local working variables + my $count = 0; + my $prefix = ''; + my $tmp = ''; + my $orig_len = length $num; + + # handle negatives + if ($num < 0 ) { + $num = abs $num; + $prefix = '-'; + } + + # adjust number to proper base + $num *= $base; + + # reduce number to something readable by factor specified + while ($num > $format{'factor'}) { + $num /= $format{'factor'}; + $count++; + } + + # optionally fudge "near" values up to next higher level + if (defined $format{'fudge'}) { + if ($num > ($format{'fudge'} * $format{'factor'})) { + $count++; + $num /= $format{'factor'}; + } + } + + # no .[1-9] decimal on longer numbers for easier reading + # only show decimal if format say so + if (length sprintf("%.f", $num) > $format{'max_human_length'} || + ! $format{'decimal'}) { + + $tmp = sprintf("%.0f", $num); + + } else { + $tmp = sprintf("%.1f", $num); + + # optionally hack trailing .0 as is not needed + $tmp =~ s/\.0$// unless $format{'decimal_zero'}; + } + + # return number with proper style applied and leading whitespace + # for proper right-justification + $tmp = $prefix . $tmp . $format{'suffix'}->[$count]; + return (' ' x ($orig_len - length $tmp)) . $tmp; +} + +# a generic help blarb +sub help { + print <<"HELP"; +Usage: $0 [opts] + +Script to humanize numbers in data. + +Options for version $VERSION: + -h/-? Display this message + + -b nn Integer to offset incoming data by. + -k Default incoming data to Kilobtyes. Default: bytes. + + -m rr Regex to match what to operate on. Default: $regex. + +Run perldoc(1) on this script for additional documentation. + +HELP + exit; +} + +###################################################################### +# +# DOCUMENTATION + +=head1 NAME + +human.pl - humanizes file sizes in data + +=head1 SYNOPSIS + +Make df(1) output readable on systems lacking the human output option: + + $ df -k | human.pl -k + +=head1 DESCRIPTION + +Intended as a quick way to humanize the output from random programs +that displays unreadable file sizes, such as df(1) on large file +systems: + + $ df -k | grep nfs + nfs:/mbt 1026892400 704296472 322595928 69% /mbt + +While certain utilities now support humanized output internally, not +all systems have those utilities. Hence, this perl script is intended +to fill that gap util more utilities support humanization routines +directly. This will become more important as file systems continue to +grow, and the exact number of bytes something takes up less meaningful +to the user. + +The data munged by this script is less accurate, in that rounding is +done in an effort to make the numbers more readable by a human. In +the above case, the munged data would look like: + + $ df -k | grep nfs | human.pl -k + nfs:/mbt 1.0T 672G 308G 69% /mbt + +=head2 Normal Usage + + $ human.pl [options] + +See L<"OPTIONS"> for details on the command line switches supported. + +human.pl expects the data to be humanized to come via STDIN, and +results will be piped to STDOUT. Input can either be from a program, +or you can interactively type numbers into the terminal and get a +humanized size back. + +=head1 OPTIONS + +This script currently supports the following command line switches: + +=over 4 + +=item B<-h>, B<-?> + +Prints a brief usage note about the script. + +=item B<-b> I<base> + +Optional integer to factor the incoming data by. The humanizing +routine operates on bytes by default, so numbers of different formats +will have to be adjusted accordingly. + +The value should be one that adjusts the incoming data to be in bytes +format; for example, incoming data in Kilobytes would need a base of +1024 to be converted properly to bytes, as there are 1024 bytes in +each Kilobyte. + +=item B<-k> + +Overrides B<-b> and treats the incoming data as if in Kilobytes. + +=item B<-m> I<regex> + +Optional perl regex to specify what in the incoming data should be +operated on; the default of digit runs of four or more characters +should be reasonable in most cases. + +Your regex should match integers of some kind; otherwise, the script +will generally do nothing with your data and not print any warnings. +If you are matching numbers inside of a more complictated regex, you +will need to put parentheses around the number you want changed, and +use non-capturing parentheses for preceeding items, as only $1 is +passed to the humanizing routine. See perlre(1) for more details. + +If you leave parentheses out of your regex, they will be added around +it by default. This lets you supply regex like '\d{7,}' and have it +work, which is the same as saying '(\d{7,})' in this case. + +=back + +=head1 BUGS + +=head2 Reporting Bugs + +Newer versions of this script may be available from: + +http://sial.org/code/perl/ + +If the bug is in the latest version, send a report to the author. +Patches that fix problems or add new features are welcome. + +=head2 Known Issues + +No known issues. + +=head1 TODO + +Option to read humanizing prefs from a external location would be a +nice idea. + +=head1 SEE ALSO + +perl(1) + +=head1 AUTHOR + +Jeremy Mates, http://sial.org/contact/ + +=head1 COPYRIGHT + +Copyright (c) 2000-2001, Jeremy Mates. This script is free +software; you can redistribute it and/or modify it under the same +terms as Perl itself. + +=head1 HISTORY + +Inspired from the B<-h> option present in GNU df, which is sorely +lacking in commercial varients of the same name. (On the other hand, +leaving the job of humanizing to an external script is probably more +inline with the unix philosphopy of filters.) + +=head1 VERSION + + $Id: human.pl,v 1.1 2004/03/09 10:21:13 simigern Exp $ + +=cut Added: csw/mgar/pkg/gal2/trunk/legacy/scripts/pkghelper.pl =================================================================== --- csw/mgar/pkg/gal2/trunk/legacy/scripts/pkghelper.pl (rev 0) +++ csw/mgar/pkg/gal2/trunk/legacy/scripts/pkghelper.pl 2009-04-27 12:41:23 UTC (rev 4503) @@ -0,0 +1,696 @@ +#!/opt/csw/bin/perl -w +use strict; +use warnings FATAL => 'uninitialized'; + +use FindBin qw($RealBin $RealScript); +use File::Basename; +use Getopt::Long; + +my @csw_ignore = qw( +opt/csw +opt/csw/bin +opt/csw/bin/sparcv8 +opt/csw/bin/sparcv8plus +opt/csw/bin/sparcv8plus+vis +opt/csw/bin/sparcv9 +opt/csw/lib +opt/csw/lib/X11 +opt/csw/lib/X11/app-defaults +opt/csw/lib/sparcv8plus +opt/csw/lib/sparcv8plus+vis +opt/csw/lib/sparcv9 +opt/csw/sbin +opt/csw/share +opt/csw/share/doc +opt/csw/share/info +opt/csw/share/locale +opt/csw/share/locale/az +opt/csw/share/locale/az/LC_MESSAGES +opt/csw/share/locale/be +opt/csw/share/locale/be/LC_MESSAGES +opt/csw/share/locale/bg +opt/csw/share/locale/bg/LC_MESSAGES +opt/csw/share/locale/ca +opt/csw/share/locale/ca/LC_MESSAGES +opt/csw/share/locale/cs +opt/csw/share/locale/cs/LC_MESSAGES +opt/csw/share/locale/da +opt/csw/share/locale/da/LC_MESSAGES +opt/csw/share/locale/de +opt/csw/share/locale/de/LC_MESSAGES +opt/csw/share/locale/el +opt/csw/share/locale/el/LC_MESSAGES +opt/csw/share/locale/e...@boldquot +opt/csw/share/locale/e...@boldquot/LC_MESSAGES +opt/csw/share/locale/e...@quot +opt/csw/share/locale/e...@quot/LC_MESSAGES +opt/csw/share/locale/es +opt/csw/share/locale/es/LC_MESSAGES +opt/csw/share/locale/et +opt/csw/share/locale/et/LC_MESSAGES +opt/csw/share/locale/eu +opt/csw/share/locale/eu/LC_MESSAGES +opt/csw/share/locale/fi +opt/csw/share/locale/fi/LC_MESSAGES +opt/csw/share/locale/fr +opt/csw/share/locale/fr/LC_MESSAGES +opt/csw/share/locale/ga +opt/csw/share/locale/ga/LC_MESSAGES +opt/csw/share/locale/gl +opt/csw/share/locale/gl/LC_MESSAGES +opt/csw/share/locale/he +opt/csw/share/locale/he/LC_MESSAGES +opt/csw/share/locale/hr +opt/csw/share/locale/hr/LC_MESSAGES +opt/csw/share/locale/hu +opt/csw/share/locale/hu/LC_MESSAGES +opt/csw/share/locale/id +opt/csw/share/locale/id/LC_MESSAGES +opt/csw/share/locale/it +opt/csw/share/locale/it/LC_MESSAGES +opt/csw/share/locale/ja +opt/csw/share/locale/ja/LC_MESSAGES +opt/csw/share/locale/ko +opt/csw/share/locale/ko/LC_MESSAGES +opt/csw/share/locale/locale.alias +opt/csw/share/locale/lt +opt/csw/share/locale/lt/LC_MESSAGES +opt/csw/share/locale/nl +opt/csw/share/locale/nl/LC_MESSAGES +opt/csw/share/locale/nn +opt/csw/share/locale/nn/LC_MESSAGES +opt/csw/share/locale/no +opt/csw/share/locale/no/LC_MESSAGES +opt/csw/share/locale/pl +opt/csw/share/locale/pl/LC_MESSAGES +opt/csw/share/locale/pt +opt/csw/share/locale/pt/LC_MESSAGES +opt/csw/share/locale/pt_BR +opt/csw/share/locale/pt_BR/LC_MESSAGES +opt/csw/share/locale/ro +opt/csw/share/locale/ro/LC_MESSAGES +opt/csw/share/locale/ru +opt/csw/share/locale/ru/LC_MESSAGES +opt/csw/share/locale/sk +opt/csw/share/locale/sk/LC_MESSAGES +opt/csw/share/locale/sl +opt/csw/share/locale/sl/LC_MESSAGES +opt/csw/share/locale/sp +opt/csw/share/locale/sp/LC_MESSAGES +opt/csw/share/locale/sr +opt/csw/share/locale/sr/LC_MESSAGES +opt/csw/share/locale/sv +opt/csw/share/locale/sv/LC_MESSAGES +opt/csw/share/locale/tr +opt/csw/share/locale/tr/LC_MESSAGES +opt/csw/share/locale/uk +opt/csw/share/locale/uk/LC_MESSAGES +opt/csw/share/locale/vi +opt/csw/share/locale/vi/LC_MESSAGES +opt/csw/share/locale/wa +opt/csw/share/locale/wa/LC_MESSAGES +opt/csw/share/locale/zh +opt/csw/share/locale/zh/LC_MESSAGES +opt/csw/share/locale/zh_CN +opt/csw/share/locale/zh_CN/LC_MESSAGES +opt/csw/share/locale/zh_CN.GB2312 +opt/csw/share/locale/zh_CN.GB2312/LC_MESSAGES +opt/csw/share/locale/zh_TW +opt/csw/share/locale/zh_TW/LC_MESSAGES +opt/csw/share/locale/zh_TW.Big5 +opt/csw/share/locale/zh_TW.Big5/LC_MESSAGES +opt/csw/share/man +); + +my @csw_dirs = qw(); +#my @csw_dirs = qw( +#etc/init.d +#etc/rc0.d +#etc/rc1.d +#etc/rc2.d +#etc/rc3.d +#etc/rcS.d +#opt/csw +#opt/csw/etc +#opt/csw/bin +#opt/csw/bin/sparcv8 +#opt/csw/bin/sparcv8plus +#opt/csw/bin/sparcv8plus+vis +#opt/csw/bin/sparcv9 +#opt/csw/sbin +#opt/csw/share +#opt/csw/share/doc +#opt/csw/share/locale +#opt/csw/share/man +#opt/csw/share/man/man1 +#opt/csw/share/man/man2 +#opt/csw/share/man/man3 +#opt/csw/share/man/man4 +#opt/csw/share/man/man5 +#opt/csw/share/man/man6 +#opt/csw/share/man/man7 +#opt/csw/share/man/man8 +#opt/csw/share/info +#opt/csw/lib +#opt/csw/lib/X11 +#opt/csw/lib/X11/app-defaults +#opt/csw/include +#opt/csw/libexec +#opt/csw/var +#); + +my @possible_scripts = qw(request checkinstall preinstall postinstall preremove postremove); + +my @sunwsprolocs = ('/opt/forte11x86/SUNWspro/bin', '/opt/forte11/SUNWspro/bin', '/opt/studio/SOS11/SUNWspro/bin', '/opt/studio/SOS10/SUNWspro/bin', '/opt/forte8/SUNWspro/bin', '/opt/SUNWspro/bin'); +my $builddir = $ENV{'BUILDDIR'} || '/opt/build/michael'; +my $packagedir = $ENV{'PACKAGEDIR'} || "${RealBin}/../packages"; +my $content = "/var/sadm/install/contents"; +my %options; # getopt + +# variables defined via eval +my $progname = undef; +my $version = undef; +my $buildroot = undef; +my $category = undef; +my $vendor = undef; +my $hotline = 'http://www.opencsw.org/bugtrack/'; +my $email = 'mich...@opencsw.org'; +my @sources = undef; +my $prepatch = undef; +my @patches = (); # default to no patches +my $copyright = undef; +my $build = undef; +my $suffix = undef; +my $rev = undef; +my $arch = undef; +my $osversion = undef; +my @packages = undef; +my @isaexecs = (); +my $sunwspropath = undef; +my %attributes = (); +my %seenpaths = (); +my %contents = (); + +# helper applications +my $tar = '/opt/csw/bin/gtar'; + +sub +prepare +{ + chdir($builddir) || die("can't change to $builddir"); + + foreach my $source (@sources) { + if (($source =~ /tar\.gz$/) + ||($source =~ /tgz$/) + ||($source =~ /tar\.Z$/)) { + system("/bin/gzcat ${RealBin}/../sources/${source} | ${tar} xf -"); + + } elsif ($source =~ /tar\.bz2$/) { + system("/bin/bzcat ${RealBin}/../sources/${source} | ${tar} xf -"); + + } elsif ($source =~ /tar$/) { + system("${tar} xf ${RealBin}/../sources/${source}"); + + } else { + die("don't know how to extrace ${source}"); + } + } + + if (defined($prepatch)) { + open(PREPATCH, "> $builddir/prepatch") || die ("can't create $builddir/prepatch: $!"); + print PREPATCH $prepatch; + close(PREPATCH); + system("chmod +x $builddir/prepatch"); + system("/bin/bash -x $builddir/prepatch"); + unlink("$builddir/prepatch"); + } + + foreach my $patch (@patches) { + chdir("$builddir/@{$patch}[1]") || die("can't change to $builddir/@{$patch}[1]"); + system("gpatch @{$patch}[2] < ${RealBin}/../sources/@{$patch}[0]"); + } +} + +sub probe_directory +{ + while (my $dir = shift) { + -d $dir && return $dir; + } + + return undef; +} + + +sub +isaexec +{ + foreach my $exec (@isaexecs) { + open(ISA, "> ${builddir}/isaexec.c") || die("can't create ${builddir}/isaexec.c for overwrite: $!"); + print ISA <<"EOF"; +#include <unistd.h> + +int +main(int argc, char *argv[], char *envp[]) +{ + return (isaexec("${exec}", argv, envp)); +} +EOF + close(ISA); + system("${sunwspropath}/cc -o ${buildroot}${exec} ${builddir}/isaexec.c"); + unlink("${builddir}/isaexec.c"); + } +} + +sub +build +{ + chdir($builddir) || die("can't change to $builddir"); + + open(BUILD, "> $builddir/build") || die ("can't create $builddir/build: $!"); + print BUILD $build; + close(BUILD); + system("chmod +x $builddir/build"); + system("/bin/bash -x $builddir/build"); + unlink("$builddir/build"); + isaexec(); + strip(); +} + +sub +compute_ownership +{ + my $path = shift; + my $perm = shift; + my $user = 'root'; + my $group = 'bin'; + + if (%attributes) { + $perm = $attributes{$path}->{perm} || $perm; + $user = $attributes{$path}->{user} || $user; + $group = $attributes{$path}->{group} || $group; + } + + return "$perm $user $group\n"; +} + +# This functions purpose is to get sure that all directories in /path/to/file +# are also in file list. It also accounts which filename was packaged in what +# package. So that it possible to warn the user if a file has been packaed in +# more than one package. + +sub +verify_path +{ + my $r = shift; + my $prototype = shift; + my $path = shift; + + push(@{$seenpaths{$path}}, "CSW$r->{pkgname}"); + + # Handle symlinks in the art of etc/rcS.d/K03cswsamba=../init.d + $path =~ s/=.*$//; + + while ('.' ne ($path = dirname($path))) { + if (! grep($_ =~ /^d none \/\Q${path}\E\s+/, @$prototype)) { + pkgproto($r, $prototype, `echo ${path} | pkgproto`); + } + } +} + +sub +pkgproto +{ + my $r = shift; + my $prototype = shift; + + while (my $line = shift) { + my @fields = split(/\s+/, $line); + if ($fields[0] eq 'd') { + # d none opt/csw 0755 sithglan icipguru + if ((! ($fields[2] =~ /\//)) || (grep($fields[2] eq $_, @csw_ignore)) ) { + # skip toplevel dirs (opt, etc, ...) + + } elsif (grep($fields[2] eq $_, @csw_dirs)) { + unshift(@$prototype, "$fields[0] $fields[1] /$fields[2] ? ? ?\n"); + } else { + unshift(@$prototype, "$fields[0] $fields[1] /$fields[2] " . compute_ownership("/$fields[2]", "$fields[3]")); + } + + } elsif ($fields[0] eq 'f') { + # f none opt/csw 0755 sithglan icipguru + push(@$prototype, "$fields[0] $fields[1] /$fields[2] " . compute_ownership("/$fields[2]", "$fields[3]")); + verify_path($r, $prototype, $fields[2]); + + } elsif ( ($fields[0] eq 's') + ||($fields[0] eq 'l')) { + push(@$prototype, "$fields[0] $fields[1] /$fields[2]\n"); + verify_path($r, $prototype, $fields[2]); + } else { + die ("unknown line: <$line>"); + } + } +} + +sub +generate_prototype +{ + my $r = shift; + + my @prototype = (); + + chdir($buildroot) || die("can't change to ${buildroot}: $!"); + push(@prototype, "i pkginfo\n"); + push(@prototype, "i depend\n"); + if (defined(${copyright})) { + -f "$builddir/${copyright}" || die("can't find copyrightfile: $!"); + system("cp $builddir/${copyright} copyright"); + push(@prototype, "i copyright\n"); + } + foreach my $file (@possible_scripts) { + if (defined($r->{"$file"})) { + -f "${RealBin}/../sources/$r->{$file}" || die("can't find $file: $!"); + system("cp -f ${RealBin}/../sources/$r->{$file} $file"); + push(@prototype, "i $file\n"); + } + } + + my @dirs = `gfind @{$r->{filelist}} -type d | sort | uniq | pkgproto`; + pkgproto($r, \...@prototype, @dirs); + my @links = `gfind @{$r->{filelist}} -type l | sort | uniq | pkgproto`; + pkgproto($r, \...@prototype, @links); + my @files = `gfind @{$r->{filelist}} -type f | sort | uniq | pkgproto`; + pkgproto($r, \...@prototype, @files); + + open(PROTOTYPE, "> ${buildroot}/prototype") || die("can't open ${buildroot}/prototype for overwrite: $!"); + print PROTOTYPE @prototype; + close(PROTOTYPE); +} + +sub +uniq +{ + my %hash; @ha...@_} = (); + return sort keys %hash; +} + +sub +write_dependencies +{ + my $r = shift || die("one reference expected"); + + my @out = `pkginfo`; + my %pkg = (); + foreach my $line (@out) { + if ($line =~ /^[^\s]+\s+([^\s]+)\s+([^\s].*)/) { + $pkg{$1} = "$2"; + } + } + + open(DEP, '> depend') || die("can't open depend file: $!"); + + foreach my $dep (@{$r->{dependencies}}) { + if (! defined($pkg{$dep})) { + print STDERR "WARNING: FAKEING dependency for <$dep>\n"; + $pkg{$dep} = 'common - THIS IS A FAKE DEPENDENCY'; + } + print DEP "P $dep $pkg{$dep}\n"; + } + + if (defined($r->{incompatibilities})) { + foreach my $inc (@{$r->{incompatibilities}}) { + if (! defined($pkg{$inc})) { + print STDERR "WARNING: FAKEING incompatibiltie for <$inc>\n"; + $pkg{$inc} = 'common - THIS IS A FAKE INCOMPATIBILTY'; + } + print DEP "I $inc $pkg{$inc}\n"; + } + } + + close(DEP); +} + +sub +resolve_link +{ + my $file = shift || die ("one argument expected"); + my $count = 0; + + chomp($file); + + while ((-l $file) + && ($count < 10)) { + my $dirname = dirname($file); + $file = readlink($file); + if(! ($file =~ /^\//)) { + $file = $dirname . '/' . $file; + } + $count++; + } + + return $file; +} + +sub +a1minusa2 +{ + my ($a1,$a2) = @_; + my %h; + @h...@$a2} = (1) x @$a2; + return grep {!exists $h{$_}} @$a1; +} + +sub +populate_contents +{ + open(FILE, ${content}) || die("can't open ${content}: $!"); + for my $line (<FILE>) { + # /etc/cron.d/queuedefs f none 0644 root sys 17 1164 1018133064 SUNWcsr + # 0 1 2 3 4 5 6 7 8 9 + my @array = split(/\s+/, $line); + my ($file, $type, @packages) = @array[0, 1, 9 ... $#array]; + if ($type =~ /^f$/) { + push(@{$contents{$file}}, @packages); + } + } + close(FILE); +} + +sub +find_dependencies +{ + my $r = shift || die("one reference expected"); + populate_contents(); + + chdir(${buildroot}) || die("can't change to ${buildroot}: $!"); + # look for shared libaries + my @deps = `gfind @{$r->{filelist}} \\( -type f -perm +111 \\) -o -path opt/csw/lib/\\*.so\\* | xargs ldd 2> /dev/null | grep -v 'file not found' 2> /dev/null | grep '=>' | awk '{print \$3}'`; + + # look for bangs + my @files = `gfind @{$r->{filelist}} -type f -perm +111`; + foreach my $file (@possible_scripts) { + -f "${buildroot}/${file}" && push(@files, "${buildroot}/${file}"); + } + foreach my $file (@files) { + chomp($file); + open(FILE, $file) || die("can't open ${file}: $!"); + my $firstline = <FILE>; + if ($firstline =~ /^#!\s?([^\s]+)/) { + push(@deps, "$1\n"); + } + close(FILE); + } + + # resolve symlinks / substitute + @deps = uniq(@deps); + for my $element (@deps) { + # /bin and /lib are packages in /usr/{bin,lib} + $element =~ s#^/bin#/usr/bin#; + $element =~ s#^/lib#/usr/lib#; + # /opt/csw/lib/sparcv8 is a symlink to . + $element =~ s#^/opt/csw/lib/sparcv8#/opt/csw/lib#; + # Resolve links if necessary + $element = resolve_link($element); + } + + # get dependencies + foreach my $dep (@deps) { + # </usr/lib/../openwin/lib/libX11.so.4> + $dep =~ s#\w+\/\.\.##g; + + if (defined($contents{$dep})) { + push(@{$r->{dependencies}}, @{$contents{$dep}}); + } + } + + # make them uniq and don't include a dependency to the packet itself + @{$r->{dependencies}} = grep("CSW$r->{pkgname}" ne $_, uniq(@{$r->{dependencies}})); + + if (defined($r->{exclude_dependencies})) { + @{$r->{dependencies}} = a1minusa2($r->{dependencies}, $r->{exclude_dependencies}); + } + + write_dependencies($r); +} + +sub +strip +{ + system("/usr/ccs/bin/strip ${buildroot}/opt/csw/bin/* ${buildroot}/opt/csw/bin/sparcv8/* ${buildroot}/opt/csw/bin/sparcv8plus/* ${buildroot}/opt/csw/bin/sparcv8plus+vis/* ${buildroot}/opt/csw/bin/sparcv9/* 2> /dev/null"); +} + +sub +generate_pkginfo +{ + my $r = shift || die("one reference expected"); + + chdir(${buildroot}) || die("can't change to ${buildroot}: $!"); + open(PKGINFO, '> pkginfo'); + +print PKGINFO <<"EOF"; +PKG=CSW$r->{pkgname} +NAME=$r->{name} +ARCH=${arch} +CATEGORY=${category} +VERSION=${version} +VENDOR=${vendor} +HOTLINE=${hotline} +EMAIL=${email} +EOF +# DESC=[Optional extra info about software. Omit this line if you wish] + close(PKGINFO); +} + +sub +actually_package +{ + my $r = shift || die("one reference expected"); + + my $filename="$r->{filename}-${version}-SunOS${osversion}-${arch}-CSW.pkg"; + + chdir(${buildroot}) || die("can't change to ${buildroot}: $!"); + system("/usr/bin/pkgmk -o -r ${buildroot}"); + system("/usr/bin/pkgtrans -s /var/spool/pkg ${packagedir}/$filename CSW$r->{pkgname}"); + unlink("${packagedir}/${filename}.gz"); + system("/usr/bin/gzip ${packagedir}/$filename"); + system("rm -rf /var/spool/pkg/CSW$r->{pkgname}"); +} + +# This function makes all files not readable by me readable. This is because +# the bang checker and pkgmk needs this. The correct permissions are allready +# in pkginfo file so everything is as it should be. + +sub +make_all_files_readable_by_user +{ + my $r = shift || die("one reference expected"); + + chdir(${buildroot}) || die("can't change to ${buildroot}: $!"); + system("gfind @{$r->{filelist}} -perm -400 -o -print | xargs -x -n 1 chmod u+r"); +} + +sub +mkpackage +{ + foreach my $r (@packages) { + generate_prototype($r); + make_all_files_readable_by_user($r); + generate_pkginfo($r); + find_dependencies($r); + actually_package($r); + } + + foreach my $key (keys(%seenpaths)) { + if (1 < @{$seenpaths{$key}}) { + print "$key -> @{$seenpaths{$key}}\n"; + } + } +} + +if (! (-d $builddir)) { + mkdir("$builddir", 0755) || die("can't create $builddir: $!"); +} + +#main +# { + +if (! GetOptions(\%options, "p", "b", "c", "s", "u", "rev=s")) { + print <<"__EOF__"; +${RealBin}/${RealScript} [-p] [-b] [-c] [-s] specfile ... + + -p prepare: extract and patch sources + -b build: build and install sources into destenation + -c create: create package + -s show: show build script and exit (high precedence!) + -u cleanUp: remove ${builddir} + -rev <rev> use <rev> instead of current date + + If no parameter is specified. The given specfile is processed. (eg. + prepared, build and packaged) +__EOF__ + exit(1); +} + +# Unset makeflags +$ENV{'MFLAGS'} = ''; +$ENV{'MAKEFLAGS'} = ''; + +my $infile = shift || die('one argument expected'); + +if (! defined($arch)) { + $arch = `/bin/uname -p` || die("can't get arch: $!"); + chomp($arch); +} + +$sunwspropath = probe_directory(@sunwsprolocs) || die ("couldn't find SUNWspro"); + +eval `/bin/cat $infile`; + +if (! defined($rev)) { + $rev = $options{'rev'} || $ENV{'REV'} || `/bin/date '+20%y.%m.%d'`; +} +chomp ($rev); + +$version .= ',REV=' . ${rev}; + +if (defined($suffix)) { + $version .= $suffix; +} + +if (! defined($osversion)) { + $osversion = `/bin/uname -r`; + chomp($osversion); +} + +if (! -d "${packagedir}") { + system("/bin/mkdir -p ${packagedir}"); +} + +if (! keys(%options)) { + prepare(); + build(); + mkpackage(); + exit(); +} + +if (defined($options{'s'})) { + print $build; + exit(); +} + +if (defined($options{'p'})) { + prepare(); +} + +if (defined($options{'b'})) { + build(); +} + +if (defined($options{'c'})) { + mkpackage(); +} + +if (defined($options{'u'})) { + system("/bin/rm -rf ${builddir}"); +} + +# } Added: csw/mgar/pkg/gal2/trunk/legacy/specs/Makefile =================================================================== --- csw/mgar/pkg/gal2/trunk/legacy/specs/Makefile (rev 0) +++ csw/mgar/pkg/gal2/trunk/legacy/specs/Makefile 2009-04-27 12:41:23 UTC (rev 4503) @@ -0,0 +1,28 @@ +PACKAGES := $(shell find . -type f | sed "s/^.\///" | grep -v Makefile) + +PREPARE := $(PACKAGES:=.p) +BUILD := $(PACKAGES:=.b) +CREATE := $(PACKAGES:=.c) +SHOW := $(PACKAGES:=.s) + +clean: ../scripts/pkghelper.pl + @echo Do you really want to do this\? Press Ctrl-C to abort + @read LUTZ + @../scripts/pkghelper.pl -u + +$(PACKAGES): ../scripts/pkghelper.pl + @../scripts/pkghelper.pl $@ + +$(PREPARE): ../scripts/pkghelper.pl + @../scripts/pkghelper.pl -p $(subst .p,,$@) + +$(BUILD): ../scripts/pkghelper.pl + @../scripts/pkghelper.pl -b $(subst .b,,$@) + +$(CREATE): ../scripts/pkghelper.pl + @../scripts/pkghelper.pl -c $(subst .c,,$@) + +$(SHOW): ../scripts/pkghelper.pl + @../scripts/pkghelper.pl -s $(subst .s,,$@) + +.PHONY: $(PACKAGES) Added: csw/mgar/pkg/gal2/trunk/legacy/specs/gal2 =================================================================== --- csw/mgar/pkg/gal2/trunk/legacy/specs/gal2 (rev 0) +++ csw/mgar/pkg/gal2/trunk/legacy/specs/gal2 2009-04-27 12:41:23 UTC (rev 4503) @@ -0,0 +1,57 @@ +# vim: ft=perl +# $Id: gal2,v 1.11 2005/04/13 15:17:11 simigern Exp $ + +$progname = 'gal'; +$version = '2.4.2'; + +$buildroot = "${builddir}/${progname}-${version}-buildroot"; + +$category = 'application'; +$vendor = 'http://ftp.gnome.org/pub/GNOME/sources/gal/ packaged for CSW by Michael Gernoth'; + +...@sources = ("${progname}-${version}.tar.bz2"); + +...@patches = (['filename.patch', "${progname}-${version}", '-p0']); + +$progname = $progname."2"; + +...@packages = ({ + pkgname => $progname, + filename => $progname, + name => "$progname - GNOME Application Libs", + dependencies => ['CSWcommon'], + filelist => [qw(opt)], + exclude_dependencies => ['SUNWfreetype2','SUNWgnome-base-libs','SUNWgnome-libs','SUNWgnome-audio','SUNWgnome-component','SUNWgnome-config','SUNWgnome-vfs','SUNWlibpopt'] + }); + +$copyright = "gal-${version}/COPYING.LIB"; + +$build = <<"EOF"; +export CC=cc +export CXX=CC +export PATH="${sunwspropath}:/usr/ccs/bin:/usr/bin:/usr/openwin/bin:/opt/csw/bin" +if [ "${arch}" = "sparc" ]; then + export CFLAGS='-fast -xarch=v8' +else + export CFLAGS='-xO3 -xspace -xarch=386' +fi +export CFLAGS="\$CFLAGS -I/opt/csw/include" +export CPPFLAGS='-I/opt/csw/include' +export LD_OPTIONS='-L${buildroot}/opt/csw/lib -R/opt/csw/lib -L/opt/csw/lib -L${buildroot}/opt/csw/lib' +export LDFLAGS='-L${buildroot}/opt/csw/lib -R/opt/csw/lib -L/opt/csw/lib -L${buildroot}/opt/csw/lib' +cd gal-${version} +export PATH="${sunwspropath}:/usr/ccs/bin:/opt/csw/bin:/usr/bin:/usr/openwin/bin" +./configure --prefix=/opt/csw --mandir=/opt/csw/share/man --infodir=/opt/csw/share/info +export PATH="${sunwspropath}:/usr/ccs/bin:/usr/bin:/usr/openwin/bin:/opt/csw/bin" +gmake || exit 1 +gmake DESTDIR=${buildroot} install + +#remove mess from libtool-archives +for i in ${buildroot}/opt/csw/lib/*.la; do + if [ -f "\${i}" ]; then + sed -e "s|[^ ]*${buildroot}[^ ]* *||g" "\${i}" >"\${i}.newbuild" && mv "\${i}.newbuild" "\${i}" + fi +done + + +EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ devel mailing list devel@lists.opencsw.org https://lists.opencsw.org/mailman/listinfo/devel