This repository has been archived by the owner on Jun 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprepare.sh
90 lines (70 loc) · 2.64 KB
/
prepare.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
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
#!/bin/bash
shopt -extglob
my_dir=`dirname "$0"`
cd $my_dir
aio=./co2mpas_AIO-2.0.0
##aio_ver="$(cat VERSION.txt)" !!
read -d $'\x04' aio_ver < VERSION.txt
rm="rm -v"
cp="cp -v"
mkdir=mkdir
sed=sed
gpg="${aio}/Apps/GnuPG/pub/gpg2"
GPG="$gpg" # Not PRETENDING.
cat=cat
echo=echo
if [[ " $* " =~ " -n " ]]; then
noop="echo"
rm="echo PRETEND $rm"
cp="echo PRETEND $cp"
mkdir="echo PRETEND $mkdir"
sed="echo PRETEND $sed"
gpg="echo PRETEND $gpg"
cat="echo PRETEND $cat"
echo="echo PRETEND $echo"
fi
###################################
## Clean up existing files ##
###################################
## Cleanup GnuPG-HOME.
$rm -rf "$aio/Apps/GnuPG/home/*"
## Cleanup pacman caches.
#
#$noop $aio/Apps/MSYS2/usr/bin/pacman -Scc --noconfirm
$rm -rf $aio/Apps/MSYS2/var/cache/*
find ${aio} -mindepth 1 -name '*.ver' | xargs $rm -rf
find ${aio}/{*.xlsx,*.zip,*.ipynb} | xargs $rm -rf
find ${aio}/CO2MPAS -mindepth 1 | grep -vFf keepfiles.txt | xargs $rm -rf
find ${aio}/Apps/WinPython/settings -mindepth 1 | grep -v winpython.ini | grep -v .jupyter | grep -v .ipython | xargs $rm -rf
## Remove root scripts and version engraving.
$rm -f ${aio}/*
## TOO BIG.
$rm -rf ${aio}/Apps\WinPython/python-3.5.2.amd64/Lib/site-packages/wltp/test
find . -name __pycache__ -type d | xargs $rm -rf
###################################
## Start creating dirs & folders ##
###################################
$cp -r ./Archive/* ${aio}/.
## Clone demo-files into co2mpas HOME:
$mkdir -p ${aio}/CO2MPAS/co2mpas-demos
$cp ./Archive/Apps/.co2mpas-demos/* ${aio}/CO2MPAS/co2mpas-demos/.
## Copy template-file into co2mpas HOME:
$cp ./co2mpas_AIO/Apps/WinPython/python*/Lib/site-packages/co2mpas/co2mpas_template.xlsx ${aio}/CO2MPAS/.
$mkdir -p "$aio/Apps/GnuPG/var/cache/gnupg"
## Ensure log-file not in DEBUG mode.
$sed -i 's/^ level: .*/ level: INFO # one of: DEBUG INFO WARNING ERROR FATAL/' ${aio}/CO2MPAS/.co2_logconf.yaml.SAMPLE
## Set Co2mpas test-key expiration 6monts:
printf 'expire\n6m\nsave\n' | $gpg --batch --yes --command-fd 0 --status-fd 2 --edit-key 5464E04EE547D1FEDCAC4342B124C999CBBB52FF
$GPG --rebuild-keydb-caches
## WinPython relocatable executables (i.e. `co2mpas.exe`).
$noop "${aio}/Apps/WinPython/scripts/make_winpython_movable.bat"
## Check keys...
test_key="CBBB52FF"
stamper_key="70B61F81"
jrc_stamper_key="94777323"
echo "\n\Inspect MANUALLY expiration, and no other keys than:"
echo -e " $test_key\n $stamper_key\n $jrc_stamper_key"
$GPG --allow-weak-digest-algos --list-keys
## Engrave AIO version.
$sed -i "s/X.Y.Z/$aio_ver/g" "$aio/Apps/Console/console.xml" "$aio/README.txt"
$echo "$aio_ver" > "$aio/AIO-$aio_ver.ver"