summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimone Rota <sip@crux.nu>2006-04-08 17:04:19 +0000
committerSimone Rota <sip@crux.nu>2006-04-08 17:04:19 +0000
commitb2ec2a0e4228961c783b012b2b3376bdfa61b1a0 (patch)
tree5b93f81ecea6f546952128ee8c1a7b099ce1398f
parent5132e8c38851ac8e70ea3fc5f65b853402500eef (diff)
downloadprt-utils-b2ec2a0e4228961c783b012b2b3376bdfa61b1a0.tar.gz
prt-utils-b2ec2a0e4228961c783b012b2b3376bdfa61b1a0.tar.xz
added pkgfoster and portspage by Jukka Heino
-rw-r--r--CHANGES4
-rw-r--r--Makefile2
-rwxr-xr-xpkgfoster57
-rwxr-xr-xportspage324
4 files changed, 385 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 3f8c80e..6f9ca0b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
0.7.1 -> XXX
-- Added revdep script by Johannes Winkelmann
+- Added revdep by Johannes Winkelmann
+- Added portspage by Jukka Heino
+- Added pkgfoster by Jukka Heino
0.7.0 -> 0.7.1
- Removed warnings from oldfiles
diff --git a/Makefile b/Makefile
index ad9763f..3fc5537 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ VERSION = 0.7.1
TOOLS = prtcreate prtrej prtsweep prtcheck prtwash pkgexport pkgsize \
prtorphan prtcheckmissing oldfiles finddeps dllist \
- findredundantdeps pkg_installed revdep
+ findredundantdeps pkg_installed revdep portspage pkgfoster
PREFIX = /usr
MANDIR = $(PREFIX)/man
diff --git a/pkgfoster b/pkgfoster
new file mode 100755
index 0000000..71e0efc
--- /dev/null
+++ b/pkgfoster
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# pkgfoster 2005-11-27
+# Jukka Heino <jukka@karsikkopuu.net>
+#
+# pkgfoster 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.
+#
+
+PRT_GET=prt-cache
+PKGRM="sudo pkgrm"
+BASE="autoconf automake bash bin86 binutils bison bzip2 coreutils cpio db dcron devfsd diffutils e2fsprogs ed file filesystem findutils flex gawk gcc gdbm glibc grep groff gzip kbd less libtool lilo m4 make man man-pages mktemp module-init-tools nasm ncurses net-tools netkit-base patch perl pkgutils procps psmisc rc readline reiserfsprogs sed sendmail shadow slocate sysklogd sysvinit tar tcp_wrappers tcsh time traceroute util-linux vim wget which zlib"
+
+touch ~/.keepers
+
+echo "Checking packages for orphans..."
+
+while true ; do
+
+ RECHECK=0
+
+ for PACKAGE in $($PRT_GET listinst) ; do
+
+ if [ -z "$(grep ^$PACKAGE$ ~/.keepers)" ] && \
+ [ -z "$(echo "$BASE" | tr ' ' '\n' | grep ^$PACKAGE$)" ] && \
+ [ -z "$($PRT_GET dependent $PACKAGE)" ] ; then
+
+ echo
+ $PRT_GET info $PACKAGE
+ echo
+
+ echo -n "Uninstall $PACKAGE? (y/N) "
+ read ANSWER
+
+ if [ "$ANSWER" == "y" ] ; then
+ $PKGRM $PACKAGE
+ RECHECK=1
+ else
+ echo $PACKAGE >> ~/.keepers
+ fi
+
+ fi
+
+ done
+
+ if [ "$RECHECK" == "0" ] ; then
+ exit 0
+ fi
+
+ echo
+ echo "Re-checking packages for new orphans..."
+
+done
diff --git a/portspage b/portspage
new file mode 100755
index 0000000..5da14c5
--- /dev/null
+++ b/portspage
@@ -0,0 +1,324 @@
+#!/usr/bin/perl -w
+
+our $version = "1.0.4";
+
+########################################################################
+#
+# portspage (http://www.karsikkopuu.net/crux/scripts/)
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# This is a script for generating CRUX port listings.
+# Distributed under the terms of the GPL license.
+# Report bugs and suggestions to <jukka@karsikkopuu.net>.
+#
+# Changelog:
+# 1.0.4
+# - Added --date-from-pkgfile (patch from Mikhail Kolesnik)
+# 1.0.3
+# - Fixed a problem with tabs in Pkgfile
+# 1.0.2
+# - Might as well make it XHTML 1.1
+# 1.0.1
+# - Output is now valid XHTML 1.0 Strict
+#
+########################################################################
+
+use strict;
+
+our %options =
+(
+ title => "CRUX ports",
+ timestamp_accuracy => 1,
+ date_from_file => 0,
+);
+
+sub print_usage
+{
+ print <<EOT;
+Usage: portspage [OPTION]... [DIRECTORY]
+
+ --title=TITLE set the page title
+ --header=FILE name of file to insert before port listing
+ --footer=FILE name of file to insert after port listing
+ --timestamp-accuracy=LEVEL 0 = no timestamp, 1 = date only, 2 = date and time
+ default is 1
+ --date-from-file take date from newest file instead of directory
+ --date-from-pkgfile take date from Pkgfile instead of directory
+ --version output version information and exit
+
+Report bugs to <jukka\@karsikkopuu.net>.
+EOT
+}
+
+sub parse_args
+{
+ foreach my $arg (@ARGV)
+ {
+ if ($arg =~ /^--header=(.*)$/)
+ {
+ $options{header} = $1;
+ }
+ elsif ($arg =~ /^--footer=(.*)$/)
+ {
+ $options{footer} = $1;
+ }
+ elsif ($arg =~ /^--title=(.*)$/)
+ {
+ $options{title} = $1;
+ }
+ elsif ($arg =~ /^--timestamp-accuracy=(0|1|2)$/)
+ {
+ $options{timestamp_accuracy} = $1;
+ }
+ elsif ($arg =~ /^--date-from-file$/)
+ {
+ $options{date_from_file} = 1;
+ }
+ elsif ($arg =~ /^--date-from-pkgfile$/)
+ {
+ $options{date_from_pkgfile} = 1;
+ }
+ elsif ($arg =~ /^--version$/)
+ {
+ print "$version\n";
+ exit 0;
+ }
+ elsif ($arg =~ /^--help$/)
+ {
+ print_usage();
+ exit 0;
+ }
+ else
+ {
+ $options{directory} = $arg;
+ }
+ }
+}
+
+sub recurse_tree
+{
+ my $path = shift;
+ my @list;
+
+ while ($path =~ s/\/\//\//g) {}
+ $path =~ s/\/$//;
+
+ opendir(DIR, $path) or return;
+ ENTRY:
+ foreach my $entry(sort(readdir(DIR)))
+ {
+ next ENTRY if $entry eq ".";
+ next ENTRY if $entry eq "..";
+ push (@list, "$path/$entry") if -f "$path/$entry";
+ push (@list, recurse_tree("$path/$entry")) if -d "$path/$entry";
+ }
+
+ return @list;
+}
+
+sub parse_pkgfile
+{
+ my %parsed;
+ my $pkgfile = shift;
+
+ if (open (FILE, $pkgfile))
+ {
+ while (<FILE>)
+ {
+ if ($_ =~ /^#\s*(.*?):\s*(.*)$/)
+ {
+ my $key = $1;
+ my $value = $2;
+ $value =~ s/</&lt;/g;
+ $value =~ s/>/&gt;/g;
+ $parsed{$key} = $value;
+ }
+ elsif ($_ =~ /^version=(.*)$/)
+ {
+ $parsed{version} = $1;
+ }
+ elsif ($_ =~ /^release=(.*)$/)
+ {
+ $parsed{release} = $1;
+ }
+ }
+ close (FILE);
+ }
+
+ return { %parsed };
+}
+
+sub main
+{
+ my %db;
+
+ parse_args();
+
+ if (!$options{directory})
+ {
+ print_usage();
+ return 0;
+ }
+
+ foreach my $file (recurse_tree($options{directory}))
+ {
+ if ($file =~ q:.*/(.*)/Pkgfile$:)
+ {
+ $db{$1} = parse_pkgfile("$file");
+ }
+ }
+
+ print <<EOH;
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+EOH
+
+ print " <title>$options{title}</title>\n";
+
+ print <<EOH;
+ <style type="text/css">
+ body
+ {
+ font-family: Verdana, sans-serif;
+ font-size: 85%;
+ padding: 2em;
+ }
+ a
+ {
+ color: black;
+ }
+ table
+ {
+ border: solid #CAD4E9 1px;
+ font-size: 85%;
+ }
+ td
+ {
+ padding: 6px;
+ }
+ tr.header
+ {
+ background-color: #CAD4E9;
+ }
+ tr.odd
+ {
+ background-color: #ECF0F7;
+ }
+ tr.even
+ {
+ background-color: #F7F9FC;
+ }
+ </style>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body>
+EOH
+
+ print " <h2>$options{title}</h2>\n";
+
+ if ($options{header})
+ {
+ open(FILE, $options{header}) or die "Couldn't open header file";
+ while (<FILE>)
+ {
+ print " " . $_;
+ }
+ close(FILE);
+ }
+
+ print " <table width=\"100%\" cellspacing=\"0\">\n";
+ print " <tr class=\"header\"><td><b>Port</b></td><td><b>Version</b></td><td><b>Description</b></td>";
+ if ($options{timestamp_accuracy} > 0)
+ {
+ print "<td><b>Last modified</b></td>";
+ }
+ print "</tr>\n";
+ our $odd = "odd";
+ my $count = 0;
+ foreach my $port (sort keys %db)
+ {
+ $count++;
+ print " <tr class=\"$odd\"><td>";
+ $db{$port}{URL} ? print "<a href=\"$db{$port}{URL}\">$port</a>" : print "$port";
+ print "</td><td><a href=\"$options{directory}/$port/\">$db{$port}{version}-$db{$port}{release}</a></td><td>";
+ print $db{$port}{Description} if $db{$port}{Description};
+ print "</td>";
+
+ if ($options{timestamp_accuracy} > 0)
+ {
+ my $date;
+
+ if ($options{date_from_file})
+ {
+ my @files = recurse_tree("$options{directory}/$port");
+ my @dates;
+ foreach my $file (@files)
+ {
+ push (@dates, (stat($file))[9]);
+ }
+ @dates = sort @dates;
+ $date = $dates[$#dates];
+
+ }
+ elsif ($options{date_from_pkgfile})
+ {
+ $date = (stat("$options{directory}/$port/Pkgfile"))[9];
+ }
+ else
+ {
+ $date = (stat("$options{directory}/$port"))[9];
+ }
+
+ print "<td>" . isotime($date, $options{timestamp_accuracy}) . "</td>";
+ }
+
+ print "</tr>\n";
+
+ if ($odd eq "odd") { $odd = "even"; }
+ else { $odd = "odd"; }
+ }
+ print " </table>\n";
+ print " <p><b>$count ports</b></p>\n";
+
+ if ($options{footer})
+ {
+ open(FILE, $options{footer}) or die "Couldn't open footer file";
+ while (<FILE>)
+ {
+ print " " . $_;
+ }
+ close(FILE);
+ }
+
+ print " <p><i>Generated by <a href=\"http://www.karsikkopuu.net/crux/scripts/\">portspage</a> $version on " . isotime() . ".</i></p>\n";
+
+ print <<EOH;
+ </body>
+</html>
+EOH
+
+ return 0;
+}
+
+sub isotime
+{
+ my $time = (shift or time);
+ my $accuracy = (shift or 2);
+ my @t = gmtime ($time);
+ my $year = $t[5] + 1900;
+ my $month = sprintf("%02d", $t[4] + 1);
+ my $day = sprintf("%02d", $t[3]);
+
+ if ($accuracy == 1)
+ {
+ return "$year-$month-$day";
+ }
+
+ return "$year-$month-$day " . sprintf("%02d:%02d:%02d UTC", $t[2], $t[1], $t[0]);
+}
+
+exit(main());
+
+# End of file

Generated by cgit