Skip to content

Commit 5614b41

Browse files
committed
stats - merge licences and pkgflags into a single module
* allow configuration of upload host/port * de-duplicate functions / split out git info into function * use an array for data / reduce var usage
1 parent 39c709a commit 5614b41

File tree

10 files changed

+71
-102
lines changed

10 files changed

+71
-102
lines changed

scriptmodules/admin/licences.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

scriptmodules/admin/pkgflags.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

scriptmodules/admin/stats.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
# This file is part of The RetroPie Project
4+
#
5+
# The RetroPie Project is the legal property of its developers, whose names are
6+
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
7+
#
8+
# See the LICENSE.md file at the top-level directory of this distribution and
9+
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
10+
#
11+
12+
rp_module_id="stats"
13+
rp_module_desc="Generates statistics about packages"
14+
rp_module_section=""
15+
16+
function _dest_stats() {
17+
local dest="$__tmpdir/stats"
18+
mkUserDir "$dest"
19+
echo "$dest"
20+
}
21+
22+
function _get_commit_data_stats() {
23+
local hash=$(git -C "$scriptdir" log -1 --format=%h)
24+
local date=$(git -C "$scriptdir" log -1 --format=%cd --date=iso-strict)
25+
local branch=$(git -C "$scriptdir" rev-parse --abbrev-ref HEAD)
26+
echo "$hash;$date;$branch;"
27+
}
28+
29+
function licences_stats() {
30+
local data=()
31+
32+
local dest="$(_dest_stats)/licences"
33+
mkUserDir "$dest"
34+
35+
local idx
36+
for idx in ${__mod_idx[@]}; do
37+
data+=("${__mod_section[$idx]};${__mod_id[$idx]};${__mod_desc[$idx]};${__mod_licence[$idx]};")
38+
done
39+
printf "%s\n" "${data[@]}" >"$dest/packages.csv"
40+
41+
echo "$(_get_commit_data_stats)" > "$dest/commit.csv"
42+
43+
cp -v "$md_data/licences/"* "$dest/"
44+
chown -R $user:$user "$dest"
45+
}
46+
47+
function packages_stats() {
48+
local data=()
49+
50+
local dest="$(_dest_stats)/pkgflags"
51+
mkUserDir "$dest"
52+
53+
local idx
54+
for idx in ${__mod_idx[@]}; do
55+
data+=("${__mod_section[$idx]};${__mod_id[$idx]};${__mod_desc[$idx]};${__mod_flags[$idx]};")
56+
done
57+
printf "%s\n" "${data[@]}" >"$dest/packages.csv"
58+
59+
echo "$(_get_commit_data_stats)" > "$dest/commit.csv"
60+
61+
cp -v "$md_data/pkgflags/"* "$dest/"
62+
chown -R $user:$user "$dest"
63+
}
64+
65+
function upload_stats() {
66+
local host="$__upload_host"
67+
[[ -z "$host" ]] && host="$__binary_host"
68+
local port="$__upload_port"
69+
[[ -z "$port" ]] && port=22
70+
rsync -av --progress --delay-updates -e "ssh -p $port" "$__tmpdir/stats/" "retropie@$host:stats/"
71+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)