Merge pull request #665 from hauke/lantiq-dsl
[project/luci.git] / modules / luci-base / src / mkversion.sh
1 #!/bin/sh
2
3 if svn info >/dev/null 2>/dev/null; then
4         if [ "${4%%/*}" = "branches" ]; then
5                 variant="LuCI ${4##*[-/]} Branch"
6         elif [ "${4%%/*}" = "tags" ]; then
7                 variant="LuCI ${4##*[-/]} Release"
8         else
9                 variant="LuCI Trunk"
10         fi
11 elif git status >/dev/null 2>/dev/null; then
12         tag="$(git describe --tags 2>/dev/null)"
13         branch="$(git symbolic-ref --short -q HEAD 2>/dev/null)"
14
15         if [ -n "$tag" ]; then
16                 variant="LuCI $tag Release"
17         elif [ "$branch" != "master" ]; then
18                 variant="LuCI ${branch##*-} Branch"
19         else
20                 variant="LuCI Master"
21         fi
22 else
23         variant="LuCI"
24 fi
25
26 cat <<EOF > $1
27 local pcall, dofile, _G = pcall, dofile, _G
28
29 module "luci.version"
30
31 if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then
32         distname    = ""
33         distversion = _G.DISTRIB_DESCRIPTION
34 else
35         distname    = "OpenWrt"
36         distversion = "Development Snapshot"
37 end
38
39 luciname    = "$variant"
40 luciversion = "${2:-Git}"
41 EOF