-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path_config
executable file
·71 lines (54 loc) · 1.98 KB
/
_config
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
#!/usr/bin/env bash
source ${HOME}/.bashrc
set -e
################################################################################
declare DIR="$(dirname ${_SELF})"
declare OPT="$(realpath ${DIR}/.options)"
declare CFG="$(realpath ${DIR}/.config)"
declare SRC="${DIR}/$(head -n2 ${OPT} | tail -n1 | ${SED} "s|^[#][ ]||g")"
########################################
if [[ -d ${1} ]]; then
declare LNX="${1}"
shift
else
exit 1
fi
declare CHR="$(echo "${LNX}" | ${SED} "s|/usr/src/linux$||g")"
declare CHL="$(echo "${LNX}" | ${SED} "s|^${CHR}||g")"
################################################################################
function reconfigure {
declare CONFIG="${1}" && shift
{
${SED} -n "s|^[^#].+[[:space:]](CONFIG_[[:alnum:]_]+)[=]([\"][^\"]+[\"]).*$|\1:\2|gp" ${OPT};
${SED} -n "s|^[^#].+[[:space:]](CONFIG_[[:alnum:]_]+)[=]([ynm]).*$|\1:\2|gp" ${OPT};
} | while read -r FILE; do
declare KEY="${FILE/%:*}"
declare VAL="${FILE/#*:}"
echo "${KEY} -> ${VAL}"
${SED} -i "s|^([#][ ])?(${KEY})[= ].+$|\2=${VAL}|g" ${CONFIG}
done
return 0
}
################################################################################
${RM} ${CFG}.${SCRIPT}.*
########################################
${RSYNC_U} ${CFG} ${CFG}.${SCRIPT}.ORIG
reconfigure ${CFG}.${SCRIPT}.ORIG
diff ${DIFF_OPTS} ${SRC} ${CFG}.${SCRIPT}.ORIG | sort -u | ${GREP} "^[+]"
${RSYNC_U} ${CFG}.${SCRIPT}.ORIG ${LNX}/.config
if [[ -n "${CHR}" ]]; then
chroot ${CHR} bash -c "(cd ${CHL} && make olddefconfig)"
else
(cd ${LNX} && make olddefconfig)
fi
${RSYNC_U} ${LNX}/.config ${CFG}.${SCRIPT}.DONE
${RSYNC_U} ${CFG}.${SCRIPT}.DONE ${CFG}.${SCRIPT}.TEST
reconfigure ${CFG}.${SCRIPT}.TEST
diff ${DIFF_OPTS} ${CFG}.${SCRIPT}.DONE ${CFG}.${SCRIPT}.TEST | sort -u | ${GREP} "^[+]"
########################################
echo -en "\n"
${LL} ${CFG}*
exit 0
################################################################################
# end of file
################################################################################