-
Notifications
You must be signed in to change notification settings - Fork 0
/
stackdiff
executable file
·94 lines (75 loc) · 1.77 KB
/
stackdiff
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
#!/bin/bash
# compare two apps trees
# print results as markdown
#
# Ruoshi Sun
# 2020-02-18, 05-14
if [ $# -ne 2 ]; then
echo "Usage: `basename $0` stack1 stack2"
exit 1
fi
module purge
ml tree
STACK1=$1
STACK2=$2
DIR=~/tree/${STACK1}-${STACK2}
mkdir $DIR || true
function stack_diff {
CATEGORY=$1
DEPTH=$2
TREE1=tree-${STACK1}-${CATEGORY}.txt
TREE2=tree-${STACK2}-${CATEGORY}.txt
TREE12=tree-${STACK1}-${STACK2}-${CATEGORY}.txt
APPDIR1=/sfs/applications/$STACK1/software/standard
APPDIR2=/sfs/applications/$STACK2/software/standard
cd $APPDIR1/$CATEGORY
tree -df -L $DEPTH . | sed 's/^.....//' > $DIR/$TREE1
cd $APPDIR2/$CATEGORY
tree -df -L $DEPTH . | sed 's/^.....//' > $DIR/$TREE2
diff <(parse $DIR/$TREE1) <(parse $DIR/$TREE2) > $DIR/$TREE12
tree2md $CATEGORY $DEPTH $TREE12
}
function parse {
FILE=$1
# to treat "-" literally, need to put it as the first or last character
sed 's/[^-0-9a-zA-Z_\.\/]//g' $FILE
}
function tree2md {
CATEGORY=$1
DEPTH=$2
TREE12=$3
NF=$((DEPTH+1))
LIST=list-${STACK1}-${STACK2}-${CATEGORY}.txt
# Steps:
# 1. only show deepest level directory
# 2. change to +/-
# 3. group +/-
# 4. write
TMP=$(
awk -F'/' -v n=$NF '{
if (NF==n) print
}' $DIR/$TREE12 | \
sed -e '/^[^><]/d' \
-e 's/^> \.\//\+ /' \
-e 's/^< \.\//\- /'
)
grep "^-" <<< "$TMP" >$DIR/$LIST
echo >>$DIR/$LIST
grep "^+" <<< "$TMP" >>$DIR/$LIST
# print markdown
echo "**${CATEGORY}**"
echo "\`\`\`bash"
cat $DIR/$LIST
echo "\`\`\`"
echo
}
# core
stack_diff core 2
# compiler
stack_diff compiler 4
# mpi
stack_diff mpi 6
# toolchains
stack_diff toolchains 2
# container
stack_diff container 4