-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcleanall
executable file
·146 lines (128 loc) · 3.41 KB
/
cleanall
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Part of the SEALS project
# cleanall
# *CAREFUL*! WIPES all builds
# Set Bash unofficial 'strict mode'; _really_ helps catch bugs
# ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
name=$(basename $0)
# Fetch the SEALs env
source ./build.config || {
echo "${name}: ./build.config file missing or invalid? using defaults if they exist..."
if [ -d ./images ]; then
STG=./
else
echo "No ./images/ dir, aborting..."
exit 1
fi
}
source ./common.sh || {
echo "${name}: source failed! ./common.sh missing or invalid?"
exit 1
}
clean_kernel()
{
aecho "Cleaning kernel source tree now..."
[[ ! -d ${KERNEL_FOLDER} ]] && {
echo "*** ERROR: kernel folder \"${KERNEL_FOLDER}\" not found ***"
return
}
cd ${KERNEL_FOLDER} || FatalError "cd to kernel folder failed"
local CMD="make mrproper"
runcmd "${CMD}"
cd ${TOPDIR}
}
clean_bb()
{
aecho "Cleaning Busybox source tree now..."
[[ ! -d ${BB_FOLDER} ]] && {
echo "*** ERROR: busybox folder \"${BB_FOLDER}\" not found ***"
return
}
cd ${BB_FOLDER} || FatalError "cd to busybox folder failed"
local CMD="make mrproper"
runcmd "${CMD}"
cd ${TOPDIR}
}
clean_rootfs()
{
aecho "About to Wipe rootfs source tree now..."
[[ ! -d ${ROOTFS_DIR} ]] && {
echo "*** ERROR: rootfs folder \"${ROOTFS_DIR}\" not found ***"
return
}
cd ${ROOTFS_DIR} || FatalError "cd to rootfs folder failed"
# !!! BE VERY CAREFUL !!!
local CMD="sudo rm -rf *"
get_yn_reply "PLEASE RECHECK and CONFIRM !? Completely wipe root fs staging folder (here: ${ROOTFS_DIR})" n
[[ $? -eq 0 ]] && {
echo "In $(pwd)"
runcmd "${CMD}"
}
cd ${TOPDIR}
}
clean_images()
{
aecho "Wiping the images folder now..."
[[ ! -d ${IMAGES_FOLDER} ]] && {
echo "*** ERROR: images folder \"${IMAGES_FOLDER}\" not found ***"
return
}
cd ${IMAGES_FOLDER} || FatalError "cd to images folder failed"
# !!! BE VERY CAREFUL !!!
local CMD="sudo rm -rf *"
[[ $? -eq 0 ]] && {
echo "In $(pwd)"
runcmd "${CMD}"
}
cd ${TOPDIR}
}
clean_images_bkp()
{
aecho "Wiping the images backup folder now..."
[[ ! -d ${IMAGES_BKP_FOLDER} ]] && {
echo "*** ERROR: images backup folder \"${IMAGES_BKP_FOLDER}\" not found ***"
return
}
cd ${IMAGES_BKP_FOLDER} || FatalError "cd to images backup folder failed"
# !!! BE VERY CAREFUL !!!
local CMD="sudo rm -rf *"
[[ $? -eq 0 ]] && {
echo "In $(pwd)"
runcmd "${CMD}"
}
cd ${TOPDIR}
}
### --- 'main'
TOPDIR=$(pwd)
ShowTitle "SEALS :: CLEAN ALL Script"
echo "FYI, this is the current SEALS config:
"
./show_curr_config.sh
Prompt "" #[Enter] to continue, ^C to abort..."
echo
get_yn_reply "COMPLETELY CLEAN kernel source tree (here: ${KERNEL_FOLDER})
(this will also wipe any kernel config files)
[make mrproper] ?" n
[[ $? -eq 0 ]] && clean_kernel
echo
get_yn_reply "COMPLETELY CLEAN busybox source tree (here: ${BB_FOLDER})
(this will also wipe any busybox config files)
[make mrproper] ?" n
[[ $? -eq 0 ]] && clean_bb
echo
[[ "${ARCH_PLATFORM}" != "x86_64" ]] && ROOTFS_DIR=${ROOTFS} || ROOTFS_DIR=${ROOTFS_PC}
get_yn_reply "COMPLETELY WIPE root fs staging folder (here: ${ROOTFS_DIR})
?" n
[[ $? -eq 0 ]] && clean_rootfs
echo
get_yn_reply "COMPLETELY WIPE images folder (here: ${IMAGES_FOLDER})
?" n
[[ $? -eq 0 ]] && clean_images
echo
get_yn_reply "COMPLETELY WIPE images backup folder (here: ${IMAGES_BKP_FOLDER})
?" n
[[ $? -eq 0 ]] && clean_images_bkp
# configs?
#CONFIGS_FOLDER=${STG}/configs
exit 0