Skip to content

Instantly share code, notes, and snippets.

@lwhsu
Created July 16, 2014 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwhsu/c91bf50379d297298be9 to your computer and use it in GitHub Desktop.
Save lwhsu/c91bf50379d297298be9 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
#
# Updating ports tree, portsnap.tw.FreeBSD.org cache and
# local distfiles.
#
use strict;
my @arch = qw/amd64 i386 ia64 pc98 powerpc sparc64/;
my $bsdadm = "bsdadm";
my $portsnap = "/usr/sbin/portsnap";
my $make = "/usr/bin/make";
#print "Job start at ".`date`;
open PORTSNAP, "$portsnap cron update|";
#print "Start fetch at ".`date`;
while (<PORTSNAP>) {
next unless (/^\/.*\/$/);
chomp;
foreach my $a (@arch) {
my $cmd = "cd $_ && $make -DBATCH -DDISABLE_CONFLICTS -DDISABLE_VULNERABILITIES ARCH=$a checksum";
print $cmd ."\n";
system "su -f -m $bsdadm -c \'$cmd\'";
## print the return value
# seems work.
# print $?. "\n";
last if ($? == 0);
}
}
close PORTSNAP;
#print "Job done at ".`date`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment