4 # Opennet trac-bitten-slave Scripts
5 # Mathias Mahnke, created 2014/05/05
6 # Opennet Admin Group <admin@opennet-initiative.de>
9 # stop on error and unset variables
12 # get config file name
13 FILE=
"$(basename "$0
")"
16 # get current script dir
17 HOME=
"$(dirname $(readlink -f "$0
"))"
18 OPENWRT_CONFIG=
"${HOME}/../../../openwrt/.config"
28 grep
"^CONFIG_VERSION_NUMBER=" "$OPENWRT_CONFIG" | cut -f 2 -
d '"'
33 # kurze Uebersicht aller commits des aktuellen Builds inkl. eines Commit-Zaehlers
34 git log --oneline | sed -n
'1!G;h;$p' | nl | tac
40 local snapshot_name=$(get_snapshot_name)
41 [ -z
"$snapshot_name" ] &&
return 1
43 # prepare export directory
44 local dest_dir=
"$HOME/$EXPORT_DIR/$snapshot_name"
45 local dest_platform_dir=
"$dest_dir/$platform"
46 mkdir -
p "$dest_platform_dir"
48 # copy build to export directory
49 local src_dir=
"$HOME/$BIN_DIR/$platform"
50 rsync $RSYNC_OPTIONS
"$src_dir/" "$dest_platform_dir/"
52 #
set version number in export directories
53 get_commit_info >
"$dest_dir/__${snapshot_name}__"
54 get_commit_info >
"$dest_platform_dir/__${snapshot_name}__"
56 # generate latest link
57 rm -f
"$HOME/$EXPORT_DIR/$LATEST_LINK"
58 (cd
"$HOME/$EXPORT_DIR" && ln -
s "$snapshot_name" "$LATEST_LINK")
63 local snapshot_name=$(get_snapshot_name)
64 [ -z
"$snapshot_name" ] &&
return 1
65 local dest_dir=
"$HOME/$EXPORT_DIR/$snapshot_name/doc"
67 local src_dir=
"$HOME/$DOC_DIR"
68 echo
"Copying documentation: $src_dir -> $dest_dir"
69 rsync $RSYNC_OPTIONS
"$src_dir/" "$dest_dir/"
74 local keep_builds=
"$1"
75 cd
"$HOME/$EXPORT_DIR"
76 # "uniq -u" entfernt doppelte Zeilen - also verbleiben nur die alten Dateien
78 ls -t | head -n
"$keep_builds"
80 ) | sort | uniq -u | xargs --delimiter
'\n' --no-run-
if-empty rm -r
87 echo "Usage: $(basename "$0")"
88 echo " [<platform>] - export build"
89 echo " --doc - generate documentation"
90 echo " --purge <keep-number-of-dirs> - purge old exports"
98 [ -z
"$keep_builds" ] && echo >&2
"No number of non-purgeable builds given" && exit 2
99 echo
"$keep_builds" | grep -q
"[^0-9]" && echo >&2
"Number of non-purgeable builds contains non-digits: '$keep_builds'" && exit 3
100 [
"$keep_builds" -lt 1 ] && echo >&2
"Number of non-purgeable builds is too low: '$keep_builds'" && exit 4
101 purge_old_exports
"$keep_builds"
104 build_platform
"$action"