Import of pkgsrc-2013Q2

This commit is contained in:
2013-09-26 17:14:40 +02:00
commit 785076ae39
74991 changed files with 4380255 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
This is a simple script that will synchronise the content of your ${DISTDIR}
directory with currently installed packages.
This script will delete any ${DISTFILE} in ${DISTDIR} that does not currently
have an installed package as an owner.
If you play with packages a fair bit and download some just to have a play with
and delete the package later your ${DISTDIR} can end up with a lot of orphaned
${DISTFILES}. While lintpkgsrc will help you remove outdated ${DISTFILES} it
does not do any correlation with installed packages which is the gap this
script aims to fill.
With "lintpkgsrc -or && pkg_distinst --delete" you can and up with a fairly
lean and current ${DISTDIR}.
+10
View File
@@ -0,0 +1,10 @@
===========================================================================
$NetBSD: MESSAGE,v 1.1.1.1 2009/01/04 00:44:38 adrianp Exp $
WARNING:
This script will quite hapily delete *any* file in ${DISTDIR}
(or --distdir) that does not belong to an installed package. The only
exception to this is that it tries to avoid deleting some CVS files.
Please be sure that you are not storing anything else in ${DISTDIR}
(or --distdir) that you may want to keep.
===========================================================================
+33
View File
@@ -0,0 +1,33 @@
# $NetBSD: Makefile,v 1.7 2013/05/31 12:41:46 wiz Exp $
DISTNAME= pkg_distinst-0.02
PKGREVISION= 2
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
MAINTAINER= pkgsrc-users@NetBSD.org
COMMENT= Remove any distfiles not belonging to an installed package
WRKSRC= ${WRKDIR}
USE_TOOLS+= perl:run
NO_BUILD= yes
USE_LANGUAGES= # none
AUTO_MKDIRS= yes
SUBST_CLASSES+= di
SUBST_STAGE.di= do-configure
SUBST_FILES.di= pkg_distinst.pl
SUBST_SED.di= -e 's,@PERL5@,${PERL5},g'
SUBST_SED.di+= -e 's,@PKGSRCDIR@,${PKGSRCDIR},g'
SUBST_SED.di+= -e 's,@MAKE@,${MAKE},g'
SUBST_MESSAGE.di= Fixing script for installation.
do-extract:
cd ${FILESDIR} && cp pkg_distinst.pl ${WRKSRC}/
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/pkg_distinst.pl \
${DESTDIR}${PREFIX}/bin/pkg_distinst
.include "../../mk/bsd.pkg.mk"
+2
View File
@@ -0,0 +1,2 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2009/01/04 00:44:38 adrianp Exp $
bin/pkg_distinst
+175
View File
@@ -0,0 +1,175 @@
#!@PERL5@ -w
# $NetBSD: pkg_distinst.pl,v 1.2 2009/01/06 10:28:38 adrianp Exp $
use Data::Dumper;
use File::Basename;
use File::Find;
use Getopt::Long;
use strict;
my ($pkg_info, $pkgsrc, @pkg, @installed, $ipkg, $loc, @distfiles, $line);
my (@pdistfiles, %dupe, $distdir, @downloaded, $dl, @dltmp, $dir, $file);
my (@orphan, $found, $delete, $help);
# set some defaults
#
$pkgsrc = "";
$distdir = "";
$delete = 0;
$found = 0;
$help = 0;
GetOptions ( 'pkgsrc=s' => \$pkgsrc,
'distdir=s' => \$distdir,
'delete' => \$delete,
'help' => \$help,
);
if ($help == 1) {
help();
exit 0;
}
# check everything we need exists
#
if ($pkgsrc eq "") {
$pkgsrc = "@PKGSRCDIR@";
}
if (! -d "$pkgsrc/pkgtools/pkglint") {
print "ERROR: Unable to find $pkgsrc: $!\n";
exit 1;
}
chdir("$pkgsrc/pkgtools/pkglint");
$pkg_info = `@MAKE@ show-var VARNAME=PKG_INFO_CMD`;
chomp($pkg_info);
if ($distdir eq "") {
$distdir = `@MAKE@ show-var VARNAME=DISTDIR`;
chomp($distdir);
}
if (! -d "$distdir") {
print "ERROR: Unable to find $distdir: $!\n";
exit 1;
}
# get a list of installed packages
#
open(PKG_INFO, "$pkg_info|");
while(<PKG_INFO>) {
$line = $_;
@pkg = split / /, $line;
push(@installed, $pkg[0]);
}
close(PKG_INFO);
# get a list of distfiles for the installed packages
#
print "Gathering DISTFILES for installed packages";
foreach $ipkg (@installed) {
$loc = `$pkg_info -Q PKGPATH $ipkg`;
chomp($loc);
if (! -d "$pkgsrc/$loc") {
print "WARNING: Unable to find package $loc: $!\n";
} else {
chdir("$pkgsrc/$loc");
$line = `@MAKE@ show-var VARNAME=DISTFILES`;
chomp($line);
if ($line ne "") {
@pdistfiles = split / /, $line;
push(@distfiles, @pdistfiles);
}
$line = `@MAKE@ show-var VARNAME=PATCHFILES`;
chomp($line);
if ($line ne "") {
@pdistfiles = split / /, $line;
push(@distfiles, @pdistfiles);
}
print ".";
}
}
print "done\n";
# remove duplicates
#
%dupe = map { $_, 1 } @distfiles;
@distfiles = keys %dupe;
# get a list of downloaded DISTFILES in DISTDIR
#
find(\&dfile, $distdir);
# trim .cvsignore and CVS/*
#
foreach $dl (@downloaded) {
$dir = dirname($dl);
$file = basename($dir);
if (-f $dl && $dl ne "$distdir/.cvsignore" && $file ne "CVS") {
push(@dltmp, $dl);
}
}
@downloaded = @dltmp;
# figure out what belongs and what doesn't
#
foreach $dl (@downloaded) {
$file = basename($dl);
foreach my $ipkg (@distfiles) {
if ($file eq $ipkg) {
$found = 1;
last;
}
}
if ($found == 0) {
push(@orphan, $dl);
} else {
$found = 0;
}
}
# Print the list of orphaned files
#
foreach $file (@orphan) {
print "$file\n";
if ($delete == 1) {
unlink($file);
}
}
exit 0;
#
# subs follow
#
sub dfile {
push(@downloaded, $File::Find::name);
}
sub help {
print "pkg_distinst [--pkgsrc <pkgsrc dir> | --distdir <distfiles dir> | --delete | --help]\n";
print "\t --pkgsrc <pkgsrc dir>: Specify a pkgsrc directory to use.\n";
print "\t\t This will default to \${PKGSRCDIR}\n";
print "\t --distdir <distfiles dir>: Specify a distfiles directory to use.\n";
print "\t\t This will default to \${DISTDIR}\n";
print "\t --delete: Delete any orphaned files found.\n";
print "\t\t Default is to display the list of files.\n";
print "\t --help: You\'re looking at it\n";
}