~z-man/armagetronad/0.2.8-armagetronad-sty+ct

« back to all changes in this revision

Viewing changes to batch/make/version

  • Committer: Manuel Moos
  • Date: 2020-03-08 10:07:42 UTC
  • mfrom: (563.24.393 source)
  • Revision ID: z-man@users.sf.net-20200308100742-ax3qwhjs0n5zr7l5
Merge with mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
# set version parts to defaults for CVS snapshot
10
10
major_version=`cat ${srcdir}/major_version`
 
11
minor_version_proto=`cat ${srcdir}/minor_version`
11
12
DATE=`date +%Y%m%d`
12
13
 
13
14
#echo $major_version
14
15
#echo $minor_version
15
16
 
16
 
if test -d "${srcdir}/CVS"; then
17
 
    # get the date/branch/version tag
18
 
    rawtag=`cat ${srcdir}/CVS/Entries | grep major_version | sed -e "s,/major_version/.*/.*/.*/,,"`
19
 
    #echo $rawtag
20
 
    # determine the type of the tag
21
 
    echo $rawtag | grep "^D" > /dev/null && tagtype=D
22
 
    #echo $rawtag | grep "^Tb" > /dev/null && tagtype=Tb
23
 
    echo $rawtag | grep "^Tv" > /dev/null && tagtype=Tv
24
 
    #echo $tagtype
25
 
 
26
 
    # extract the raw tag
27
 
    tag=`echo $rawtag | sed -e "s,^$tagtype,,"`
28
 
    #echo $tag
29
 
 
30
 
    # date tag: make it a date dagged alpha release
31
 
    if test "$tagtype" = D; then
32
 
        DATE=`echo $tag | sed -e "s,\...\...\...\$,," | sed -e "s,\.,,g"`
33
 
        minor_version=`cat ${srcdir}/minor_version | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
34
 
    fi
35
 
 
36
 
    # version tag: take whole version, replace _[number] with .[number]
37
 
    if test "$tagtype" = Tv; then
38
 
        major_version=`echo $tag | sed -e "s,_\([0-9]\),\.\\1,g"`
39
 
        minor_version=""
40
 
        DATE=""
41
 
    fi
42
 
fi
43
 
 
44
 
if test -d "${srcdir}/.svn" || test -d "${srcdir}/../.svn"; then
45
 
    # get the inter-repository path by parsing the URL
46
 
 
47
 
    URL=`svn info ${srcdir} | grep ^URL | sed -e 's,^URL: ,,'`
48
 
 
49
 
    # uncomment the followint URLs to test various cases
50
 
    # trunk
51
 
    # URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/trunk/armagetronad
52
 
    # branch 0.4
53
 
    # URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/branches/0.4/armagetronad
54
 
 
55
 
    # tag 0.2.8.2
56
 
    # URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/tags/0.2.8.2/armagetronad
57
 
 
58
 
    #echo URL=$URL
59
 
    REPOPATH=`echo $URL | sed -e 's,/armagetronad$,,' -e 's,.*/armagetronad/,,'`
60
 
    #echo REPOPATH=$REPOPATH
61
 
 
62
 
    # is it a tag?
63
 
    if echo $REPOPATH | grep '^tags/' > /dev/null; then
64
 
        # echo Tag
65
 
        major_version=`echo $REPOPATH | sed -e 's,^tags/,,'`
66
 
        minor_version=""
67
 
        DATE=""
68
 
    else
69
 
        # make revision the alpha tag
70
 
        REVISION=`svn info ${srcdir} | grep ^Revision | sed -e 's,^Revision: ,,'`
71
 
 
72
 
        # is it a branch?
73
 
        if echo $REPOPATH | grep '^branches/' > /dev/null; then
74
 
            # echo Branch
75
 
            branch=`echo $REPOPATH | sed -e 's,^branches/,,'`
76
 
            # branch 0.2.8 produces 0.2.9 versions. Confusing, yeah, but moving it
77
 
            # in the repo is too risky.
78
 
            if test ${branch} = "0.2.8"; then
79
 
                # try to get revision ID from bzr using the magic bzr-svn marker
80
 
                # (only works this way on 0.2.8)
81
 
                REVISION=`svn propget bzr:revision-id:v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs ${srcdir} | tail -n 4 | sed -e 's, .*,,' | grep [0-9] | tail -n 1`
82
 
            else
83
 
                major_version=${branch}
84
 
            fi
85
 
        fi
86
 
        
87
 
        # trunk or branch
88
 
 
89
 
        #echo REVISION=$REVISION
90
 
        minor_version=_alpha_r$REVISION
91
 
        DATE=""
92
 
    fi
93
 
fi
 
17
bzr_count_revisions()
 
18
{
 
19
    srcdir="$1"
 
20
    limit="$2"
 
21
 
 
22
    test -z "$limit" || limit="-l $limit"
 
23
 
 
24
    count=$(bzr log --include-merges --line $limit "${srcdir}" 2>/dev/null | wc -l)
 
25
    echo $count
 
26
}
94
27
 
95
28
# *TODO* once we get our superproject up on launchpad (and thus get saner branch nicks), use branch nicks for $major_version
96
29
# Check if bzr is installed, and if the path is versionned
97
 
bzr info ${srcdir} >/dev/null 2>&1
 
30
bzr >/dev/null 2>&1
98
31
# But for now, ignore it
99
 
if test $? -eq 0
 
32
if test $? -eq 0 && test -d ${srcdir}/.bzr
100
33
#if test 1 -eq 0
101
34
then
102
 
    # get revno
103
 
    revno=`bzr revno ${srcdir}`
104
 
 
 
35
    # Crappily, we can't rely on revision numbers to do anything
 
36
    # ( ie. when one merges then pushes, the last revno might be lower than originally)
 
37
    # So we count revisions, including merged ones, also including fools which have empty
 
38
    # lines with only "revno: 15" in their commit messages
 
39
    revno=$( bzr revno ${srcdir} 2>/dev/null)    
 
40
    revcount=$( bzr_count_revisions ${srcdir} )
 
41
    lca=$revno
 
42
    lcaz=$revcount
 
43
    versioned=#
 
44
    branchurl=$( bzr info ${srcdir} 2>/dev/null | sed -ne 's/^  parent branch: \(.*\)$/\1/p' )
 
45
 
 
46
 
 
47
    # We will check this branch diverged, and/or if tree changed
 
48
    bzrmissingcout=$( cd ${srcdir} && bzr missing --this 2>/dev/null )
 
49
    missing=$?
105
50
    bzr diff ${srcdir} --quiet >/dev/null 2>&1
106
 
    # Test for the return code of bzr diff (see bzr diff --help)
107
 
    if test $? -eq 0
108
 
    then
109
 
        # If no change was made, use revision number (with offset to match svn revno)
110
 
        # but first check if it's tagged
 
51
    changed=$?
 
52
        
 
53
 
 
54
    if test ${missing} -eq 1
 
55
    # if it diverged:
 
56
    then
 
57
        # Count the revisions we added locally
 
58
        localrevisions=$( echo "${bzrmissingcout}" | sed -ne '2,1s/[^0-9]//gp' )
 
59
        # See how many steps it is, with the fool's number
 
60
        stepsbackwards=$( bzr_count_revisions ${srcdir} ${localrevisions} )
 
61
        # And start dancing.
 
62
        minor_version=_alpha_z$(( ${revcount} - ${stepsbackwards} ))_${DATE}
 
63
        # Set last common ancestors
 
64
        lca=$(( ${revno} - ${localrevisions}))
 
65
        lcaz=$(( ${revcount} - ${stepsbackwards} ))
 
66
        srcchanged=#
 
67
    elif test ${missing} -eq 0 && ( test ${changed} -eq 1 || test ${changed} -eq 2 )
 
68
    then
 
69
        # If a change was made and no more revision was added, just use revision fool's number plus build date
 
70
        minor_version=_alpha_z${revcount}_${DATE}
 
71
        # And this is versionned too
 
72
        srcchanged=#
 
73
    elif test ${missing} -eq 0
 
74
    then
 
75
        # If really no change was made, use the fool's number, with tag if any
 
76
        # So check if we have tags
 
77
        revno=$(bzr revno ${srcdir})
111
78
        tag=$(bzr tags -r $revno | awk '{ print $1 }')
112
 
        if test $tag
 
79
        if test ${tag}
113
80
        then
114
81
            # If it is tagged, use the tag
115
 
            DATE=_$tag
 
82
            minor_version=_alpha_z${revcount}_${tag}
116
83
        else
117
 
            # If not, use revision number
118
 
            DATE=_r${revno}
 
84
            # If not, use fool's number only
 
85
            minor_version=_alpha_z${revcount}
119
86
        fi
120
 
    elif test $? -lt 3
 
87
        # That's versioned as well
 
88
    else
 
89
        # Otherwise, this is just not versionned
 
90
        versioned=
 
91
    fi
 
92
 
 
93
    if test $versioned
121
94
    then
122
 
        # If a change was made, use revision number plus build date
123
 
        DATE=_r${revno}_$DATE
124
 
    # It returns 3 if it's not versionned, so forget it
 
95
        branchnick=$( cd ${srcdir}; bzr nick )
 
96
        revid=$( bzr testament | sed -ne 's/^revision-id: \(.*\)/\1/p' )
 
97
    fi
 
98
fi
 
99
 
 
100
if test -d "${srcdir}/.git"; then
 
101
    # check for a tag
 
102
    cd $srcdir
 
103
    # todo: once we have make tags, consider just git describe --tags as version ID.
 
104
    if tag=`git describe --tags --candidates=0` > /dev/null 2>&1; then
 
105
        major_version=`echo ${tag} | sed -e s/version_// -e s/release_//`
 
106
        minor_version=""
 
107
        DATE=""
 
108
    else
 
109
        if git diff-index --quiet HEAD --; then
 
110
            # local checkout clean, just use revno
 
111
            DATE=_z`git rev-list HEAD --count`
 
112
        else
 
113
            # local changes, add date
 
114
            DATE=_z`git rev-list HEAD --count`_$DATE
 
115
        fi
125
116
    fi
126
117
fi
127
118
 
128
119
if test -z "$minor_version"
129
120
then
130
 
    test -z "$DATE" || minor_version=`cat ${srcdir}/minor_version | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
 
121
    test -z "$DATE" || minor_version=`echo ${minor_version_proto} | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
131
122
fi
132
123
 
133
124
echo $major_version$minor_version