Annotation of loncom/build/getcvsdate.pl, revision 1.1
1.1 ! raeburn 1: #!/usr/bin/perl
! 2:
! 3: # The LearningOnline Network with CAPA
! 4: # getcvsdate.pl - script to get CVS commit date for a file from CVS/Entries.
! 5: #
! 6: # $Id: getcvsdate.pl,v 1.1 2012/01/27 16:50:50 raeburn Exp $
! 7: #
! 8: # Copyright Michigan State University Board of Trustees
! 9: #
! 10: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
! 11: #
! 12: # LON-CAPA is free software; you can redistribute it and/or modify
! 13: # it under the terms of the GNU General Public License as published by
! 14: # the Free Software Foundation; either version 2 of the License, or
! 15: # (at your option) any later version.
! 16: #
! 17: # LON-CAPA is distributed in the hope that it will be useful,
! 18: # but WITHOUT ANY WARRANTY; without even the implied warranty of
! 19: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 20: # GNU General Public License for more details.
! 21: #
! 22: # You should have received a copy of the GNU General Public License
! 23: # along with LON-CAPA; if not, write to the Free Software
! 24: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! 25: #
! 26: # /home/httpd/html/adm/gpl.txt
! 27: #
! 28: # http://www.lon-capa.org/
! 29: #
! 30:
! 31: use strict;
! 32:
! 33: # ------------------------------------------------------------------ Invocation
! 34: my $invocation=<<END;
! 35: getcvsdate.pl [PATH TO CVS/Entries] [FILE]
! 36:
! 37: END
! 38:
! 39: unless (@ARGV) {
! 40: print $invocation;
! 41: exit 1;
! 42: }
! 43:
! 44: my %month_to_twodigit = (
! 45: Jan => '01',
! 46: Feb => '02',
! 47: Mar => '03',
! 48: Apr => '04',
! 49: May => '05',
! 50: Jun => '06',
! 51: Jul => '07',
! 52: Aug => '08',
! 53: Sep => '09',
! 54: Oct => '10',
! 55: Nov => '11',
! 56: Dec => '12',
! 57: );
! 58:
! 59: if (@ARGV==2) {
! 60: my $path = $ARGV[0];
! 61: my $file = $ARGV[1];
! 62: my $datetime;
! 63: if ($path ne '' && $file ne '') {
! 64: if (-e $path) {
! 65: if (open(my $fh,"<$path")) {
! 66: while(<$fh>) {
! 67: chomp();
! 68: if (m{\Q$file\E/[\d.]+/+([^/]+)/}) {
! 69: my ($wday,$month,$day,$clock,$yr) = split(/\s+/,$1);
! 70: if (exists($month_to_twodigit{$month})) {
! 71: $datetime = $yr.'-'.$month_to_twodigit{$month}.'-'.$day.' '.$clock.' +0000';
! 72: }
! 73: last;
! 74: }
! 75: }
! 76: close($fh);
! 77: }
! 78: }
! 79: }
! 80: print $datetime;
! 81: }
! 82:
! 83: =pod
! 84:
! 85: =head1 NAME
! 86:
! 87: getcvsdate.pl - script to get CVS commit date for a file from CVS/Entries.
! 88:
! 89: =head1 SYNOPSIS
! 90:
! 91: getcvsdate.pl [PATH TO CVS/Entries] [FILE]
! 92:
! 93: =head1 DESCRIPTION
! 94:
! 95: getcvsdate.pl can be used to retrieve the CVS commit date/time for a prticular
! 96: file from the corresponding entry in CVS/Entries.
! 97:
! 98: The date is returned in the following format:
! 99: YYYY-MM-DD HH:MM:SS +0000
! 100:
! 101: where +0000 (in HHMM) is the (assumed zero) timezone offset from UTC.
! 102:
! 103: This script is invoked in Makefile (within aboutVERSION and postaboutVERSION
! 104: targets) to set the modification dates for two files containing version
! 105: information which are modified during the LON-CAPA installation process.
! 106: In this use case the time string generated by a call to getcvsdate.pl for
! 107: loncapa_apache.conf and about.html is passed as the input for the date argument
! 108: in a call to the touch utility, e.g.,
! 109:
! 110: touch --date="$(shell echo `perl getcvsdate.pl
! 111: $(SOURCE)/loncom/license/CVS/Entries about.html`)"
! 112: $(SOURCE)/loncom/license/about.html
! 113:
! 114: =cut
! 115:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>