-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfetch_from_upstream.sh
executable file
·46 lines (38 loc) · 1.04 KB
/
fetch_from_upstream.sh
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
#!/bin/bash
#
# Fetch new code for the Alif Security Toolkit, and clean it up a little.
if [ $# -ne 1 ]; then
echo "usage: $0 <src>"
echo ""
echo "eg: $0 path/to/app-release"
exit 1
fi
alifsrc=$1
alifdest=./toolkit/
if [ ! -f $alifsrc/maintenance.py ]; then
echo "ERROR: $alifsrc does not contain an Alif Security Toolkit"
exit 1
fi
# Remove any old files and copy across the new ones.
echo "Fetching Alif Security Toolkit"
rm -rf $alifdest
mkdir -p $alifdest
cp -r $alifsrc/* $alifdest
# Remove __pycache__.
rm -rf `find $alifdest -name __pycache__`
# Convert newlines to Unix style, and ensure there's a newline at the end of the file.
for file in `find $alifdest -regex '.+\.\(py\|txt\|json\)'`; do
cat $file | sed 's/$//' | sed '$a\' > tmp$$
/bin/mv tmp$$ $file
done
# Make sure permission flags are sensible.
for file in `find $alifdest -type f`; do
if grep -q argparse $file; then
chmod 755 $file
else
chmod 644 $file
fi
done
# Format Python code.
ruff format `find $alifdest -name \*.py`