|  | @@ -66,7 +66,7 @@ dist() {
 | 
	
		
			
			| 66 | 66 |      # Create distributable tarball
 | 
	
		
			
			| 67 | 67 |      #
 | 
	
		
			
			| 68 | 68 |      local version=$(get_version)
 | 
	
		
			
			| 69 |  | -    local dirname=$MKIT_PROJNAME-$version
 | 
	
		
			
			|  | 69 | +    local dirname=$MKIT_PKGNAME-$version
 | 
	
		
			
			| 70 | 70 |      mkdir -p $dirname
 | 
	
		
			
			| 71 | 71 |      local item
 | 
	
		
			
			| 72 | 72 |      cp -R $(ini values "lists:dist") $dirname
 | 
	
	
		
			
			|  | @@ -128,10 +128,10 @@ get_version() {
 | 
	
		
			
			| 128 | 128 |      #
 | 
	
		
			
			| 129 | 129 |      #  1. use VERSION (from config.mk)
 | 
	
		
			
			| 130 | 130 |      #  2. if we are in git, override the version with last tag
 | 
	
		
			
			| 131 |  | -    #  3. if set, add STAGE (from config.mk) as pre-release ID
 | 
	
		
			
			|  | 131 | +    #  3. if set, add PRERELEASE (from config.mk) as pre-release ID
 | 
	
		
			
			| 132 | 132 |      #     (afer dash)
 | 
	
		
			
			| 133 |  | -    #  4. if we are at a later commit than the last tag, add commit
 | 
	
		
			
			| 134 |  | -    #     sha1 to build metadata (after plus sign)
 | 
	
		
			
			|  | 133 | +    #  4. if we are at a later commit than the last tag, add branch
 | 
	
		
			
			|  | 134 | +    #     name and commit sha1 to build metadata (after plus sign)
 | 
	
		
			
			| 135 | 135 |      #  5. if the tree is "dirty", i.e. has uncommited changes,
 | 
	
		
			
			| 136 | 136 |      #     add "dirty" to build metadata
 | 
	
		
			
			| 137 | 137 |      #
 | 
	
	
		
			
			|  | @@ -140,11 +140,12 @@ get_version() {
 | 
	
		
			
			| 140 | 140 |      # Examples:
 | 
	
		
			
			| 141 | 141 |      #
 | 
	
		
			
			| 142 | 142 |      #     myprog v1.0.7                         # all clear
 | 
	
		
			
			| 143 |  | -    #     myprog v1.0.7-alpha                   # STAGE="alpha"
 | 
	
		
			
			| 144 |  | -    #     myprog v1.0.7-alpha+g1aef811          # ^^ + some commits after
 | 
	
		
			
			| 145 |  | -    #     myprog v1.0.7-alpha+g1aef811.dirty    # ^^ + tree edited
 | 
	
		
			
			|  | 143 | +    #     myprog v1.0.7-alpha                   # PRERELEASE="alpha"
 | 
	
		
			
			|  | 144 | +    #     myprog v1.0.7-alpha+g1aef811.master   # ^^ + some commits after
 | 
	
		
			
			|  | 145 | +    #     myprog v1.0.7-alpha+gf14fc4f.api2     # ^^ + on a feature branch
 | 
	
		
			
			|  | 146 | +    #     myprog v1.0.7-alpha+gf14fc4f.api2.dirty  # ^^ + tree edited
 | 
	
		
			
			| 146 | 147 |      #     myprog v1.0.7-alpha+dirty             # tag OK but tree edited
 | 
	
		
			
			| 147 |  | -    #     myprog v1.0.7+dirty                   # ^^ but no stage
 | 
	
		
			
			|  | 148 | +    #     myprog v1.0.7+dirty                   # ^^ but no pre-release id
 | 
	
		
			
			| 148 | 149 |      #
 | 
	
		
			
			| 149 | 150 |      # Note that versions with "dirty" should be perceived as kind of
 | 
	
		
			
			| 150 | 151 |      # dangerous outside developer's own machine.  Versions with sha1 are
 | 
	
	
		
			
			|  | @@ -164,30 +165,36 @@ get_version() {
 | 
	
		
			
			| 164 | 165 |      #         from tags" fails if we are in shallow clone made from
 | 
	
		
			
			| 165 | 166 |      #         other than a tagged commit.
 | 
	
		
			
			| 166 | 167 |      #
 | 
	
		
			
			|  | 168 | +    # FIXME:  Using PRERELEASE for release IDs may not be compatible with
 | 
	
		
			
			|  | 169 | +    #         release strategy implemented in release.sh
 | 
	
		
			
			|  | 170 | +    #
 | 
	
		
			
			| 167 | 171 |      local version=$VERSION
 | 
	
		
			
			| 168 |  | -    local stage=$STAGE
 | 
	
		
			
			|  | 172 | +    local prerl=$PRERELEASE
 | 
	
		
			
			|  | 173 | +    grep ":" <<<"$prerl" && warn "colon in PRERELEASE may corrupt version data: $prerl"
 | 
	
		
			
			| 169 | 174 |      if git rev-parse HEAD >&/dev/null;
 | 
	
		
			
			| 170 | 175 |      then    # we are in git repo... so we can get smart
 | 
	
		
			
			| 171 | 176 |          local lasttag=$(git tag | grep ^v | sort -V | tail -n1)
 | 
	
		
			
			| 172 | 177 |          if ! git describe --tags --exact-match HEAD >&/dev/null;
 | 
	
		
			
			| 173 |  | -        then    # we are not at later commit than the last tag
 | 
	
		
			
			|  | 178 | +        then    # we are at a later commit than the last tag
 | 
	
		
			
			| 174 | 179 |              local sha=g$(git log -1 --pretty=format:%h HEAD)
 | 
	
		
			
			|  | 180 | +            local curbranch=$(git rev-parse --abbrev-ref HEAD)
 | 
	
		
			
			|  | 181 | +            local commit="$curbranch.$sha"
 | 
	
		
			
			| 175 | 182 |          fi
 | 
	
		
			
			| 176 | 183 |          if test "$(git diff --shortstat 2>/dev/null)" != "";
 | 
	
		
			
			| 177 |  | -        then    # thr tree is "dirty", i.e. has been edited
 | 
	
		
			
			|  | 184 | +        then    # the tree is "dirty", i.e. has been edited
 | 
	
		
			
			| 178 | 185 |              local dirty=dirty
 | 
	
		
			
			| 179 | 186 |          fi
 | 
	
		
			
			| 180 | 187 |          version=${lasttag:1}
 | 
	
		
			
			| 181 | 188 |          local suffix=""
 | 
	
		
			
			| 182 |  | -        case $stage:$sha:$dirty in
 | 
	
		
			
			| 183 |  | -            ::)         suffix=""                    ;;
 | 
	
		
			
			| 184 |  | -            ::dirty)    suffix="+$dirty"             ;;
 | 
	
		
			
			| 185 |  | -            :g*:)       suffix="+$sha"               ;;
 | 
	
		
			
			| 186 |  | -            :g*:dirty)  suffix="+$sha.dirty"         ;;
 | 
	
		
			
			| 187 |  | -            *::)        suffix="-$stage"             ;;
 | 
	
		
			
			| 188 |  | -            *::dirty)   suffix="-$stage+$dirty"      ;;
 | 
	
		
			
			| 189 |  | -            *:g*:)      suffix="-$stage+$sha"        ;;
 | 
	
		
			
			| 190 |  | -            *:g*:dirty) suffix="-$stage+$sha.$dirty" ;;
 | 
	
		
			
			|  | 189 | +        case $prerl:$commit:$dirty in
 | 
	
		
			
			|  | 190 | +            ::)        suffix=""                       ;;
 | 
	
		
			
			|  | 191 | +            ::dirty)   suffix="+$dirty"                ;;
 | 
	
		
			
			|  | 192 | +            :*:)       suffix="+$commit"               ;;
 | 
	
		
			
			|  | 193 | +            :*:dirty)  suffix="+$commit"               ;;
 | 
	
		
			
			|  | 194 | +            *::)       suffix="-$prerl"                ;;
 | 
	
		
			
			|  | 195 | +            *::dirty)  suffix="-$prerl+$dirty"         ;;
 | 
	
		
			
			|  | 196 | +            *:*:)      suffix="-$prerl+$commit"        ;;
 | 
	
		
			
			|  | 197 | +            *:*:dirty) suffix="-$prerl+$commit.$dirty" ;;
 | 
	
		
			
			| 191 | 198 |          esac
 | 
	
		
			
			| 192 | 199 |          version=$version$suffix
 | 
	
		
			
			| 193 | 200 |      fi
 |