]> git.saurik.com Git - cydia.git/blobdiff - version.sh
Support listing installed applications on old iOS.
[cydia.git] / version.sh
index 2508390b7f5bb082a64dbdc18b82e1add5dadcb3..3c95ec71093ac6e38117c07f8487fee9f9f52e26 100755 (executable)
@@ -1,5 +1,22 @@
 #!/bin/bash
-ver=$(git describe --tags --dirty="+")
-ver=${ver#v}
-ver=${ver//-/.}
-echo "${ver}"
+
+if [[ $# -eq 0 ]]; then
+    flags=(--dirty="+")
+else
+    flags=("$@")
+fi
+
+version=$(git describe --tags --match="v*" "${flags[@]}" | sed -e 's@-\([^-]*\)-\([^-]*\)$@+\1.\2@;s@^v@@;s@%@~@g')
+
+if grep '#define ForRelease 0' MobileCydia.mm &>/dev/null; then
+    version=${version}~srk
+fi
+
+define="#define CYDIA_VERSION \"${version}\""
+before=$(cat Version.h 2>/dev/null)
+
+if [[ ${before} != ${define} ]]; then
+    echo "${define}" >Version.h
+fi
+
+echo "${version}"