Skip to content

Commit ff2f2aa

Browse files
committed
fix(ci): fix rclone docker build and update checksums (#162)
* fix(ci): resolve conflicts and complete lib to public migration - Adopt latest changes from main - Update rclone action to v1.1.1 - Complete migration of lib/ to public/ - Update README and workflow triggers * fix(ci): complete lib→public migration; update installer scripts and tests - Update sync-init.sh with explicit --local/--remote/--checksum-url args - Update check-linux.yml to pass explicit args to sync-init.sh - Improve install.sh and install_zpmod.sh with better error handling - Update checksums after public/ path changes - Expand tests/installers.sh coverage * chore(meta): secure workflows and unify agent instructions --------- Co-authored-by: ss-o <ss-o@users.noreply.github.com> 31b10db
1 parent 93b6f66 commit ff2f2aa

7 files changed

Lines changed: 184 additions & 69 deletions

File tree

CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

checksum.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
5d8fdd881b84548f38c1d5ffc6d5f46a18919d8dd6c1398d69abe055dd76ef98 lib/sh/install_zpmod.sh
2-
eb744a0aa3d03c4c2a6c9cfb5b9088389ce4bc9027d272dfd0b52dbb7b04e348 lib/sh/install.sh
3-
83d9f0dc013376b5aa03b7a11f3908058da176df3407ac6e2872857d7c9658fd lib/sh/sync-init.sh
4-
66dc5bb0575d44e4e1192e229204abe1ac47979a05ee3c3bb23afc2b9b493637 lib/zsh/init.zsh
1+
348b78e992d28ecebd23940d06944629ef7f8f9d93c17ef3469cd6eebd288451 public/sh/install_zpmod.sh
2+
7408a1045f330a6e73bda55c6c7b48be7873a4e7f1fb00d7db989827cc9224a9 public/sh/install.sh
3+
f8519bf7e3e42ad67cc9cff6d82a8367641611fc687b2f6793e26bd55dbbb553 public/sh/sync-init.sh
4+
98f54a779985719e390b3e4559b7b0ac22101caac91d0569d41cd9229a05c6de public/zsh/init.zsh

sh/install.sh

Lines changed: 107 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,80 @@ while getopts ":i:a:b:" opt; do
3636
done
3737
shift $((OPTIND - 1))
3838

39+
SCRIPT_DIR=""
40+
LOCAL_INIT_ZSH=""
41+
LOCAL_INSTALL_ZPMOD=""
42+
case "$0" in
43+
*/?*)
44+
SCRIPT_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)" || SCRIPT_DIR=""
45+
;;
46+
*) ;;
47+
esac
48+
49+
if [ -n "${SCRIPT_DIR}" ]; then
50+
if [ -f "${SCRIPT_DIR}/../zsh/init.zsh" ]; then
51+
LOCAL_INIT_ZSH="${SCRIPT_DIR}/../zsh/init.zsh"
52+
fi
53+
if [ -f "${SCRIPT_DIR}/install_zpmod.sh" ]; then
54+
LOCAL_INSTALL_ZPMOD="${SCRIPT_DIR}/install_zpmod.sh"
55+
fi
56+
fi
57+
58+
fetch_to_file() {
59+
_dest="$1"
60+
shift
61+
_has_fetcher=0
62+
63+
for _src; do
64+
[ -n "${_src}" ] || continue
65+
case "${_src}" in
66+
http://* | https://*)
67+
if command -v curl >/dev/null 2>&1; then
68+
_has_fetcher=1
69+
if command curl -fsSL "${_src}" -o "${_dest}" 2>/dev/null; then
70+
return 0
71+
fi
72+
elif command -v wget >/dev/null 2>&1; then
73+
_has_fetcher=1
74+
if command wget -qO "${_dest}" "${_src}" 2>/dev/null; then
75+
return 0
76+
fi
77+
fi
78+
;;
79+
*)
80+
if [ -r "${_src}" ]; then
81+
command cp "${_src}" "${_dest}"
82+
return 0
83+
fi
84+
;;
85+
esac
86+
done
87+
88+
if [ "${_has_fetcher}" -eq 0 ]; then
89+
printf '%s\n' "-- ERROR -- curl or wget is required to download installer assets" >&2
90+
fi
91+
return 1
92+
}
93+
3994
if [ "${AOPT}" = loader ]; then
4095
ZI_CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/zi"
96+
loader_tmp="${WORKDIR}/init.zsh.tmp"
4197
command mkdir -p "${ZI_CONFIG_DIR}"
42-
if command -v curl >/dev/null 2>&1; then
43-
command curl -fsSL https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/init.zsh -o "${ZI_CONFIG_DIR}/init.zsh"
44-
elif command -v wget >/dev/null 2>&1; then
45-
command wget -qO "${ZI_CONFIG_DIR}/init.zsh" https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/init.zsh
98+
set +e
99+
fetch_to_file "${ZI_CONFIG_DIR}/init.zsh" \
100+
"${LOCAL_INIT_ZSH}" \
101+
"https://raw.githubusercontent.com/z-shell/src/main/public/zsh/init.zsh" \
102+
"https://raw.githubusercontent.com/z-shell/src/main/lib/zsh/init.zsh"
103+
fetch_status=$?
104+
set -e
105+
if [ "${fetch_status}" -ne 0 ]; then
106+
printf '%s\n' "-- ERROR -- failed to retrieve init.zsh" >&2
107+
exit 1
46108
fi
47-
command chmod go-w "${ZI_CONFIG_DIR}" && command chmod a+x "${ZI_CONFIG_DIR}/init.zsh"
48109
# shellcheck disable=SC2016
49-
command sed -i 's|: ${ZI\[STREAM\]:="main"}|: ${ZI[STREAM]:="'"${BOPT}"'"}|' "${ZI_CONFIG_DIR}/init.zsh"
110+
command sed 's|: ${ZI\[STREAM\]:="main"}|: ${ZI[STREAM]:="'"${BOPT}"'"}|' "${ZI_CONFIG_DIR}/init.zsh" >"${loader_tmp}" &&
111+
command mv "${loader_tmp}" "${ZI_CONFIG_DIR}/init.zsh"
112+
command chmod go-w "${ZI_CONFIG_DIR}" && command chmod a+x "${ZI_CONFIG_DIR}/init.zsh"
50113
fi
51114

52115
if [ -z "${ZI_HOME-}" ]; then
@@ -58,7 +121,7 @@ if [ -z "${ZI_BIN_DIR_NAME-}" ]; then
58121
fi
59122

60123
if ! test -d "${ZI_HOME}"; then
61-
command mkdir "${ZI_HOME}"
124+
command mkdir -p "${ZI_HOME}"
62125
command chmod go-w "${ZI_HOME}"
63126
fi
64127

@@ -68,17 +131,20 @@ if ! command -v git >/dev/null 2>&1; then
68131
fi
69132

70133
# Get the download-progress bar tool
71-
if command -v curl >/dev/null 2>&1; then
72-
command mkdir -p /tmp/zi
73-
cd /tmp/zi || exit 1
74-
command curl -fsSLO https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh &&
75-
command chmod a+x /tmp/zi/git-process-output.zsh
76-
elif command -v wget >/dev/null 2>&1; then
77-
command mkdir -p /tmp/zi
78-
cd /tmp/zi || exit 1
79-
command wget -q https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh &&
80-
command chmod a+x /tmp/zi/git-process-output.zsh
134+
command mkdir -p /tmp/zi
135+
cd /tmp/zi || exit 1
136+
set +e
137+
fetch_to_file /tmp/zi/git-process-output.zsh \
138+
"" \
139+
"https://raw.githubusercontent.com/z-shell/zi/main/public/zsh/git-process-output.zsh" \
140+
"https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh"
141+
fetch_status=$?
142+
set -e
143+
if [ "${fetch_status}" -ne 0 ]; then
144+
printf '%s\n' "-- ERROR -- failed to retrieve git-process-output.zsh" >&2
145+
exit 1
81146
fi
147+
command chmod a+x /tmp/zi/git-process-output.zsh
82148

83149
if test -d "${ZI_HOME}/${ZI_BIN_DIR_NAME}/.git"; then
84150
cd "${ZI_HOME}/${ZI_BIN_DIR_NAME}" || exit 1
@@ -168,36 +234,28 @@ EOF
168234

169235
ZPMOD_PROFILE() {
170236
_zpmod_sh=""
171-
case "$0" in
172-
*/*)
173-
_script_dir="$(cd "$(dirname "$0")" 2>/dev/null && pwd)" || _script_dir=""
174-
;;
175-
*)
176-
_script_dir=""
177-
;;
178-
esac
179-
180-
if [ -n "${_script_dir}" ] && [ -f "${_script_dir}/install_zpmod.sh" ]; then
181-
_zpmod_sh="${_script_dir}/install_zpmod.sh"
237+
if [ -n "${LOCAL_INSTALL_ZPMOD}" ]; then
238+
_zpmod_sh="${LOCAL_INSTALL_ZPMOD}"
182239
else
183240
_zpmod_sh="${WORKDIR}/install_zpmod.sh"
184-
_zpmod_url="https://raw.githubusercontent.com/z-shell/zi-src/main/lib/sh/install_zpmod.sh"
185-
if command -v curl >/dev/null 2>&1; then
186-
command curl -fsSL "${_zpmod_url}" -o "${_zpmod_sh}"
187-
elif command -v wget >/dev/null 2>&1; then
188-
command wget -qO "${_zpmod_sh}" "${_zpmod_url}"
189-
else
190-
printf '%s\n' "-- ERROR -- curl or wget is required to download install_zpmod.sh" >&2
191-
exit 1
192-
fi
193-
if [ ! -s "${_zpmod_sh}" ]; then
241+
set +e
242+
fetch_to_file "${_zpmod_sh}" \
243+
"" \
244+
"https://raw.githubusercontent.com/z-shell/src/main/public/sh/install_zpmod.sh" \
245+
"https://raw.githubusercontent.com/z-shell/src/main/lib/sh/install_zpmod.sh"
246+
fetch_status=$?
247+
set -e
248+
if [ "${fetch_status}" -ne 0 ]; then
194249
printf '%s\n' "-- ERROR -- failed to download install_zpmod.sh" >&2
195250
exit 1
196251
fi
197252
command chmod a+x "${_zpmod_sh}"
198253
fi
199254

200-
exec sh "${_zpmod_sh}" "$@"
255+
if [ "$#" -gt 0 ]; then
256+
exec sh "${_zpmod_sh}" "$@"
257+
fi
258+
exec sh "${_zpmod_sh}"
201259
}
202260

203261
CLOSE_PROFILE() {
@@ -211,7 +269,11 @@ CLOSE_PROFILE() {
211269

212270
MAIN() {
213271
if [ "${AOPT}" = zpmod ]; then
214-
ZPMOD_PROFILE "$@"
272+
if [ "$#" -gt 0 ]; then
273+
ZPMOD_PROFILE "$@"
274+
else
275+
ZPMOD_PROFILE
276+
fi
215277
else
216278
MAIN_PROFILE
217279
ANNEX_PROFILE
@@ -227,4 +289,8 @@ EOF
227289
exit 0
228290
}
229291

230-
MAIN "${@}"
292+
if [ "$#" -gt 0 ]; then
293+
MAIN "$@"
294+
else
295+
MAIN
296+
fi

sh/install_zpmod.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,20 @@ MAIN() {
124124
col_info2=""
125125
col_rst=""
126126

127-
setup_environment "$@"
128-
setup_zpmod_repository "$@"
129-
build_zpmod_module "$@"
127+
if [ "$#" -gt 0 ]; then
128+
setup_environment "$@"
129+
setup_zpmod_repository "$@"
130+
build_zpmod_module "$@"
131+
else
132+
setup_environment
133+
setup_zpmod_repository
134+
build_zpmod_module
135+
fi
130136
exit 0
131137
}
132138

133-
MAIN "${@}"
139+
if [ "$#" -gt 0 ]; then
140+
MAIN "$@"
141+
else
142+
MAIN
143+
fi

sh/sync-init.sh

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
33
# vim: ft=sh sw=2 ts=2 et
44
#
5-
# sync-init.sh — verify and optionally sync local lib/zsh/init.zsh with remote.
5+
# sync-init.sh — verify and optionally sync local public/zsh/init.zsh with remote.
66
#
77
# Usage:
8-
# sh lib/sh/sync-init.sh [OPTIONS]
8+
# sh public/sh/sync-init.sh [OPTIONS]
99
#
1010
# Options:
1111
# --write Replace local file with remote copy (requires valid checksum)
12-
# --local PATH Local file to compare (default: lib/zsh/init.zsh)
12+
# --local PATH Local file to compare (default: public/zsh/init.zsh)
1313
# --remote URL|PATH Remote URL or local path (default: GitHub raw main)
1414
# --checksum-url URL|PATH Checksum.txt URL or path (default: GitHub raw main)
1515
# --no-checksum Skip checksum validation of remote content
@@ -28,10 +28,10 @@ trap 'rm -rf "${WORKDIR:?}"' EXIT INT TERM
2828
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
2929
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
3030

31-
DEFAULT_LOCAL="${REPO_ROOT}/lib/zsh/init.zsh"
32-
DEFAULT_REMOTE="https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/init.zsh"
33-
DEFAULT_CHECKSUM_URL="https://raw.githubusercontent.com/z-shell/zi-src/main/lib/checksum.txt"
34-
CHECKSUM_KEY="lib/zsh/init.zsh"
31+
DEFAULT_LOCAL="${REPO_ROOT}/public/zsh/init.zsh"
32+
DEFAULT_REMOTE="https://raw.githubusercontent.com/z-shell/src/main/public/zsh/init.zsh"
33+
DEFAULT_CHECKSUM_URL="https://raw.githubusercontent.com/z-shell/src/main/public/checksum.txt"
34+
CHECKSUM_KEY="public/zsh/init.zsh"
3535

3636
OPT_LOCAL="${DEFAULT_LOCAL}"
3737
OPT_REMOTE="${DEFAULT_REMOTE}"
@@ -43,14 +43,14 @@ OPT_NO_CHECKSUM=0
4343

4444
print_help() {
4545
cat <<EOF
46-
Usage: sh lib/sh/sync-init.sh [OPTIONS]
46+
Usage: sh public/sh/sync-init.sh [OPTIONS]
4747
48-
Verify local lib/zsh/init.zsh against the canonical GitHub raw main copy.
48+
Verify local public/zsh/init.zsh against the canonical GitHub raw main copy.
4949
By default, reports mismatches only. Use --write to update the local file.
5050
5151
Options:
5252
--write Replace local file with remote (requires valid checksum)
53-
--local PATH Local file to compare [default: lib/zsh/init.zsh]
53+
--local PATH Local file to compare [default: public/zsh/init.zsh]
5454
--remote URL|PATH Remote URL or local path [default: GitHub raw main]
5555
--checksum-url URL|PATH Checksum URL or path [default: GitHub raw main checksum.txt]
5656
--no-checksum Skip checksum validation of remote content
@@ -63,19 +63,59 @@ Exit codes:
6363
EOF
6464
}
6565

66+
_fetch_url() {
67+
_url="$1"
68+
if command -v curl >/dev/null 2>&1; then
69+
command curl -fsSL "${_url}"
70+
elif command -v wget >/dev/null 2>&1; then
71+
command wget -qO- "${_url}"
72+
else
73+
printf '%s\n' "[1;31m▓▒░[0m No curl or wget available." >&2
74+
return 1
75+
fi
76+
}
77+
78+
_legacy_url() {
79+
_url="$1"
80+
case "${_url}" in
81+
https://raw.githubusercontent.com/z-shell/src/main/public/*)
82+
printf '%s\n' "https://raw.githubusercontent.com/z-shell/src/main/lib/${_url#https://raw.githubusercontent.com/z-shell/src/main/public/}"
83+
;;
84+
*)
85+
return 1
86+
;;
87+
esac
88+
}
89+
6690
# Fetch a URL or copy a local readable path to stdout.
6791
_fetch() {
6892
_src="$1"
93+
_legacy_src=""
94+
_fetch_status=0
6995
case "${_src}" in
7096
http://* | https://*)
71-
if command -v curl >/dev/null 2>&1; then
72-
command curl -fsSL "${_src}"
73-
elif command -v wget >/dev/null 2>&1; then
74-
command wget -qO- "${_src}"
75-
else
76-
printf '%s\n' "[1;31m▓▒░[0m No curl or wget available." >&2
77-
return 1
97+
set +e
98+
_fetch_url "${_src}"
99+
_fetch_status=$?
100+
set -e
101+
if [ "${_fetch_status}" -eq 0 ]; then
102+
return 0
78103
fi
104+
set +e
105+
_legacy_src="$(_legacy_url "${_src}" 2>/dev/null)"
106+
_legacy_status=$?
107+
set -e
108+
if [ "${_legacy_status}" -eq 0 ] && [ -n "${_legacy_src}" ]; then
109+
set +e
110+
_fetch_url "${_legacy_src}"
111+
_fetch_status=$?
112+
set -e
113+
if [ "${_fetch_status}" -eq 0 ]; then
114+
return 0
115+
fi
116+
fi
117+
printf '%s\n' "[1;31m▓▒░[0m Failed to fetch: ${_src}" >&2
118+
return 1
79119
;;
80120
*)
81121
if [ -r "${_src}" ]; then

zsh/init.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _zi_setup() {
5757
[[ -d "$tmp_dir" ]] || command mkdir -p "$tmp_dir"
5858

5959
show_process="${tmp_dir}/git-process.zsh"
60-
process_url="https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh"
60+
process_url="https://raw.githubusercontent.com/z-shell/zi/main/public/zsh/git-process-output.zsh"
6161

6262
if [[ ! -f "$show_process" ]]; then
6363
if _zi_fetch "$process_url" > "${tmp_dir}/git-process.zsh"; then

zsh/snippets/welcome.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
+zi-message "{auto}\`Welcome to Zi :)\`"
22
sleep 1
33
+zi-message "{hi}I am the snippet\!"
4-
zi delete https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/snippets/welcome.zsh
4+
zi delete https://raw.githubusercontent.com/z-shell/src/main/public/zsh/snippets/welcome.zsh

0 commit comments

Comments
 (0)