-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathjustfile
132 lines (113 loc) · 4.93 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#
# SPDX-FileCopyrightText: © 2020-2025 Serpent OS Developers
#
# SPDX-License-Identifier: MPL-2.0
#
default: (_build build_file)
set dotenv-load
set quiet
# respect variables set in .env file next to the present justfile
boulder := env_var_or_default('BOULDER', 'boulder')
boulder_args := env_var_or_default('BOULDER_ARGS', '')
boulder_profile := env_var_or_default('BOULDER_PROFILE', 'local-x86_64')
build_file := join(invocation_directory(), "stone.yaml")
local_repo := env_var_or_default('LOCAL_REPO', '${HOME}/.cache/local_repo/x86_64')
# Build the stone.yaml recipe using boulder
_build target:
cd {{ invocation_directory() }}; {{boulder}} build {{boulder_args}} -u {{ if path_exists(target) == "true" { target } else { error("Missing stone.yaml file") } }} -p {{ boulder_profile }}
# Build stone.yaml from the current directory
build: (_build build_file)
# Chroot into target from stone.yaml recipe with boulder
_chroot target:
cd {{ invocation_directory() }}; {{boulder}} {{boulder_args}} chroot {{ if path_exists(target) == "true" { target } else { error("Missing stone.yaml file") } }}
_bump target:
cd {{ invocation_directory() }}; {{boulder}} {{boulder_args}} recipe bump
bump: (_bump build_file)
# check existing monitoring.yaml files in the tree for missing mandatory fields
check-monitoring-fields:
#!/usr/bin/env bash
total_count=0
missing_count=0
for f in $(find -type f -name "monitoring.yaml" 2>/dev/null |sort -n ); do
let "total_count=total_count+1"
cpe="$( grep "cpe:" "${f}" )"
id="$( grep "id:" "${f}" )"
rss="$( grep "rss:" "${f}" )"
if [[ "${cpe}" == "" || "${id}" == "" || "${rss}" == "" ]]; then
echo -en "\n${f} is missing mandatory fields:\n>> "
[[ "${cpe}" == "" ]] && echo -n "cpe "
[[ "${id}" == "" ]] && echo -n "id "
[[ "${rss}" == "" ]] && echo -n "rss "
echo -e "<<\nContents:\n---------"
cat "${f}"
echo "---------"
let "missing_count=missing_count+1"
fi
done
echo -e "\nOut of ${total_count} monitoring.yaml files, ${missing_count} are missing mandatory fields.\n"
unset missing_count
unset total_count
# end
# check the entire tree for package recipes missing monitoring.yaml files
check-monitoring-missing:
#!/usr/bin/env bash
OUTPUT=/tmp/check-monitoring-missing.txt
missing_count=0
# find all dirs with a stone.yaml file
find -mindepth 3 -maxdepth 3 -type f -name 'stone.yaml' -exec /usr/bin/dirname '{}' \; 2>/dev/null > "${OUTPUT}"
total_count=$( wc -l "${OUTPUT}" |cut -f1 -d' ' )
# find all dirs with a monitoring.yaml file
find -mindepth 3 -maxdepth 3 -type f -name 'monitoring.yaml' -exec /usr/bin/dirname '{}' \; 2>/dev/null >> "${OUTPUT}"
echo "The following directories have a stone.yaml recipe but no monitoring.yaml file:"
# the non-duplicate lines are most likely dirs with no monitoring.yaml
for d in $( sort -n ${OUTPUT} | uniq -u ); do
[[ -f ${d}/monitoring.yml ]] && echo -n " (has .yml) " || echo -n " "
echo -en "${d}\n"
let "missing_count=missing_count+1"
done
echo -e "\nOut of ${total_count} package recipes, ${missing_count} are missing monitoring.yaml files.\n"
unset missing_count
unset total_count
[[ -f "${OUTPUT}" ]] && rm -f "${OUTPUT}"
# end
# Chroot into pkg from the current directory
chroot: (_chroot build_file)
# Clean up .stone files
_clean target:
cd {{ invocation_directory() }}; rm -v *.stone || echo "No .stone file(s) found"
# Clean *.stone artefacts from the current directory
clean: (_clean build_file)
# Init git hooks
_init target:
ln -sfv ../../tools/prepare-commit-msg.py $(git rev-parse --git-path hooks)/prepare-commit-msg
ln -sfv ../../tools/pre-commit.py $(git rev-parse --git-path hooks)/pre-commit
init: (_init build_file)
[confirm('This will delete ALL .stones in your local repo -- continue?')]
_clean-local:
#!/usr/bin/env bash
set -euo pipefail
if [[ -d {{local_repo}} ]]; then
rm -f {{local_repo}}/*.stone
fi
# clean the LOCAL_REPO dir of .stones and reindex it
clean-local: ls-local && index-local
just _clean-local
# create LOCAL_REPO dir if it doesn't exist
create-local:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -d {{local_repo}} ]]; then
mkdir -pv {{local_repo}}
fi
# index .stones in LOCAL_REPO (create it if it doesn't exist)
index-local: create-local
cd {{ invocation_directory() }} && moss index {{local_repo}}
# list .stones in LOCAL_REPO (create it if it doesn't exist)
ls-local: create-local
cd {{ invocation_directory() }} && ls -AFcghlot {{local_repo}}
# move .stones to LOCAL_REPO (create if it doesn't exist) and reindex it
mv-local: create-local
cd {{ invocation_directory() }} && mv -v *.stone {{local_repo}}/ && moss index {{local_repo}}
# Check for upstream updates
updates:
cd {{ invocation_directory() }} && ent check updates