Changeset View
Changeset View
Standalone View
Standalone View
Tools/scripts/chkversion.pl
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
# | # | ||||
# install port sysutils/pkg_install-devel (optional) | # install port sysutils/pkg_install-devel (optional) | ||||
# mkdir -p /var/db/chkversion | # mkdir -p /var/db/chkversion | ||||
# touch /var/db/chkversion/VERSIONS | # touch /var/db/chkversion/VERSIONS | ||||
# chown -R ports /var/db/chkversion | # chown -R ports /var/db/chkversion | ||||
# and enter something like | # and enter something like | ||||
# | # | ||||
# BLAME=yes (git specific) | # BLAME=yes (git specific) | ||||
# SVNBLAME=yes # XXX: SVN specific | |||||
# ALLPORTS=yes | # ALLPORTS=yes | ||||
# RCPT_ORIGIN=you@domain.example | # RCPT_ORIGIN=you@domain.example | ||||
# RCPT_VERSION=you@domain.example | # RCPT_VERSION=you@domain.example | ||||
# 0 */2 * * * /usr/ports/Tools/scripts/chkversion.pl | # 0 */2 * * * /usr/ports/Tools/scripts/chkversion.pl | ||||
# | # | ||||
# into `crontab -u ports -e', or run the script by hand if you can spare the time. | # into `crontab -u ports -e', or run the script by hand if you can spare the time. | ||||
# | # | ||||
# If the environment variable BLAME is set and the ports tree is checked | # If the environment variable BLAME is set and the ports tree is checked | ||||
# out by git, every entry is listed with a record of the last git commit. | # out by git, every entry is listed with a record of the last git commit. | ||||
# | # | ||||
# XXX: SVN specific: | |||||
# If the environment variable SVNBLAME is set and the ports tree is checked | |||||
# out by SVN, every entry is listed with a record of the last SVN commit. | |||||
# | |||||
use v5.20; | use v5.20; | ||||
use strict; | use strict; | ||||
use warnings; | use warnings; | ||||
use feature qw(signatures); | use feature qw(signatures); | ||||
no warnings qw(experimental::signatures); | no warnings qw(experimental::signatures); | ||||
use Cwd 'abs_path'; | use Cwd 'abs_path'; | ||||
use File::Find; | use File::Find; | ||||
use List::Util qw(first); | use List::Util qw(first); | ||||
use POSIX; | use POSIX; | ||||
my $portsdir = $ENV{PORTSDIR} // '/usr/ports'; | my $portsdir = $ENV{PORTSDIR} // '/usr/ports'; | ||||
my $versiondir = $ENV{VERSIONDIR} // '/var/db/chkversion'; | my $versiondir = $ENV{VERSIONDIR} // '/var/db/chkversion'; | ||||
my $svnblame = exists $ENV{SVNBLAME}; # XXX: SVN specific | |||||
my $blame = exists $ENV{BLAME}; | my $blame = exists $ENV{BLAME}; | ||||
my $allports = exists $ENV{ALLPORTS}; | my $allports = exists $ENV{ALLPORTS}; | ||||
my $watch_re = $ENV{WATCH_REGEX} // ''; | my $watch_re = $ENV{WATCH_REGEX} // ''; | ||||
my $watchm_re = $ENV{WATCHM_REGEX} // ''; | my $watchm_re = $ENV{WATCHM_REGEX} // ''; | ||||
my $returnpath = $ENV{RETURNPATH} // ''; | my $returnpath = $ENV{RETURNPATH} // ''; | ||||
my $h_from = $ENV{HEADER_FROM} // $ENV{USER} . '@' . ($ENV{HOST} // `/bin/hostname`); | my $h_from = $ENV{HEADER_FROM} // $ENV{USER} . '@' . ($ENV{HOST} // `/bin/hostname`); | ||||
my $h_replyto = $ENV{HEADER_REPLYTO} // $h_from; | my $h_replyto = $ENV{HEADER_REPLYTO} // $h_from; | ||||
my $rcpt_watch = $ENV{RCPT_WATCH} // ''; | my $rcpt_watch = $ENV{RCPT_WATCH} // ''; | ||||
my $rcpt_watchm = $ENV{RCPT_WATCHM} // ''; | my $rcpt_watchm = $ENV{RCPT_WATCHM} // ''; | ||||
my $rcpt_orig = $ENV{RCPT_ORIGIN} // ''; | my $rcpt_orig = $ENV{RCPT_ORIGIN} // ''; | ||||
my $rcpt_vers = $ENV{RCPT_VERSION} // ''; | my $rcpt_vers = $ENV{RCPT_VERSION} // ''; | ||||
my $cc_author = exists $ENV{CC_AUTHOR}; | my $cc_author = exists $ENV{CC_AUTHOR}; | ||||
my $cc_mntnr = exists $ENV{CC_MAINTAINER}; | my $cc_mntnr = exists $ENV{CC_MAINTAINER}; | ||||
my $make = '/usr/bin/make'; | my $make = '/usr/bin/make'; | ||||
my $svn = '/usr/local/bin/svn'; # XXX: SVN specific | |||||
my $git = '/usr/local/bin/git'; | my $git = '/usr/local/bin/git'; | ||||
my $sendmail = '/usr/sbin/sendmail'; | my $sendmail = '/usr/sbin/sendmail'; | ||||
my $pkg = first { -x $_ } ($ENV{PKG} // '', '/usr/local/sbin/pkg', '/usr/sbin/pkg'); | my $pkg = first { -x $_ } ($ENV{PKG} // '', '/usr/local/sbin/pkg', '/usr/sbin/pkg'); | ||||
$watch_re =~ s/ /|/g; | $watch_re =~ s/ /|/g; | ||||
$watchm_re =~ s/ /|/g; | $watchm_re =~ s/ /|/g; | ||||
-d $portsdir or die "Can't find ports tree at $portsdir.\n"; | -d $portsdir or die "Can't find ports tree at $portsdir.\n"; | ||||
Show All 34 Lines | |||||
my %pkgmntnr; | my %pkgmntnr; | ||||
sub wanted() { | sub wanted() { | ||||
return unless -d; | return unless -d; | ||||
# Skip directories we shouldn't descend into | # Skip directories we shouldn't descend into | ||||
# if (/^.git$/ | # if (/^.git$/ | ||||
if (/^\.git$/ | if (/^\.git$/ | ||||
|| /^\.svn$/ # XXX: SVN specific | |||||
|| $File::Find::name =~ m"^$portsdir/(?:Mk|Templates|Tools|distfiles|packages)$"os | || $File::Find::name =~ m"^$portsdir/(?:Mk|Templates|Tools|distfiles|packages)$"os | ||||
|| $File::Find::name =~ m"^$portsdir/[^/]+/pkg$"os) | || $File::Find::name =~ m"^$portsdir/[^/]+/pkg$"os) | ||||
{ | { | ||||
$File::Find::prune = 1; | $File::Find::prune = 1; | ||||
} | } | ||||
elsif ($File::Find::name =~ m"^$portsdir/([^/]+/[^/]+)$"os) { | elsif ($File::Find::name =~ m"^$portsdir/([^/]+/[^/]+)$"os) { | ||||
$File::Find::prune = 1; | $File::Find::prune = 1; | ||||
if (-f "$File::Find::name/Makefile") { | if (-f "$File::Find::name/Makefile") { | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | sub getauthors($ports) { | ||||
return %author; | return %author; | ||||
} | } | ||||
# Gets the Makefile log starting from the last known rev for a port | # Gets the Makefile log starting from the last known rev for a port | ||||
sub printlog($fh, $portdir, $rev) { | sub printlog($fh, $portdir, $rev) { | ||||
if ($blame && -d "$portsdir/.git") { | if ($blame && -d "$portsdir/.git") { | ||||
my @log = readfrom $portdir, $git, 'log', "${rev}^..HEAD", 'Makefile'; | my @log = readfrom $portdir, $git, 'log', "${rev}^..HEAD", 'Makefile'; | ||||
print $fh " | $_\n" for @log; | print $fh " | $_\n" for @log; | ||||
} | |||||
# XXX: SVN specific: | |||||
elsif ($svnblame && -d "$portsdir/.svn") { | |||||
my @svnlog = readfrom $portdir, $svn, 'log', ($rev ? "-r$rev" : ''), 'Makefile'; | |||||
for (@svnlog) { | |||||
my $in_log = /^-{20,}$/ ... /^(-{20,}|={70,})$/; | |||||
print $fh " | $_\n" | |||||
if ($in_log && $in_log ne 1 && $in_log !~ /E0$/); | |||||
} | |||||
} | } | ||||
} | } | ||||
# Git version: | # Git version: | ||||
# sub printlog($fh, $portdir, $rev) { | # sub printlog($fh, $portdir, $rev) { | ||||
# } | # } | ||||
sub blame($fh, $ports) { | sub blame($fh, $ports) { | ||||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |