···
3
+
# This script is meant to be used to mark failing hydra builds as broken in the meta attrs
4
+
# To use the script, you should pass the list of failing attrs as arguments to the script.
6
+
# Example: `cat failing-attrs | xargs ./pkgs/common-update/scripts/mark-broken`
8
+
# Generating a list of failing attrs: (this should be improved at a later date)
9
+
# - Go to the most recent hydra evaluation with all builds completed
10
+
# - Select the "builds still failing" tab
11
+
# - Highlight and select all packages, should be prefixed with `nixpkgs.`
12
+
# - Use regex and editor foo to leave only the attr names
13
+
# - Use the above example command to then execute the script
16
+
# - The `denyFileList` and `denyAttrList` will likely need to be updated slightly
17
+
# to align with the conventions used in nixpkgs at execution time
18
+
# - Any attrs which failed for any reason will be written to `failed-marks.txt`.
19
+
# Those attrs will likely need manual attention as disablement will likely be conditional.
scriptName=mark-broken # do not use the .wrapped name
7
-
echo "$scriptName: error: $1" >&2
27
+
echo "$attr: $@" >&2
28
+
echo $attr >> failed-marks.txt
12
-
echo "Usage: $scriptName <attr> [--new-value=<new-value>]"
32
+
echo "Usage: $scriptName <attrs>"
20
-
newValue="${arg#*=}"
27
-
echo "$scriptName: Unknown argument: $arg"
32
-
args["${#args[*]}"]=$arg
39
-
if (( "${#args[*]}" < 1 )); then
35
+
if (( "${#@}" < 1 )); then
echo "$scriptName: Too few arguments"
45
-
if (( "${#args[*]}" > 1 )); then
46
-
echo "$scriptName: Too many arguments"
41
+
# in case we resolve to an auto-generated file, just skip these entries
43
+
node-packages.nix # node, it will mark all node packages as broken
44
+
generic-builder.nix # haskell, it will mark all haskell packages as broken
51
-
if [ -z $newValue ]; then
47
+
# ignore older versions of parameterized packages sets, these likely need
48
+
# to be conditionally disabled
55
-
nixFile=$(nix-instantiate --eval --json -E "with import ./. {}; (builtins.unsafeGetAttrPos \"description\" $attr.meta).file" | jq -r .)
56
-
if [[ ! -f "$nixFile" ]]; then
57
-
die "Couldn't evaluate 'builtins.unsafeGetAttrPos \"description\" $attr.meta' to locate the .nix file!"
57
+
function attemptToMarkBroken() {
60
-
# Insert broken attribute
61
-
sed -i.bak "$nixFile" -r \
62
-
-e "/^\s*broken\s*=.*$/d" \
63
-
-e "s/(\s*)meta\s*=.*\{/&\n\1 broken = $newValue;/"
60
+
# skip likely to be noisy attrs
61
+
for badAttr in ${denyAttrList[@]};do
62
+
if [[ $attr =~ $badAttr ]]; then
63
+
failMark $attr "attr contained $badAttr, skipped."
65
-
if cmp -s "$nixFile" "$nixFile.bak"; then
66
-
mv "$nixFile.bak" "$nixFile"
67
-
die "Failed to mark the package as broken! Does it have a meta attribute?"
68
+
nixFile=$(nix-instantiate --eval --json -E "with import ./. {}; (builtins.unsafeGetAttrPos \"description\" $attr.meta).file" 2>/dev/null | jq -r .)
69
+
if [[ ! -f "$nixFile" ]]; then
70
+
failMark $attr "Couldn't locate correct file"
70
-
if [[ "$newValue" == "true" ]]; then
71
-
# broken should evaluate to true in any case now
72
-
markedSuccessfully=$(nix-instantiate --eval -E "with import ./. {}; $attr.meta.broken" || true)
73
-
if [[ ! "$markedSuccessfully" == "true" ]]; then
74
-
mv "$nixFile.bak" "$nixFile"
75
-
die "Couldn't verify the broken attribute to be set correctly, restoring backup!"
78
-
# we can not check if broken evaluates to the correct value, but we can check that it does evaluate
79
-
if ! nix-instantiate --eval -E "with import ./. {}; $attr.meta.broken" >/dev/null; then
80
-
mv "$nixFile.bak" "$nixFile"
81
-
die "Couldn't verify the broken attribute to be set correctly, restoring backup!"
74
+
# skip files which are auto-generated
75
+
for filename in ${denyFileList[@]};do
76
+
if [[ "$filename" == $(basename $nixFile) ]]; then
77
+
failMark $attr "filename matched $filename, skipped."
82
+
# Insert broken attribute
83
+
sed -i.bak "$nixFile" -r \
84
+
-e "/^\s*broken\s*=.*$/d" \
85
+
-e "s/(\s*)meta\s*=.*\{/&\n\1 broken = true;/"
85
-
rm -f "$nixFile.bak"
86
-
rm -f "$attr.fetchlog"
87
+
if cmp -s "$nixFile" "$nixFile.bak"; then
88
+
mv "$nixFile.bak" "$nixFile"
89
+
failMark $attr "Does it have a meta attribute?"
93
+
# broken should evaluate to true in any case now
94
+
markedSuccessfully=$(nix-instantiate --eval -E "with import ./. {}; $attr.meta.broken")
95
+
if [[ "$markedSuccessfully" != "true" ]]; then
96
+
mv "$nixFile.bak" "$nixFile"
97
+
failMark $attr "$attr.meta.broken doesn't evaluate to true."
101
+
rm -f "$nixFile.bak"
105
+
attemptToMarkBroken $attr