kernel: remove stray 4.4 references
[openwrt/openwrt.git] / scripts / get_source_date_epoch.sh
1 #!/usr/bin/env bash
2 export LANG=C
3 export LC_ALL=C
4 [ -n "$TOPDIR" ] && cd $TOPDIR
5
6 try_version() {
7 [ -f version.date ] || return 1
8 SOURCE_DATE_EPOCH="$(cat version.date)"
9 [ -n "$SOURCE_DATE_EPOCH" ]
10 }
11
12 try_git() {
13 [ -e .git ] || return 1
14 SOURCE_DATE_EPOCH="$(git log -1 --format=format:%ct)"
15 [ -n "$SOURCE_DATE_EPOCH" ]
16 }
17
18 try_hg() {
19 [ -d .hg ] || return 1
20 SOURCE_DATE_EPOCH="$(hg log --template '{date}' -l 1 | cut -d. -f1)"
21 [ -n "$SOURCE_DATE_EPOCH" ]
22 }
23
24 try_mtime() {
25 perl -e 'print((stat $ARGV[0])[9])' "$0"
26 [ -n "$SOURCE_DATE_EPOCH" ]
27 }
28
29 try_version || try_git || try_hg || try_mtime || SOURCE_DATE_EPOCH=""
30 echo "$SOURCE_DATE_EPOCH"