Compare commits
2 Commits
ec3c8f87ab
...
9f2bfaa011
Author | SHA1 | Date | |
---|---|---|---|
9f2bfaa011 | |||
fe29385053 |
68
man1/oldfiles.1
Normal file
68
man1/oldfiles.1
Normal file
@ -0,0 +1,68 @@
|
||||
." Text automatically generated by txt2man-1.4.7
|
||||
.TH oldfiles 1 "April 23, 2006" "" ""
|
||||
.SH NAME
|
||||
\fBoldfiles\fP - display old packages and sources
|
||||
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.fam C
|
||||
.B oldfiles [\-p|\-s|\-l]
|
||||
.fam T
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
Oldfiles is a script to list outdated packages, sources, and build logs on a
|
||||
CRUX system with central directories for those \fBpkgmk\fP(8) and
|
||||
\fBprt\-get\fP(8) artifacts.
|
||||
The global config /etc/pkgmk.conf must define PKGMK_SOURCE_DIR and
|
||||
PKGMK_PACKAGE_DIR (if using \fB\-s\fP or \fB\-p\fP), and /etc/prt-get.conf must
|
||||
define \fIwritelog enabled\fP and a template for \fIlogfile\fP (if using
|
||||
\fB\-l\fP). See \fBpkgmk.conf\fP(5) and \fBprt\-get.conf\fP(5) for details.
|
||||
.PP
|
||||
Without any options, \fBoldfiles\fP will default to showing only sources and
|
||||
packages. The list of ports is built using \fBprt\-get\fP(8), so deactivating
|
||||
a repository in /etc/prt-get.conf will result in all its ports' sources and
|
||||
packages being flagged as old.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-p
|
||||
list only outdated packages
|
||||
|
||||
.TP
|
||||
.B \-s
|
||||
list only outdated sources
|
||||
|
||||
.TP
|
||||
.B \-l
|
||||
list only outdated build logs (those from packages that have since been
|
||||
uninstalled, or from building a previous version)
|
||||
|
||||
.SH EXAMPLES
|
||||
.TP
|
||||
.B
|
||||
\fBoldfiles\fP \fB-p\fP
|
||||
will list all outdated packages.
|
||||
.TP
|
||||
.B
|
||||
\fBoldfiles\fP | xargs rm
|
||||
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), e.g.:
|
||||
.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@varlock.com>
|
||||
.PP
|
||||
Mark Rosenstand <mark@borkware.net>
|
||||
.PP
|
||||
John McQuah <jmcquah@disroot.org>
|
||||
.SH SEE ALSO
|
||||
\fBpkgmk\fP(8), \fBprt-get\fP(8)
|
@ -1,5 +1,8 @@
|
||||
1.2 -> 1.2.1
|
||||
------------
|
||||
- oldfiles: add the option -l to show outdated build logs
|
||||
- prtrej: clean up /var/lib/pkg/rejected in case a package was uninstalled
|
||||
before merging its conflicting files
|
||||
- prtsweep, prtwash: rewritten in perl
|
||||
- prtcheck: test that all sources are signed
|
||||
- pkgfoster: save the list of adoptees in ~/.config rather than cluttering $HOME;
|
||||
|
164
scripts/oldfiles.pl
Executable file
164
scripts/oldfiles.pl
Executable file
@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# oldfiles - show outdated packages, sources, build logs for a CRUX system
|
||||
#
|
||||
# by Simone Rota <sip at varlock dot com>,
|
||||
# Mark Rosenstand <mark at borkware dot net>,
|
||||
# John McQuah <jmcquah at disroot dot org>
|
||||
# License: GNU GPL v2
|
||||
#
|
||||
# Requires prt-get by Johannes Winkelmann
|
||||
#
|
||||
# User beware:
|
||||
# - Ports not using signatures for their manifests will have all their
|
||||
# source files listed. Contact those port maintainers and get them to
|
||||
# abandon the deprecated md5sums.
|
||||
# - Deactivating a repository in prt-get.conf will allow all its packages
|
||||
# and source files to be reported by this script.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my %options = %{getoptions(@ARGV)};
|
||||
my $pkgdir = "";
|
||||
my $srcdir = "";
|
||||
my $logdir = "";
|
||||
my $logtemplate = "";
|
||||
my $writelog = "disabled";
|
||||
my $compress = "gz";
|
||||
my %wanted;
|
||||
my %keepme;
|
||||
|
||||
# Assume packages and sources if no options specified (historical behaviour).
|
||||
# Users who want to search for build logs (feature added in Sep 2023)
|
||||
# must pass the -l flag explicitly
|
||||
if ( $options{"-p"} + $options{"-s"} + $options{"-l"} == 0 ) {
|
||||
$options{"-p"} = 1;
|
||||
$options{"-s"} = 1;
|
||||
$options{"-l"} = 0;
|
||||
}
|
||||
|
||||
# Read pkgmk.conf
|
||||
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/;
|
||||
$compress = $1 if m/^PKGMK_COMPRESSION_MODE="(.*)"\n/;
|
||||
}
|
||||
close CONFIG;
|
||||
|
||||
# Check if dirs are specified / exists
|
||||
if ( $options{"-p"} ) {
|
||||
if ($pkgdir eq ""){
|
||||
print STDERR "error: no PKGMK_PACKAGE_DIR specified in /etc/pkgmk.conf\n";
|
||||
print STDERR " skipping the search for old packages.\n";
|
||||
$options{"-p"} = 0;
|
||||
} elsif (! -d $pkgdir) {
|
||||
print STDERR "error: $pkgdir is not a directory\n";
|
||||
print STDERR " skipping the search for old packages.\n";
|
||||
$options{"-p"} = 0;
|
||||
}
|
||||
}
|
||||
if ( $options{"-s"} ) {
|
||||
if ($srcdir eq ""){
|
||||
print STDERR "error: no PKGMK_SOURCE_DIR specified in /etc/pkgmk.conf\n";
|
||||
print STDERR " skipping the search for old sources.\n";
|
||||
$options{"-s"} = 0;
|
||||
} elsif (! -d $srcdir) {
|
||||
print STDERR "error: $srcdir is not a directory\n";
|
||||
print STDERR " skipping the search for old sources.\n";
|
||||
$options{"-s"} = 0;
|
||||
}
|
||||
}
|
||||
if ( $options{"-l"} ) {
|
||||
open PGCONF, "/etc/prt-get.conf" or die "cannot open prt-get.conf";
|
||||
while (<PGCONF>) {
|
||||
$writelog = $1 if m/^\s*writelog\s+(enabled|disabled)/;
|
||||
$logtemplate = $1 if m/^\s*logfile\s+([^\s]+)(#|\n)/;
|
||||
}
|
||||
close PGCONF;
|
||||
if ($logtemplate ne "") {
|
||||
$logdir = $logtemplate;
|
||||
$logdir =~ s/[^\/]+$//;
|
||||
$logdir =~ s/\/$//;
|
||||
}
|
||||
if (($writelog eq "disabled") or ($logdir =~ m/(%p|%n|%v|%r)/)) {
|
||||
print STDERR "warning: $logdir does not resolve to a shared directory,\n";
|
||||
print STDERR " skipping the search for old logs.\n";
|
||||
$options{"-l"} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
# Early exit if no valid dirs are found
|
||||
if ($options{"-s"}+$options{"-p"}+$options{"-l"}==0) { exit 1; }
|
||||
|
||||
# Collect current sources / packages / log files
|
||||
foreach (split('\n', `prt-get printf "%p:%n:%v:%r:%i\n"`)) {
|
||||
my ($path, $name, $version, $release, $isinst) = split(':', $_, 5);
|
||||
if ( $options{"-p"} ) {
|
||||
$wanted{$pkgdir}{"$name\#$version-$release.pkg.tar.$compress"} = 1;
|
||||
}
|
||||
if ( $options{"-s"} ) {
|
||||
open SIGNATURES, "$path/$name/.signature" or next;
|
||||
while (<SIGNATURES>) {
|
||||
m/^SHA256\s\((.+)\)\s.+\n/;
|
||||
if ($1 && !($1 =~ "Pkgfile") && !($1 =~ ".footprint")) {
|
||||
$wanted{$srcdir}{$1} = 1;
|
||||
}
|
||||
}
|
||||
close SIGNATURES;
|
||||
}
|
||||
if ( $options{"-l"} and ($isinst ne "no") ) {
|
||||
my $logfile = $logtemplate;
|
||||
my %subs = ( $logdir => "", "%p" => $path, "%n" => $name,
|
||||
"%v" => $version, "%r" => $release );
|
||||
$logfile =~ s/($logdir|%p|%n|%v|%r)/$subs{$1}/g;
|
||||
$logfile =~ s/^\///;
|
||||
$wanted{$logdir}{$logfile} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# 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;
|
||||
|
||||
# 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
|
||||
sub getoptions {
|
||||
my @args = reverse @_;
|
||||
my %options = ("-p" => 0, "-s" => 0, "-l" => 0);
|
||||
|
||||
while (my $argument = pop @args) {
|
||||
if ( $argument eq "-p" ) { $options{"-p"} = 1;
|
||||
} elsif ( $argument eq "-s" ) { $options{"-s"} = 1;
|
||||
} elsif ( $argument eq "-l" ) { $options{"-l"} = 1;
|
||||
} else {
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
return \%options;
|
||||
}
|
||||
|
||||
# Show usage
|
||||
sub usage {
|
||||
print "usage: oldfiles [-p|-s|-l]\n";
|
||||
}
|
96
scripts/prtrej
Executable file
96
scripts/prtrej
Executable file
@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# $Id: prtrej,v 1.4 2004/02/06 11:30:00 opel Exp $
|
||||
# (c) 2003,2004 by Martin Opel <mo@obbl-net.de>
|
||||
# (c) 2002 by Markus Ackermann <maol@symlink.ch>
|
||||
#
|
||||
# may be redistributed and modified under the terms of the GPL
|
||||
# only usable with CRUX Linux, version 0.9.2 or higher
|
||||
#
|
||||
# USE AT YOUR OWN RISK
|
||||
#
|
||||
# Interactive tool to ask user what he/she wants to do with a rejected file
|
||||
# in /var/lib/pkg/rejected
|
||||
# Requires opt/dialog to be installed
|
||||
# All identical files are removed without a user's interaction
|
||||
# TODO: respect SYSROOT?
|
||||
|
||||
TMP=/tmp/rejdiff
|
||||
REJ=/var/lib/pkg/rejected
|
||||
|
||||
cleanup() {
|
||||
echo "Removed $count unneeded files"
|
||||
rm -f $TMP
|
||||
}
|
||||
|
||||
interrupted() {
|
||||
echo "Interrupted..."
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap "interrupted" SIGHUP SIGINT SIGQUIT SIGTERM
|
||||
|
||||
count=0
|
||||
|
||||
if [ ! -d "$REJ" ]; then
|
||||
echo "$REJ not found. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mapfile -t REJECTS < <(find $REJ -type f)
|
||||
# Why not loop over the output of find?
|
||||
# bash splits on whitespace, so by putting the newline-separated results
|
||||
# of find into an array, we can use double-quotes to ensure any file with
|
||||
# space in its name is not misinterpreted as multiple files.
|
||||
# Redefining IFS is another option, but prone to unwanted side-effects.
|
||||
|
||||
for reject in "${REJECTS[@]}"; do
|
||||
real="/${reject#*rejected/}"
|
||||
#
|
||||
# Insert a test to ensure that diff is given two valid args.
|
||||
#
|
||||
# Nonexistent $real suggests that $reject is no longer needed.
|
||||
# Forgot to merge it, and then later uninstalled the package, perhaps?
|
||||
# If this circumstance is common and $REJ becomes cluttered too easily,
|
||||
# then someone might ask for another side-effect of prt-get remove.
|
||||
# This cleanup could be incorporated directly into pkgrm, but until that
|
||||
# happens we might as well do the cleanup here.
|
||||
#
|
||||
if [ ! -e "$real" ] || diff "$real" "$reject" >/dev/null; then
|
||||
rm "$reject"
|
||||
count=$(( count + 1 ))
|
||||
else
|
||||
diff -u "$real" "$reject" &> $TMP
|
||||
|
||||
ACTION=$(dialog --no-shadow --stdout \
|
||||
--title "diff $real $reject" \
|
||||
--textbox $TMP -1 -1 \
|
||||
--menu "Make your selection:" 11 50 4 \
|
||||
KEEP "Keep existing file." \
|
||||
INST "Overwrite with file from package." \
|
||||
EXIT "Exit immediately." \
|
||||
" " "Do nothing now.")
|
||||
|
||||
case "$ACTION" in
|
||||
"KEEP")
|
||||
echo "Keeping old file, removing $reject."
|
||||
rm $reject
|
||||
;;
|
||||
"INST")
|
||||
echo "Installing new file, overwriting $real with $reject."
|
||||
mv $reject $real
|
||||
;;
|
||||
"EXIT")
|
||||
echo "Exiting..."
|
||||
cleanup
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Leaving $real and $reject untouched for now."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
cleanup
|
Loading…
Reference in New Issue
Block a user