-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions
More file actions
120 lines (99 loc) · 2.63 KB
/
functions
File metadata and controls
120 lines (99 loc) · 2.63 KB
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
#!/bin/bash
# author: steve.jeong
# date: 2022.11.09
# dependency: . prefix
confirm() {
read -r -p "${1:-Are you sure? [Y/n]} " response
case ${response} in
[nN][oO]|[nN])
echo "no"
false
;;
*)
echo "yes"
true
;;
esac
}
do_backup() {
local backup_list=""
# path of backups
backup_list=("${HOME}/.bashrc"
"${HOME}/.gitconfig"
"${HOME}/.tmux.conf"
)
# setup backup dir
[ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR}
# setup backups to install dir
for backup_file in ${backup_list[@]}; do
[ -e ${backup_file} ] && \
rsync -a ${backup_file} ${BACKUP_DIR}
done
echo "backup configs... OK"
}
do_install() {
local fixup_list=""
local prog=""
fixup_list=$(ls -A1 ${INSTALL_DIR}/fixups/*)
for fixup in ${fixup_list}; do
prog=${fixup#*fixups/}
prog=${prog:1:2}
echo "processing... ${prog}%"
. ${fixup}
sleep ${SPEED}
done
echo "COMPLETE!... 100%"
}
do_preinstall() {
local fixup_list=""
local pkg_list=""
# path of fixups
fixup_list=("${TOP_DIR}/common/fixups"
"${TOP_DIR}/distro/${DISTRO}/${FLAVOUR}/fixups"
"${TOP_DIR}/target/${TARGET}/fixups"
)
# path of packages
pkg_list=("${TOP_DIR}/common/packages"
"${TOP_DIR}/distro/${DISTRO}/${FLAVOUR}/packages"
"${TOP_DIR}/target/${TARGET}/packages"
)
# setup install dir
[ ! -d ${INSTALL_DIR} ] && mkdir -p ${INSTALL_DIR}
# setup fixups to install dir
for fixups in ${fixup_list[@]}; do
[ -d ${fixups} ] && \
rsync -a ${fixups} ${INSTALL_DIR}
done
# reconf fixups
fixups="$(ls -A1 ${INSTALL_DIR}/fixups/*)"
for fixup in ${fixups}; do
sed -i \
-e "s,__APT_OPTIONS__,$(get_apt_options),g" \
-e "s,__BACKUP_DIR__,${BACKUP_DIR},g" \
-e "s,__DISTRO__,${DISTRO},g" \
-e "s,__GIT_OPTIONS__,$(get_git_options),g" \
-e "s,__HOME__,${HOME},g" \
-e "s,__INSTALL_DIR__,${INSTALL_DIR},g" \
-e "s,__FALVOUR__,${FLAVOUR},g" \
-e "s,__OS__,${OS},g" \
-e "s,__TARGET__,${TARGET},g" \
-e "s,__TOP_DIR__,${TOP_DIR},g" \
-e "s,__VERSION__,${VERSION},g" \
${fixup}
done
# setup packages to install dir
for pkgs in ${pkg_list[@]}; do
[ -e ${pkgs} ] && \
cat ${pkgs} | tee -a ${INSTALL_DIR}/packages > /dev/null
done
# reconf pakages
pkgs="$(cat ${INSTALL_DIR}/packages | tr " " "\n" | sort | uniq | tr "\n" " ")"
echo ${pkgs} > ${INSTALL_DIR}/packages
echo "reconfig before install... OK"
}
get_apt_options() {
echo "-y --no-install-recommends"
}
get_git_options() {
echo "--global"
}