annotate version.sh @ 15649:c3688869c2e5

Generate the version string with awk on BSD systems and work around wrong day/month order in the ls output. based on a patch by Chris Roccati <roccati - at - pobox - dot - com>
author diego
date Sun, 05 Jun 2005 17:38:10 +0000
parents 65a8ce32e9f1
children 5c5219508907
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
420
980bafac238f write cvs date+version into version.h
arpi_esp
parents:
diff changeset
1 #!/bin/sh
980bafac238f write cvs date+version into version.h
arpi_esp
parents:
diff changeset
2
8687
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
3 OS=`uname -s`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
4 case "$OS" in
15513
3f20ae0bd86e simplification
diego
parents: 15511
diff changeset
5 CYGWIN*|Linux)
8687
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
6 last_cvs_update=`date -r CVS/Entries +%y%m%d-%H:%M 2>/dev/null`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
7 ;;
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
8 BSD/OS)
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
9 LS=`ls -lT CVS/Entries`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
10 month=`echo $LS | awk -F" " '{print $6}'`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
11 day=`echo $LS | awk -F" " '{print $7}'`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
12 hms=`echo $LS | awk -F" " '{print $8}'`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
13 hour=`echo $hms | awk -F":" '{print $1}'`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
14 minute=`echo $hms | awk -F":" '{print $2}'`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
15 year=`echo $LS | awk -F" " '{print $9}'`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
16 last_cvs_update="${year}${month}${day}-${hour}:${minute}"
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
17 ;;
15536
b39eee207c42 LANG=C ensures month/day order and English language in the date string for
diego
parents: 15513
diff changeset
18 Darwin|*BSD)
b39eee207c42 LANG=C ensures month/day order and English language in the date string for
diego
parents: 15513
diff changeset
19 # BSD 'date -r' does not print modification time
15547
c4e5c20f2dd6 LC_ALL overrides LANG, so use it instead.
diego
parents: 15536
diff changeset
20 # LC_ALL=C sets month/day order and English language in the date string
15649
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
21 # The if in the awk call works around wrong day/month order.
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
22 last_cvs_update=`LC_ALL=C ls -lT CVS/Entries | \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
23 awk '{ \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
24 day=$7; \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
25 month=index(" JanFebMarAprMayJunJulAugSepOctNovDec", $6); \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
26 if(month==0) { \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
27 day=$6; \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
28 month=index(" JanFebMarAprMayJunJulAugSepOctNovDec",$7); } \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
29 printf("%s%.02d%.02d-%s", \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
30 substr($9, 3, 2), (month+1)/3, day, substr($8, 0, 5)); \
c3688869c2e5 Generate the version string with awk on BSD systems and work around wrong
diego
parents: 15643
diff changeset
31 }'`
8687
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
32 ;;
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
33 *)
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
34 last_cvs_update=`date +%y%m%d-%H:%M`
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
35 ;;
93694559178c better BSD/OS support by Steven Schultz <sms@2bsd.com>
alex
parents: 7448
diff changeset
36 esac
3292
7fa3a928631a not it looks like this 'MPlayer CVS-011203-19:47-gcc-2.95.3'
jaf
parents: 1621
diff changeset
37
7447
a49219323787 moved to to avoid CVS-XXYYZZ- versions (if no given) - altought this comment is bigger than the patch :)
alex
parents: 5949
diff changeset
38 extra=""
7448
b464616d40b5 Should be: if test ; then - D Richard Felker III <dalias@aerifal.cx>
alex
parents: 7447
diff changeset
39 if test "$1" ; then
7447
a49219323787 moved to to avoid CVS-XXYYZZ- versions (if no given) - altought this comment is bigger than the patch :)
alex
parents: 5949
diff changeset
40 extra="-$1"
a49219323787 moved to to avoid CVS-XXYYZZ- versions (if no given) - altought this comment is bigger than the patch :)
alex
parents: 5949
diff changeset
41 fi
10421
b522f0f85387 the trailing space isn't needed anymore
alex
parents: 9374
diff changeset
42 echo "#define VERSION \"dev-CVS-${last_cvs_update}${extra}\"" >version.h