@@ -16,125 +16,42 @@ set -e
1616
1717script_path=" $( cd -P " $( dirname " $( readlink -f " $0 " ) " ) " && cd .. && pwd ) "
1818arch=" $( uname -m) "
19-
19+ archlinux32_repo= " http://mirror.juniorjpdj.pl/archlinux32/i486/core/ "
2020
2121# Set pacman.conf when build alterlinux
2222alter_pacman_conf_x86_64=" ${script_path} /system/pacman-x86_64.conf"
2323alter_pacman_conf_i686=" ${script_path} /system/pacman-i686.conf"
2424
25-
26- # Color echo
27- # usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
28- #
29- # Text Color
30- # 30 => Black
31- # 31 => Red
32- # 32 => Green
33- # 33 => Yellow
34- # 34 => Blue
35- # 35 => Magenta
36- # 36 => Cyan
37- # 37 => White
38- #
39- # Background color
40- # 40 => Black
41- # 41 => Red
42- # 42 => Green
43- # 43 => Yellow
44- # 44 => Blue
45- # 45 => Magenta
46- # 46 => Cyan
47- # 47 => White
48- #
49- # Text decoration
50- # You can specify multiple decorations with ;.
51- # 0 => All attributs off (ノーマル)
52- # 1 => Bold on (太字)
53- # 4 => Underscore (下線)
54- # 5 => Blink on (点滅)
55- # 7 => Reverse video on (色反転)
56- # 8 => Concealed on
57-
58- echo_color () {
59- local backcolor
60- local textcolor
61- local decotypes
62- local echo_opts
63- local OPTIND_bak=" ${OPTIND} "
64- unset OPTIND
65-
66- echo_opts=" -e"
67-
68- while getopts ' b:t:d:n' arg; do
69- case " ${arg} " in
70- b) backcolor=" ${OPTARG} " ;;
71- t) textcolor=" ${OPTARG} " ;;
72- d) decotypes=" ${OPTARG} " ;;
73- n) echo_opts=" -n -e" ;;
74- esac
75- done
76-
77- shift $(( OPTIND - 1 ))
78-
79- echo ${echo_opts} " \e[$( [[ -v backcolor ]] && echo -n " ${backcolor} " ; [[ -v textcolor ]] && echo -n " ;${textcolor} " ; [[ -v decotypes ]] && echo -n " ;${decotypes} " ) m${* } \e[m"
80- OPTIND=${OPTIND_bak}
25+ # Message common function
26+ # msg_common [type] [-n] [string]
27+ msg_common (){
28+ local _msg_opts=(" -a" " keyring.sh" ) _type=" ${1} "
29+ shift 1
30+ [[ " ${1} " = " -n" ]] && _msg_opts+=(" -o" " -n" ) && shift 1
31+ _msg_opts+=(" ${_type} " " ${@ } " )
32+ " ${script_path} /tools/msg.sh" " ${_msg_opts[@]} "
8133}
8234
8335# Show an INFO message
84- # $1: message string
85- msg_info () {
86- local _msg_opts=" -a keyring.sh"
87- if [[ " ${1} " = " -n" ]]; then
88- _msg_opts=" ${_msg_opts} -o -n"
89- shift 1
90- fi
91- " ${script_path} /tools/msg.sh" ${_msg_opts} info " ${1} "
92- }
36+ # ${1}: message string
37+ msg_info () { msg_common info " ${@ } " ; }
9338
9439# Show an Warning message
95- # $1: message string
96- msg_warn () {
97- local _msg_opts=" -a keyring.sh"
98- if [[ " ${1} " = " -n" ]]; then
99- _msg_opts=" ${_msg_opts} -o -n"
100- shift 1
101- fi
102- " ${script_path} /tools/msg.sh" ${_msg_opts} warn " ${1} "
103- }
104-
105- # Show an debug message
106- # $1: message string
107- msg_debug () {
108- if [[ " ${debug} " = true ]]; then
109- local _msg_opts=" -a keyring.sh"
110- if [[ " ${1} " = " -n" ]]; then
111- _msg_opts=" ${_msg_opts} -o -n"
112- shift 1
113- fi
114- " ${script_path} /tools/msg.sh" ${_msg_opts} debug " ${1} "
115- fi
116- }
40+ # ${1}: message string
41+ msg_warn () { msg_common warn " ${@ } " ; }
11742
11843# Show an ERROR message then exit with status
119- # $1 : message string
120- # $2 : exit code number (with 0 does not exit)
44+ # ${1} : message string
45+ # ${2} : exit code number (with 0 does not exit)
12146msg_error () {
122- local _msg_opts=" -a keyring.sh"
123- if [[ " ${1} " = " -n" ]]; then
124- _msg_opts=" ${_msg_opts} -o -n"
125- shift 1
126- fi
127- " ${script_path} /tools/msg.sh" ${_msg_opts} error " ${1} "
128- if [[ -n " ${2:- } " ]]; then
129- exit ${2}
130- fi
47+ msg_common error " ${1} "
48+ [[ -n " ${2:- } " ]] && exit " ${2} "
49+ return 0
13150}
13251
13352# Usage: getclm <number>
13453# 標準入力から値を受けとり、引数で指定された列を抽出します。
135- getclm () {
136- echo " $( cat -) " | cut -d " " -f " ${1} "
137- }
54+ getclm () { cut -d " " -f " ${1} " ; }
13855
13956
14057# Show usage
@@ -227,12 +144,24 @@ remove_alter_key() {
227144}
228145
229146update_arch32_key () {
147+ ! pacman -Ssq archlinux32-keyring | grep -x archlinux32-keyring 2> /dev/null 1>&2 && msg_error " Not found archlinux32-keyring on remote repository. You should install it manually." 1
230148 pacman --noconfirm -S archlinux32-keyring
231149 pacman-key --init
232150 pacman-key --populate archlinux32
233151 # pacman-key --refresh-keys
234152}
235153
154+ new_update_arch32_key (){
155+ local _savedir=" ${HOME} /.cache"
156+ while read -r _pkg ; do
157+ curl -o " ${_savedir} /${_pkg} " " ${archlinux32_repo} /${_pkg} "
158+ pacman -U --noconfirm " ${_savedir} /${_pkg} "
159+ rm -f " ${_savedir} /${_pkg} "
160+ done < <( curl -sL " ${archlinux32_repo} " | sed " s|<a href=\" ||g" | cut -d " \" " -f 1 | grep -v " ^<" | grep -v " .sig$" | grep " .pkg.tar." | grep " archlinux32-keyring" | grep -v " archlinux32-keyring-transition" )
161+ pacman-key --init
162+ pacman-key --populate archlinux32
163+ }
164+
236165remove_arch32_key () {
237166 pacman -Rsnc archlinux32-keyring
238167}
0 commit comments