Author: sip
Date: 2006-04-23 16:55:54 +0200 (Sun, 23 Apr 2006)
New Revision: 1286
Added:
tools/prt-utils/trunk/pkgfoster.1
tools/prt-utils/trunk/portspage.1
tools/prt-utils/trunk/prtcheckmissing.1
Removed:
tools/prt-utils/trunk/prtdownload
Modified:
tools/prt-utils/trunk/CHANGES
tools/prt-utils/trunk/Makefile
tools/prt-utils/trunk/TODO
tools/prt-utils/trunk/oldfiles
tools/prt-utils/trunk/oldfiles.1
Log:
merged oldfiles with Mark Rosenstrand's script, added missing manpages, prepare for release
Modified: tools/prt-utils/trunk/CHANGES
===================================================================
--- tools/prt-utils/trunk/CHANGES 2006-04-23 10:30:25 UTC (rev 1285)
+++ tools/prt-utils/trunk/CHANGES 2006-04-23 14:55:54 UTC (rev 1286)
@@ -1,7 +1,9 @@
-0.7.1 -> XXX
+0.7.1 -> 0.8.0
- Added revdep by Johannes Winkelmann
- Added portspage by Jukka Heino
- Added pkgfoster by Jukka Heino
+- oldfiles: merged with pkgclean by Mark Rosenstand;
+ added custom keep list /etc/oldfiles.conf
0.7.0 -> 0.7.1
- Removed warnings from oldfiles
Modified: tools/prt-utils/trunk/Makefile
===================================================================
--- tools/prt-utils/trunk/Makefile 2006-04-23 10:30:25 UTC (rev 1285)
+++ tools/prt-utils/trunk/Makefile 2006-04-23 14:55:54 UTC (rev 1286)
@@ -1,5 +1,5 @@
NAME = prt-utils
-VERSION = 0.7.1
+VERSION = 0.8.0
TOOLS = prtcreate prtrej prtsweep prtcheck prtwash pkgexport pkgsize \
prtorphan prtcheckmissing oldfiles finddeps dllist \
Modified: tools/prt-utils/trunk/TODO
===================================================================
--- tools/prt-utils/trunk/TODO 2006-04-23 10:30:25 UTC (rev 1285)
+++ tools/prt-utils/trunk/TODO 2006-04-23 14:55:54 UTC (rev 1286)
@@ -1,2 +1,4 @@
-- rewrite / improve prtalien. Will re-add the script to cvs when it's
- kinda stable(TM) (sip).
+- create general prt-utils man page with brief description
+ of all the tools
+- ditch prtsweep or merge it with prtwash
+ - reimplement prtwash in perl?
Modified: tools/prt-utils/trunk/oldfiles
===================================================================
--- tools/prt-utils/trunk/oldfiles 2006-04-23 10:30:25 UTC (rev 1285)
+++ tools/prt-utils/trunk/oldfiles 2006-04-23 14:55:54 UTC (rev 1286)
@@ -2,16 +2,20 @@
#
# oldfiles - show outdated packages and sources for a CRUX system
#
-# by Simone Rota <sip(a)varlock.com>
+# by Simone Rota <sip(a)varlock.com>,
+# Mark Rosenstand <mark(a)borkware.net>
# License: GNU GPL v2
#
# Requires prt-get by Johannes Winkelmann
-#use warnings;
+use warnings;
use strict;
-use File::Basename;
my %options = %{getoptions(@ARGV)};
+my $pkgdir = "";
+my $srcdir = "";
+my %wanted;
+my %keepme;
# Cannot specify -p -s together (use no options instead)
if ( $options{"-p"} && $options{"-s"} ) {
@@ -25,119 +29,75 @@
$options{"-s"} = 1;
}
-my $PKGMK_PACKAGE_DIR = "";
-my $PKGMK_SOURCE_DIR = "";
-
# Read pkgmk.conf
-open(my $cfgfile, "/etc/pkgmk.conf") or die "Couldn't open /etc/pkgmk.conf";
-while (<$cfgfile>){
- my $line = $_;
- chomp($line);
- $line =~ /^PKGMK_PACKAGE_DIR="(.*?)"|^PKGMK_SOURCE_DIR="(.*?)"/;
- if ($1){
- $PKGMK_PACKAGE_DIR = $1;
- }
- if ($2){
- $PKGMK_SOURCE_DIR = $2;
- }
+open CONFIG, "/etc/pkgmk.conf" or die "Could not open /etc/pkgmk.conf";
+while (<CONFIG>) {
+ $srcdir = $1 if m/^PKGMK_SOURCE_DIR="(.*)"\n/;
+ $pkgdir = $1 if m/^PKGMK_PACKAGE_DIR="(.*)"\n/;
}
-close($cfgfile) or die "Could not close /etc/pkgmk.conf";
+close CONFIG;
# Check if dirs are specified / exists
if ( $options{"-p"} ) {
- if ($PKGMK_PACKAGE_DIR eq ""){
+ if ($pkgdir eq ""){
print "error: no PKGMK_PACKAGE_DIR specified in /etc/pkgmk.conf\n";
exit 1;
} else {
- if (! -d $PKGMK_PACKAGE_DIR) {
- print "error: $PKGMK_PACKAGE_DIR is not a directory\n";
+ if (! -d $pkgdir) {
+ print "error: $pkgdir is not a directory\n";
exit 1;
}
}
}
if ( $options{"-s"} ) {
- if ($PKGMK_SOURCE_DIR eq ""){
+ if ($srcdir eq ""){
print "error: no PKGMK_PACKAGE_DIR specified in /etc/pkgmk.conf\n";
exit 1;
} else {
- if (! -d $PKGMK_SOURCE_DIR) {
- print "error: $PKGMK_SOURCE_DIR is not a directory\n";
+ if (! -d $srcdir) {
+ print "error: $srcdir is not a directory\n";
exit 1;
}
}
}
-# Found / current packages and sources
-my @packages;
-my @cpackages = ();
-my @sources;
-my @csources = ();
-
-# Current / found packages, current / found sources
-if ( $options{"-p"} ) {
- my $packages = `find $PKGMK_PACKAGE_DIR -maxdepth 1 -type f`;
- @packages=split("\n", $packages);
-}
-if ( $options{"-s"} ) {
- my $sources = `find $PKGMK_SOURCE_DIR -maxdepth 1 -type f`;
- @sources=split("\n", $sources);
-}
-
-# Get all ports through prt-get
-my @ports = `prt-get printf "%n|%v|%r|%p\n"`;
-
-foreach my $port (@ports) {
- my ($name, $version, $release, $path) = split(/\|/, $port);
- chop($path);
-
- # Add current package
+# Collect curent sources / packages
+foreach (split('\n', `prt-get printf "%p:%n:%v:%r\n"`)) {
+ my ($path, $name, $version, $release) = split(':', $_, 4);
if ( $options{"-p"} ) {
- push(@cpackages, "$PKGMK_PACKAGE_DIR/$name#$version-$release.pkg.tar.gz");
+ $wanted{$pkgdir}{"$name\#$version-$release.pkg.tar.gz"} = 1;
}
-
- # Add current source(s)
if ( $options{"-s"} ) {
- # Read Pkgfile
- my $pkgfilename = "$path\/$name\/Pkgfile";
- open FILE, "< $pkgfilename" or die "Couldn't open $pkgfilename";
- local $/ = undef;
- my $pkgfile = <FILE>;
- close FILE;
-
- # Parse sources from Pkgfile
- $pkgfile =~ s/\s{1,}/ /gi; # remove multiple spaces
- $pkgfile =~ s/\n//g; # remove newlines
- $pkgfile =~ s/\\//g; # remove '\'
- $pkgfile =~ /source=\((.*?)\)/; # get source array contents
- $pkgfile = $1; # prepare some tea
- # Add url(s)
- my @psources = split(" ", $pkgfile);
- foreach my $url (@psources) {
- my @split = glob($url);
- foreach my $s (@split) {
- $s =~ s/\$name/$name/g; # substitute $name
- $s =~ s/\$version/$version/g; # substitute $version
- $s =~ s/\$release/$release/g; # substitute $release
- push(@csources, "$PKGMK_SOURCE_DIR/".basename($s));
- }
+ open MD5SUMS, "$path/$name/.md5sum" or next;
+ while (<MD5SUMS>) {
+ m/^[a-z0-9]{32}\s\s(\S+)\n/;
+ $wanted{$srcdir}{$1} = 1;
}
+ close MD5SUMS;
}
-
+}
-} # foreach my $port
-
-
-# Print outdated packages
-if ( $options{"-p"} ) {
- printdiff(\@packages,\@cpackages);
+# Keep user-specified files
+if ( -f "/etc/oldfiles.conf") {
+ my $keep;
+ open KEEPME, "/etc/oldfiles.conf" or die "Could not open /etc/oldfiles.conf";
+ while ($keep = <KEEPME>) {
+ chomp($keep);
+ $keepme{$keep} = 1;
+ }
}
+close KEEPME;
-# Print outdated sources
-if ( $options{"-s"} ) {
- printdiff(\@sources,\@csources);
+# Display unwanted files
+foreach my $dir (keys %wanted) {
+ opendir DIR, $dir;
+ foreach (readdir DIR) {
+ next if ($_ eq '.' or $_ eq '..');
+ print "$dir/$_\n" unless ($wanted{$dir}{$_} or $keepme{"$dir/$_"});
+ }
+ closedir DIR;
}
-
######################## subroutines ########################
# Adapted from Martin Opel's prtorphan script
@@ -162,22 +122,3 @@
sub usage {
print "usage: oldfiles [-p|-s]\n";
}
-
-# Print differences between two lists
-# (from O'Reilly Perl Cookbook)
-sub printdiff {
- my ($A,$B) = @_;
- my @A = @{$A};
- my @B = @{$B};
- my %seen; # lookup table
- my @aonly;# answer
- @seen{@B} = (); # build lookup table
-
- foreach my $item (@A) {
- unless ( exists $seen{$item} ) {
- push(@aonly, $item);
- $seen{$item} = 1;
- print "$item\n";
- }
- }
-}
Modified: tools/prt-utils/trunk/oldfiles.1
===================================================================
--- tools/prt-utils/trunk/oldfiles.1 2006-04-23 10:30:25 UTC (rev 1285)
+++ tools/prt-utils/trunk/oldfiles.1 2006-04-23 14:55:54 UTC (rev 1286)
@@ -1,43 +1,55 @@
." Text automatically generated by txt2man-1.4.7
-.TH oldfiles "October 22, 2004" "" ""
+.TH oldfiles 1 "April 23, 2006" "" ""
.SH NAME
\fBoldfiles \fP- display old packages and sources
\fB
.SH SYNOPSIS
.nf
.fam C
-\fBoldfiles\fP [-p|-s]
+\fBoldfiles\fP [\fB-p\fP|\fB-s\fP]
.fam T
.fi
.SH DESCRIPTION
-Oldfiles is a script to list outdated packages and sources on a
-CRUX system with central binary and sources directories.
-The variables PKGMK_SOURCE_DIR and PKGMK_PACKAGE_DIR have to
-be enabled into /etc/pkgmk.conf. See \fBpkgmk\fP(8) for details.
+Oldfiles is a script to list outdated packages and sources on a CRUX system with central binary and sources
+directories. The variables PKGMK_SOURCE_DIR and PKGMK_PACKAGE_DIR have to be enabled into /etc/pkgmk.conf. See
+\fBpkgmk\fP(8) for details.
.PP
\fBprt-get\fP(8) is used to build the port list.
.SH OPTIONS
.TP
.B
--p
+\fB-p\fP
list only outdated packages
.TP
.B
--s
+\fB-s\fP
list only outdated sources
-.PP
-Note that the -p and -s options are mutually exclusive: pass no
-options to list both packages and sources.
+Note that the \fB-p\fP and \fB-s\fP options are mutually exclusive: pass no options to list both packages and sources.
.SH EXAMPLES
.TP
.B
-\fBoldfiles\fP -p
+\fBoldfiles\fP \fB-p\fP
will list all outdated packages.
.TP
.B
\fBoldfiles\fP | xargs rm
-will remove all outdated packages and sources.
+will remove all outdated packages and sources.
+.SH CONFIGURATION
+\fBoldfiles\fP looks for the file /etc/oldfiles.conf (if present) that contains
+a list of files that should be kept. The format is a simple list of filenames
+(full path required), ie:
+.PP
+.nf
+.fam C
+ /usr/sources/someport-1.3.tar.gz
+ /usr/packages/someport#1.3.pkg.tar.gz
+ /usr/packages/index.html
+
+.fam T
+.fi
.SH AUTHORS
Simone Rota <sip(a)varlock.com>
+.PP
+Mark Rosenstand <mark(a)borkware.net>
.SH SEE ALSO
\fBpkgmk\fP(8), \fBprt-get\fP(8)
Added: tools/prt-utils/trunk/pkgfoster.1
===================================================================
--- tools/prt-utils/trunk/pkgfoster.1 (rev 0)
+++ tools/prt-utils/trunk/pkgfoster.1 2006-04-23 14:55:54 UTC (rev 1286)
@@ -0,0 +1,22 @@
+." Text automatically generated by txt2man-1.4.7
+.TH pkgfoster 1 "April 23, 2006" "" ""
+.SH NAME
+\fBpkgfoster \fP- clean orphaned packages
+\fB
+.SH SYNOPSIS
+.nf
+.fam C
+\fBpkgfoster\fP
+.fam T
+.fi
+.SH DESCRIPTION
+\fBpkgfoster\fP is a simple script you can use to clean up orphaned packages (i.e.
+packages which no other package depends on). It uses prt-cache by default, so
+remember to build the cache with "prt-get cache". You can also use normal
+prt-get by modifying the PRT_GET variable. List of packages to keep
+are stored in ~/.keepers. Packages from base are never considered for
+deletion.
+.SH AUTHORS
+Jukka Heino <jukka(a)karsikkopuu.net>
+.SH SEE ALSO
+\fBprt-cache\fP(8)
Added: tools/prt-utils/trunk/portspage.1
===================================================================
--- tools/prt-utils/trunk/portspage.1 (rev 0)
+++ tools/prt-utils/trunk/portspage.1 2006-04-23 14:55:54 UTC (rev 1286)
@@ -0,0 +1,48 @@
+." Text automatically generated by txt2man-1.4.7
+.TH portspage 1 "April 23, 2006" "" ""
+.SH NAME
+\fBportspage \fP- generate html listing for a port directory
+\fB
+.SH SYNOPSIS
+.nf
+.fam C
+\fBportspage\fP [\fIOPTION\fP] [\fIDIRECTORY\fP]
+.fam T
+.fi
+.SH DESCRIPTION
+Portspage generates a html index for a directory containing ports.
+.SH OPTIONS
+.TP
+.B
+\fB--title\fP=TITLE
+set the page title
+.TP
+.B
+\fB--header\fP=FILE
+name of file to insert before port listing
+.TP
+.B
+\fB--footer\fP=FILE
+name of file to insert after port listing
+.TP
+.B
+\fB--timestamp-accuracy\fP=LEVEL
+0 = no timestamp, 1 = date only, 2 = date and time (default is 1)
+.TP
+.B
+\fB--date-from-file\fP
+take date from newest file instead of directory
+.TP
+.B
+\fB--date-from-pkgfile\fP
+take date from Pkgfile instead of directory
+.TP
+.B
+\fB--version\fP
+output version information and exit
+.SH EXAMPLES
+\fBportspage\fP \fB--header\fP=/path/to/portspage.header /usr/ports/mine > /usr/ports/mine/index.html
+.SH AUTHORS
+Jukka Heino <jukka(a)karsikkopuu.net>
+.SH SEE ALSO
+\fBports\fP(8)
Added: tools/prt-utils/trunk/prtcheckmissing.1
===================================================================
--- tools/prt-utils/trunk/prtcheckmissing.1 (rev 0)
+++ tools/prt-utils/trunk/prtcheckmissing.1 2006-04-23 14:55:54 UTC (rev 1286)
@@ -0,0 +1,19 @@
+." Text automatically generated by txt2man-1.4.7
+.TH prtcheckmissing 1 "April 23, 2006" "" ""
+.SH NAME
+\fBprtcheckmissing \fP- check for missing files
+\fB
+.SH SYNOPSIS
+.nf
+.fam C
+\fBprtcheckmissing\fP
+.fam T
+.fi
+.SH DESCRIPTION
+\fBprtcheckmissing\fP checks for missing files comparing
+the installed files on the system with the ones listed
+in the pkgutils database.
+.SH AUTHORS
+Martin Opel <mo(a)obbl.net>
+.SH SEE ALSO
+\fBpkginfo\fP(8)
Deleted: tools/prt-utils/trunk/prtdownload
===================================================================
--- tools/prt-utils/trunk/prtdownload 2006-04-23 10:30:25 UTC (rev 1285)
+++ tools/prt-utils/trunk/prtdownload 2006-04-23 14:55:54 UTC (rev 1286)
@@ -1,58 +0,0 @@
-#!/bin/bash
-#
-# $Id: prtdownload,v 1.1.1.1 2003/08/27 11:43:05 opel Exp $
-# (c) 2002, 2003 by Martin Opel <martin(a)obbl-net.de>
-#
-# May be redistributed and modified under the terms of the GPL
-# only usable with CRUX Linux, version 1.0 or higher
-#
-# USE AT YOUR OWN RISK
-#
-# This script scans your supfiles in /etc/ports to find out your port
-# directories and then runs through your ports directories and tries to
-# execute "pkgmk -do" for all ports. See "man 1 prtdownload" for details.
-#
-
-info() {
- echo -e "=======> $@"
-}
-
-error() {
- info "ERROR: $@"
-}
-
-interrupted() {
- info "exiting..."
- exit 1
-}
-
-getportdirs() {
- for sup in /etc/ports/supfile.*; do
- prefix=`cat $sup | grep "*default prefix=" | awk -F= '{ print $2 }'`
- dirs=`cat $sup | grep -v "^#" | grep -v "^\$" | grep -v "^*"`
- for dir in $dirs; do
- echo $prefix/$dir
- done
- done
-}
-
-prtdownload() {
- savedir=`pwd`
- cd $1
- for dir in *; do
- if [ -d $dir ]; then
- (
- cd $dir
- info "downloading `pwd`"
- pkgmk -do
- )
- fi
- done
- cd $savedir
-}
-
-trap "interrupted" SIGHUP SIGINT SIGQUIT SIGTERM
-
-for dir in `getportdirs`; do
- `basename $0` $dir
-done