5 # Email : hayao@fascode.net
7 # (c) 2019-2020 Fascode Network.
11 # Script to import AlterLinux and ArchLinux keys.
17 script_path="$(readlink -f ${0%/*})"
21 # Set pacman.conf when build alterlinux
22 alter_pacman_conf_x86_64="${script_path}/system/pacman-x86_64.conf"
23 alter_pacman_conf_i686="${script_path}/system/pacman-i686.conf"
27 # usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
50 # You can specify multiple decorations with ;.
51 # 0 => All attributs off (ノーマル)
53 # 4 => Underscore (下線)
55 # 7 => Reverse video on (色反転)
63 local OPTIND_bak="${OPTIND}"
68 while getopts 'b:t:d:n' arg; do
70 b) backcolor="${OPTARG}" ;;
71 t) textcolor="${OPTARG}" ;;
72 d) decotypes="${OPTARG}" ;;
73 n) echo_opts="-n -e" ;;
79 echo ${echo_opts} "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${*}\e[m"
84 # Show an INFO message
88 echo "$( echo_color -t '36' '[keyring.sh]') $( echo_color -t '32' 'Info') ${_msg}"
92 # Show an Warning message
96 echo "$( echo_color -t '36' '[keyring.sh]') $( echo_color -t '33' 'Warning') ${_msg}" >&2
100 # Show an debug message
104 if [[ ${debug} = true ]]; then
105 echo "$( echo_color -t '36' '[keyring.sh]') $( echo_color -t '35' 'Debug') ${_msg}"
110 # Show an ERROR message then exit with status
112 # $2: exit code number (with 0 does not exit)
115 echo "$( echo_color -t '36' '[keyring.sh]') $( echo_color -t '31' 'Error') ${_msg}" >&2
121 echo "usage ${0} [options]"
123 echo " General options:"
124 echo " -a | --alter-add Add alterlinux-keyring."
125 echo " -r | --alter-remove Remove alterlinux-keyring."
126 echo " -c | --arch-add Add archlinux-keyring."
127 echo " -h | --help Show this help and exit."
128 echo " -l | --arch32-add Add archlinux32-keyring."
129 echo " -i | --arch32-remove Remove archlinux32-keyring."
134 # Check if the package is installed.
137 _pkg=$(echo "${1}" | cut -d'/' -f2)
139 if [[ ${#} -gt 2 ]]; then
140 msg_error "Multiple package specification is not available."
143 if [[ -n $( pacman -Q "${_pkg}" 2> /dev/null| awk '{print $1}' ) ]]; then
152 msg_info "Running ${*}"
158 if [[ ! ${UID} = 0 ]]; then
159 msg_error "You dont have root permission."
160 msg_error 'Please run as root.'
164 if [[ ! -f "${alter_pacman_conf_x86_64}" ]]; then
165 msg_error "${alter_pacman_conf_x86_64} does not exist."
169 if [[ ! -f "${alter_pacman_conf_i686}" ]]; then
170 msg_error "${alter_pacman_conf_i686} does not exist."
179 pacman-key --refresh-keys
181 pacman-key --populate archlinux
182 pacman -S --noconfirm core/archlinux-keyring
184 pacman-key --populate archlinux
190 curl -L -o "/tmp/fascode.pub" "https://山d.com/repo/fascode.pub"
191 pacman-key -a "/tmp/fascode.pub"
192 rm -f "/tmp/fascode.pub"
193 pacman-key --lsign-key development@fascode.net
195 pacman --config "${alter_pacman_conf_x86_64}" -Sy --noconfirm
196 pacman --config "${alter_pacman_conf_x86_64}" -S --noconfirm alter-stable/alterlinux-keyring
199 pacman-key --populate alterlinux
205 pacman-key -d BDC396346243AB57ACD090F9F50544048389DA36
206 if checkpkg alterlinux-keyring; then
207 pacman -Rsnc --noconfirm alterlinux-keyring
212 update_arch32_key() {
213 pacman -Sy --config "${alter_pacman_conf_i686}"
214 pacman --noconfirm -S --config "${alter_pacman_conf_i686}" alter-stable/archlinux32-keyring
216 pacman-key --populate archlinux32
217 #pacman-key --refresh-keys
220 remove_arch32_key() {
221 pacman -Rsnc archlinux32-keyring
226 while getopts 'archli-:' arg; do
250 run update_arch32_key
255 run remove_arch32_key
276 run update_arch32_key
280 run remove_arch32_key
293 if [[ ${#} = 0 ]]; then
295 # run update_arch_key
297 # run update_arch32_key