Hi gang,
We all update the Ports collection in our own way I presume, but ever since I dove a little more into pkg(8) (pkg-updating(8) in particular) I figured that I should be able to make things easier on myself. And what started out as a simple script to automate the usage of portsnap and
What does this do?
First and foremost it automates tasks. It refreshes the ports collection using portsnap, then looks up the new ports using portmaster (while keeping logs of the entire thing) and finally it checks relevant UPDATING messages using pkg-updating(8), the starting date is the last time the script ran. To that end it keeps a semaphore file (refresh.meta) which it uses to keep track of the last date.
The end result is a file called portmaster.log in the same directory, this basically contains the output from
Next is a file called refresh.log, this basically lists all the new ports currently available (extracted from the previously mentioned
And finally, and this is something I considered very useful, it maintains a file refresh-updating.log. This is basically a collection of updating reports (found in /usr/ports/UPDATING) but only for the relevant ports, and also only those which got added after the last time the script was run.
As said it's a simple script but one which I consider quite useful, and I hope it might help some of you out there as well.
We all update the Ports collection in our own way I presume, but ever since I dove a little more into pkg(8) (pkg-updating(8) in particular) I figured that I should be able to make things easier on myself. And what started out as a simple script to automate the usage of portsnap and
# portmaster -L
resulted into this script which I call 'refresh':
Code:
#!/bin/sh
## CONFIG section
# Where the script resides
WP=/root/updates
## INIT section, don't change
> $WP/$0-updating.log
udate=`stat -f %Sa -t %Y%m%d $WP/$0.meta`
if [ -n "$udate" ]; then
ucmd="-d $udate";
fi;
## MAIN section
portsnap fetch update && portmaster -L | tee portmaster.log && grep New portmaster.log > $WP/$0.log
for a in `cat $WP/$0.log | cut -d ' ' -f5 | cut -d '-' -f1`; do
pkg updating $ucmd $a >> $WP/$0-updating.log
done
touch $WP/$0.meta
First and foremost it automates tasks. It refreshes the ports collection using portsnap, then looks up the new ports using portmaster (while keeping logs of the entire thing) and finally it checks relevant UPDATING messages using pkg-updating(8), the starting date is the last time the script ran. To that end it keeps a semaphore file (refresh.meta) which it uses to keep track of the last date.
The end result is a file called portmaster.log in the same directory, this basically contains the output from
# portmaster -L
. I could skip this step but I wanted to have a failsave: if a port gets removed or such then Portmaster will mention as such when looking for new ports, and all that information can be found here.Next is a file called refresh.log, this basically lists all the new ports currently available (extracted from the previously mentioned
# portmaster -L
output).And finally, and this is something I considered very useful, it maintains a file refresh-updating.log. This is basically a collection of updating reports (found in /usr/ports/UPDATING) but only for the relevant ports, and also only those which got added after the last time the script was run.
As said it's a simple script but one which I consider quite useful, and I hope it might help some of you out there as well.