summaryrefslogtreecommitdiffstats
path: root/src/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/install.sh')
-rw-r--r--src/install.sh95
1 files changed, 69 insertions, 26 deletions
diff --git a/src/install.sh b/src/install.sh
index 27b2a33..8447dcc 100644
--- a/src/install.sh
+++ b/src/install.sh
@@ -19,7 +19,7 @@
# <http://www.gnu.org/licenses/>.
install_deps=
-install_fnames=
+install_urls=
install_md5sums=
install_sha256sums=
install_feed_url=
@@ -45,8 +45,8 @@ install_system()
if ! profile_validate_archplat "${mirror}" "${arch}" "${plat}" \
"${suite}"; then
- error 2 "$(get_msg 'install_bad_archplat')" \
- "${arch}" "${plat}"
+ error "$(get_msg 'install_bad_archplat')" "${arch}" "${plat}"
+ return 1
fi
info "$(get_msg 'install_selected_arch')" "${arch}"
@@ -55,16 +55,23 @@ install_system()
info "$(get_msg 'install_setting_up_chroot')"
if [ -d "${root}" ] && ! dir_is_empty "${root}" 'lost+found'; then
- error 2 "$(get_msg 'install_chroot_dir_exists')" "${root}"
+ error "$(get_msg 'install_chroot_dir_exists')" "${root}"
+ return 1
fi
if ! mkdir -p "${root}/.prokit" "${root}/prokit"; then
- error 2 "$(get_msg 'install_mkdir_chroot_fail')" "${root}"
+ error "$(get_msg 'install_mkdir_chroot_fail')" "${root}"
+ return 1
fi
>"${root}/prokit/installing"
info "$(get_msg 'install_find_pkgs')"
- install_find_pkgs "${mirror}" "${suite}" "${arch}" "${plat}" "${root}"
- install_get_pkgs "${root}"
+ if ! install_find_pkgs "${mirror}" "${suite}" "${arch}" "${plat}" \
+ "${root}"; then
+ return 1
+ fi
+ if install_get_pkgs "${root}"; then
+ return 1
+ fi
info "$(get_msg 'install_configuring')"
if ! ${foreign}; then
@@ -74,6 +81,8 @@ install_system()
fi
rm "${root}/prokit/installing"
+
+ return 0
}
install_find_pkgs()
@@ -92,15 +101,19 @@ install_find_pkgs()
local pkgs=
mkdir -p "${root}/etc/opkg" "${root}/var/lib/opkg/lists"
- fopen "${root}/etc/opkg/opkg.conf" 'w'
+ if ! fopen "${root}/etc/opkg/opkg.conf" 'w'; then
+ return 1
+ fi
opkg_conf_fd=${FD}
install_deps=
- install_fnames=
+ install_urls=
install_md5sums=
install_sha256sums=
- fopen "${root}/.prokit/packages" 'w'
+ if ! fopen "${root}/.prokit/packages" 'w'; then
+ return 1
+ fi
pkgs_fd=${FD}
while read -r opt feed_idx feed; do
@@ -131,6 +144,8 @@ install_find_pkgs()
pkgs="$(resolve_deps "$(cat "${root}/.prokit/packages")" \
"${install_deps}" | xargs printf '%s\n' | sort -u)"
printf '%s\n' "${pkgs}" >"${root}/.prokit/packages"
+
+ return 0
}
install_deps_cb()
@@ -139,6 +154,8 @@ install_deps_cb()
local deps="${2}"
install_deps="${install_deps}${pkg}: ${deps}${LF}"
+
+ return 0
}
install_fname_cb()
@@ -146,8 +163,10 @@ install_fname_cb()
local pkg="${1}"
local fname="${2}"
- install_fnames="$(printf '%s\n%s %s/%s' "${install_fnames}" \
+ install_urls="$(printf '%s\n%s %s/%s' "${install_urls}" \
"${pkg}" "${install_feed_url}" "${fname}")"
+
+ return 0
}
install_md5sum_cb()
@@ -157,6 +176,8 @@ install_md5sum_cb()
install_md5sums="$(printf '%s\n%s %s' "${install_md5sums}" \
"${pkg}" "${md5sum}")"
+
+ return 0
}
install_sha256sum_cb()
@@ -166,16 +187,20 @@ install_sha256sum_cb()
install_sha256sums="$(printf '%s\n%s %s' \
"${install_sha256sums}" "${pkg}" "${sha256sum}")"
+
+ return 0
}
install_get_pkgs()
{
local root="${1}"
local status_fd=
+ local errors=
local pkg=
- local fname=
+ local url=
local md5sum=
local sha256sum=
+ local fname=
local file=
local control=
local field=
@@ -184,32 +209,44 @@ install_get_pkgs()
mkdir -p "${root}/var/cache/opkg/archives" "${root}/tmp/opkg" \
"${root}/var/lib/opkg/info"
- fopen "${root}/var/lib/opkg/status" 'w'
+ if ! fopen "${root}/var/lib/opkg/status" 'w'; then
+ return 1
+ fi
status_fd=${FD}
+ errors=false
+
for pkg in $(cat "${root}/.prokit/packages"); do
info "$(get_msg 'install_downloading_pkg')" "${pkg}"
- fname="$(printf '%s\n' "${install_fnames}" | \
+ url="$(printf '%s\n' "${install_urls}" | \
sed -n "s/^${pkg} //p")"
md5sum="$(printf '%s\n' "${install_md5sums}" | \
sed -n "s/^${pkg} //p")"
sha256sum="$(printf '%s\n' "${install_sha256sums}" | \
sed -n "s/^${pkg} //p")"
- ${WGET} -q -O "${root}/var/cache/opkg/archives/${fname##*/}" \
- "${fname}" || \
- error 2 "$(get_msg 'install_downloading_pkg_fail')"
- fname="var/cache/opkg/archives/${fname##*/}"
+ fname="var/cache/opkg/archives/${url##*/}"
+ if ! ${WGET} -q -O "${root}/${fname}" "${url}"; then
+ error "$(get_msg 'install_downloading_pkg_fail')"
+ errors=true
+ continue
+ fi
if [ "x${md5sum}" != 'x' ]; then
- printf '%s %s\n' \
- "${md5sum}" "${root}/${fname}" | \
- md5sum -c >/dev/null 2>&1 || \
- error 2 "$(get_msg 'install_checksum_fail')"
+ if ! printf '%s %s\n' \
+ "${md5sum}" "${root}/${fname}" | \
+ md5sum -c >/dev/null 2>&1; then
+ error "$(get_msg 'install_checksum_fail')"
+ errors=true
+ continue
+ fi
fi
if [ "x${sha256sum}" != 'x' ]; then
- printf '%s %s\n' \
- "${sha256sum}" "${root}/${fname}" | \
- ${SHA256SUM} -c >/dev/null 2>&1 || \
- error 2 "$(get_msg 'install_checksum_fail')"
+ if ! printf '%s %s\n' \
+ "${sha256sum}" "${root}/${fname}" | \
+ ${SHA256SUM} -c >/dev/null 2>&1; then
+ error "$(get_msg 'install_checksum_fail')"
+ errors=true
+ continue
+ fi
fi
info "$(get_msg 'install_unpacking_pkg')" "${pkg}"
@@ -262,4 +299,10 @@ install_get_pkgs()
rmdir "${root}/.prokit"
fclose ${status_fd}
+
+ if ! ${errors}; then
+ return 0
+ else
+ return 1
+ fi
}