summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/block.sh19
-rw-r--r--src/cmd.sh3
-rw-r--r--src/cmd/build.sh30
-rw-r--r--src/cmd/install.sh23
-rw-r--r--src/cmd/installer-pc.sh37
-rw-r--r--src/cmd/mkinitramfs.sh22
-rw-r--r--src/cmd/opkg.sh19
-rw-r--r--src/cmd/shell.sh18
-rw-r--r--src/fd.sh10
-rw-r--r--src/install.sh95
-rw-r--r--src/main.sh23
-rw-r--r--src/output.sh10
-rw-r--r--src/package.sh3
-rw-r--r--src/profile.sh6
-rw-r--r--src/session.sh11
-rw-r--r--src/vardata.sh12
16 files changed, 241 insertions, 100 deletions
diff --git a/src/block.sh b/src/block.sh
index f056305..ad94bde 100644
--- a/src/block.sh
+++ b/src/block.sh
@@ -31,7 +31,8 @@ check_block()
local dev="${1}"
if ! [ -b "${dev}" ]; then
- error 2 "$(get_msg 'block_device_invalid')" "${dev}"
+ error "$(get_msg 'block_device_invalid')" "${dev}"
+ return 1
fi
}
@@ -40,17 +41,21 @@ block_mount()
local dev="${1}"
local dir=
- check_block "${dev}"
+ if ! check_block "${dev}"; then
+ return 2
+ fi
rand
dir="$(get_vardata_dir 'mount')/block-$(printf '%010d' ${rand_x})"
if ! mkdir "${dir}"; then
- error 2 "$(get_msg 'block_mkdir_fail')" "${dir}"
+ error "$(get_msg 'block_mkdir_fail')" "${dir}"
+ return 1
fi
if ! mount "${dev}" "${dir}"; then
+ error "$(get_msg 'block_mount_fail')" "${dev}"
rmdir "${dir}"
- error 2 "$(get_msg 'block_mount_fail')" "${dev}"
+ return 1
fi
printf '%s' "${dir}"
@@ -75,11 +80,13 @@ block_umount()
done
if ${timed_out}; then
- error 2 "$(get_msg 'block_umount_fail')" "${dir}"
+ error "$(get_msg 'block_umount_fail')" "${dir}"
+ return 1
fi
if ! rmdir "${dir}"; then
- error 2 "$(get_msg 'block_rmdir_fail')" "${dir}"
+ error "$(get_msg 'block_rmdir_fail')" "${dir}"
+ return 1
fi
return 0
diff --git a/src/cmd.sh b/src/cmd.sh
index 82c5ce5..9afad7c 100644
--- a/src/cmd.sh
+++ b/src/cmd.sh
@@ -117,6 +117,7 @@ run_cmd()
running_cmd=''
running_cmd_clean=''
else
- error 1 "$(get_msg 'cmd_not_found')" "${cmd}"
+ error "$(get_msg 'cmd_not_found')" "${cmd}"
+ return 1
fi
}
diff --git a/src/cmd/build.sh b/src/cmd/build.sh
index dbfd910..1d0ad52 100644
--- a/src/cmd/build.sh
+++ b/src/cmd/build.sh
@@ -34,7 +34,7 @@ cmd_build_main()
if [ ${#} -lt 2 ]; then
print_cmd_usage 'build' >&2
- exit 1
+ return 1
fi
root="${1}"
@@ -43,7 +43,9 @@ cmd_build_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
cmd_build_root="${root}"
@@ -70,16 +72,28 @@ cmd_build_main()
cmd_build_pkg_dir="${arg}"
done
- profile_detect "${root}"
+ if ! profile_detect "${root}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
if ! [ -d "${cmd_build_pkg_dir}" ]; then
- error 2 "$(get_msg 'cmd_build_not_a_dir')" \
- "${cmd_build_pkg_dir}"
+ error "$(get_msg 'cmd_build_not_a_dir')" "${cmd_build_pkg_dir}"
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
+ if ! package_init "${cmd_build_pkg_dir}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
fi
- package_init "${cmd_build_pkg_dir}"
package_set_substvars "${arch}" "${plat}"
- session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false
+ if ! session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false
+ then
+ cmd_build_fini
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
cmd_build_build_deps="$(package_get_build_deps "${arch}" "${plat}")"
if [ "x${cmd_build_build_deps}" != 'x' ]; then
@@ -94,6 +108,8 @@ cmd_build_main()
session_end
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_build_make_deps_pkg()
diff --git a/src/cmd/install.sh b/src/cmd/install.sh
index ae26588..d32f488 100644
--- a/src/cmd/install.sh
+++ b/src/cmd/install.sh
@@ -30,13 +30,13 @@ cmd_install_main()
if ! get_options "${@}"; then
print_cmd_usage 'install' >&2
- exit 1
+ return 1
fi
shift $(($OPTIND - 1))
if [ ${#} -lt 2 ]; then
print_cmd_usage 'install' >&2
- exit 1
+ return 1
fi
# TODO: Consider making suite optional, getting a default suite from the
@@ -50,7 +50,9 @@ cmd_install_main()
else
profile='proteanos'
fi
- profile_set "${profile}"
+ if ! profile_set "${profile}"; then
+ return 2
+ fi
suite="$(profile_normalize_suite "${suite}")"
if [ "x${cmd_install_opt_F+set}" = 'xset' ]; then
@@ -62,14 +64,21 @@ cmd_install_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
- install_system "${cmd_install_opt_m-}" "${suite}" \
- "${cmd_install_opt_a-}" "${cmd_install_opt_p-}" \
- "${root}" "${foreign}"
+ if ! install_system "${cmd_install_opt_m-}" "${suite}" \
+ "${cmd_install_opt_a-}" "${cmd_install_opt_p-}" \
+ "${root}" "${foreign}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 1
+ fi
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_install_register()
diff --git a/src/cmd/installer-pc.sh b/src/cmd/installer-pc.sh
index f9fd509..348838e 100644
--- a/src/cmd/installer-pc.sh
+++ b/src/cmd/installer-pc.sh
@@ -33,26 +33,28 @@ cmd_installer_pc_main()
if ! get_options "${@}"; then
print_cmd_usage 'installer-pc' >&2
- exit 1
+ return 1
fi
shift $(($OPTIND - 1))
if [ "x${cmd_installer_pc_opt_a-}" = 'x' ]; then
print_cmd_usage 'installer-pc' >&2
- exit 1
+ return 1
fi
if [ "x${cmd_installer_pc_opt_p-}" = 'x' ]; then
print_cmd_usage 'installer-pc' >&2
- exit 1
+ return 1
fi
if [ ${#} -ne 2 ]; then
print_cmd_usage 'installer-pc' >&2
- exit 1
+ return 1
fi
suite="${1}"
dev="${2}"
- check_block "${dev}"
+ if ! check_block "${dev}"; then
+ return 2
+ fi
if [ "x${suite%%:*}" != "x${suite}" ]; then
profile="${suite%%:*}"
@@ -60,15 +62,23 @@ cmd_installer_pc_main()
else
profile='proteanos'
fi
- profile_set "${profile}"
+ if ! profile_set "${profile}"; then
+ return 2
+ fi
suite="$(profile_normalize_suite "${suite}")"
cmd_installer_pc_make_partition_and_fs "${dev}"
- root="$(block_mount "${dev}1")"
+ if ! root="$(block_mount "${dev}1")"; then
+ return 2
+ fi
- install_system "${cmd_installer_pc_opt_m-}" "${suite}" \
- "${cmd_installer_pc_opt_a-}" "${cmd_installer_pc_opt_p-}" \
- "${root}" false
+ if ! install_system "${cmd_installer_pc_opt_m-}" "${suite}" \
+ "${cmd_installer_pc_opt_a-}" \
+ "${cmd_installer_pc_opt_p-}" \
+ "${root}" false; then
+ block_umount "${root}"
+ return 1
+ fi
if [ -f "${root}/sbin/lilo" ]; then
read b4 b3 b2 b1 <<-EOF
@@ -76,13 +86,18 @@ cmd_installer_pc_main()
EOF
# This ln command won't be needed once lilo 24.1-1 is uploaded.
ln "${root}/boot/vmlinuz" "${root}/boot/vmlinuz.old"
- session_begin "${root}" . : false
+ if ! session_begin "${root}" . : false
+ block_umount "${root}"
+ return 2
+ fi
session_exec install-lilo \
"${dev}" "PARTUUID=${b1}${b2}${b3}${b4}-01"
session_end
fi
block_umount "${root}"
+
+ return 0
}
cmd_installer_pc_make_partition_and_fs()
diff --git a/src/cmd/mkinitramfs.sh b/src/cmd/mkinitramfs.sh
index 0ff0923..41e6327 100644
--- a/src/cmd/mkinitramfs.sh
+++ b/src/cmd/mkinitramfs.sh
@@ -29,21 +29,21 @@ cmd_mkinitramfs_main()
if ! get_options "${@}"; then
print_cmd_usage 'mkinitramfs' >&2
- exit 1
+ return 1
fi
shift $(($OPTIND - 1))
if [ "x${cmd_mkinitramfs_opt_l-}" = 'x' ]; then
print_cmd_usage 'mkinitramfs' >&2
- exit 1
+ return 1
fi
if [ "x${cmd_mkinitramfs_opt_i-}" = 'x' ]; then
print_cmd_usage 'mkinitramfs' >&2
- exit 1
+ return 1
fi
if [ ${#} -lt 1 ]; then
print_cmd_usage 'mkinitramfs' >&2
- exit 1
+ return 1
fi
linux_output="${cmd_mkinitramfs_opt_l}"
@@ -54,16 +54,22 @@ cmd_mkinitramfs_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
- profile_detect "${root}"
+ if ! profile_detect "${root}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
arch="$(cat "${root}/etc/proteanos_arch")"
plat="$(cat "${root}/etc/proteanos_plat")"
if ! img="$(profile_find_kernel "${root}" "${arch}" "${plat}")"; then
+ error "$(get_msg 'cmd_mkinitramfs_kernel_not_found')"
[ "x${dev}" != 'x' ] && block_umount "${root}"
- error 2 "$(get_msg 'cmd_mkinitramfs_kernel_not_found')"
+ return 2
fi
cp -p "${root}/${img}" "${linux_output}"
@@ -71,6 +77,8 @@ cmd_mkinitramfs_main()
>"${initramfs_output}"
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_mkinitramfs_register()
diff --git a/src/cmd/opkg.sh b/src/cmd/opkg.sh
index 5a48fb8..b99a977 100644
--- a/src/cmd/opkg.sh
+++ b/src/cmd/opkg.sh
@@ -31,7 +31,7 @@ cmd_opkg_main()
if [ ${#} -lt 1 ]; then
print_cmd_usage 'opkg' >&2
- exit 1
+ return 1
fi
root="${1}"
@@ -40,7 +40,9 @@ cmd_opkg_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
first_arg=true
@@ -78,9 +80,16 @@ cmd_opkg_main()
fi
done
- profile_detect "${root}"
+ if ! profile_detect "${root}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
- session_begin "${root}" . cmd_opkg_fini false
+ if ! session_begin "${root}" . cmd_opkg_fini false; then
+ cmd_opkg_fini
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
session_exec opkg "${@}"
@@ -88,6 +97,8 @@ cmd_opkg_main()
session_end
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_opkg_fini()
diff --git a/src/cmd/shell.sh b/src/cmd/shell.sh
index e761f55..8d5cd16 100644
--- a/src/cmd/shell.sh
+++ b/src/cmd/shell.sh
@@ -25,7 +25,7 @@ cmd_shell_main()
if [ ${#} -lt 1 ]; then
print_cmd_usage 'shell' >&2
- exit 1
+ return 1
fi
root="${1}"
@@ -34,12 +34,20 @@ cmd_shell_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
- profile_detect "${root}"
+ if ! profile_detect "${root}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
- session_begin "${root}" . : false
+ if ! session_begin "${root}" . : false; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
if [ ${#} -eq 0 ]; then
session_exec /bin/sh
printf '\n'
@@ -50,6 +58,8 @@ cmd_shell_main()
session_end
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_shell_register()
diff --git a/src/fd.sh b/src/fd.sh
index 0d5a50e..c52efec 100644
--- a/src/fd.sh
+++ b/src/fd.sh
@@ -63,8 +63,8 @@ fopen()
i=$(($i + 1))
done
if [ "x${fd:+set}" != 'xset' ]; then
- error 2 "$(get_msg 'emfile')"
- return
+ error "$(get_msg 'emfile')"
+ return 1
fi
if eval "exec ${fd}${mode}'${path}'"; then
@@ -72,7 +72,8 @@ fopen()
FD="${fd}"
return 0
else
- error 2 "$(get_msg 'cant_fopen')"
+ error "$(get_msg 'cant_fopen')"
+ return 1
fi
}
@@ -82,7 +83,8 @@ fclose()
# Make sure the file descriptor is open.
if [ "x$(eval echo "\${_fd_${fd}+set}")" != 'xset' ]; then
- error 2 "$(get_msg 'ebadf')"
+ error "$(get_msg 'ebadf')"
+ return 1
fi
eval "exec ${fd}>&-"
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
}
diff --git a/src/main.sh b/src/main.sh
index dae02d0..51b21ac 100644
--- a/src/main.sh
+++ b/src/main.sh
@@ -40,12 +40,13 @@ fi
main()
{
local cmd=
+ local es=
load_locale
if ! get_options "${@}"; then
cmd_help_main >&2
- exit 1
+ return 1
fi
shift $(($OPTIND - 1))
@@ -55,24 +56,34 @@ main()
cmd='version'
elif [ ${#} -lt 1 ]; then
cmd_help_main >&2
- exit 1
+ return 1
else
cmd="${1}"
shift
fi
srand $(expr ${$} + $(date '+%s'))
- init_vardata
+ if ! init_vardata; then
+ return 2
+ fi
case "${cmd}" in
'help'|'version') ;;
- *) check_uid || error 1 "$(get_msg 'uid_0_req')";;
+ *)
+ if ! check_uid; then
+ error "$(get_msg 'uid_0_req')"
+ return 1
+ fi
+ ;;
esac
run_cmd "${cmd}" "${@}"
+ es=${?}
- fini_vardata
+ if ! fini_vardata; then
+ return 2
+ fi
- return ${?}
+ return ${es}
}
check_uid()
diff --git a/src/output.sh b/src/output.sh
index 62d2095..1677fb5 100644
--- a/src/output.sh
+++ b/src/output.sh
@@ -20,17 +20,13 @@
error()
{
- local status=${1}
- local fmt="${2}"
- shift 2
+ local fmt="${1}"
+ shift 1
printf '%s: Error: ' "${0##*/}" >&2
printf "${fmt}\n" "${@}" >&2
- # In a subshell, this will have no effect, so the shell's exit status
- # will be 128+SIGINT. Meh.
- exit_status=${status}
- kill -s INT ${$}
+ return 0
}
warn()
diff --git a/src/package.sh b/src/package.sh
index 95cdb0e..d591484 100644
--- a/src/package.sh
+++ b/src/package.sh
@@ -37,7 +37,8 @@ package_init()
fi
if [ "x${package_format}" = 'x' ]; then
- error 2 "$(get_msg 'package_format_unknown')"
+ error "$(get_msg 'package_format_unknown')"
+ return 1
fi
return 0
diff --git a/src/profile.sh b/src/profile.sh
index 44e3022..d5ffe1e 100644
--- a/src/profile.sh
+++ b/src/profile.sh
@@ -44,7 +44,8 @@ profile_set()
if is_profile "${prof}"; then
profile="${prof}"
else
- error 1 "$(get_msg 'profile_not_found')" "${prof}"
+ error "$(get_msg 'profile_not_found')" "${prof}"
+ return 1
fi
return 0
@@ -61,7 +62,8 @@ profile_detect()
fi
done
- error 1 "$(get_msg 'profile_not_detected')" "${root}"
+ error "$(get_msg 'profile_not_detected')" "${root}"
+ return 1
}
profile_normalize_suite()
diff --git a/src/session.sh b/src/session.sh
index 6453fae..0728080 100644
--- a/src/session.sh
+++ b/src/session.sh
@@ -43,13 +43,16 @@ session_begin()
[ -d "${session_root}/prokit" ] || mkdir "${session_root}/prokit"
if [ -f "${session_root}/prokit/installing" ] && ! ${installing}; then
- error 2 "$(get_msg 'install_running')"
+ error "$(get_msg 'install_running')"
+ return 1
fi
session_set_sigs
if ! mutex_timedlock "${session_root}/prokit/sessions.lock" 5; then
- error 2 "$(get_msg 'cant_lock_sessions')"
+ error "$(get_msg 'cant_lock_sessions')"
+ trap - ${session_sigs}
+ return 1
fi
# Check for a sessions pool.
@@ -95,7 +98,9 @@ session_end()
if ! mutex_is_unlockable "${session_root}/prokit/sessions.lock"; then
if ! mutex_timedlock "${session_root}/prokit/sessions.lock" 5
then
- error 2 "$(get_msg 'cant_lock_sessions')"
+ error "$(get_msg 'cant_lock_sessions')"
+ trap - ${session_sigs}
+ return 1
fi
fi
diff --git a/src/vardata.sh b/src/vardata.sh
index 05c9cff..6a7e749 100644
--- a/src/vardata.sh
+++ b/src/vardata.sh
@@ -36,12 +36,14 @@ init_vardata()
rand
vardatadir="${tmpdir}/${PACKAGE}-$(printf '%010d' ${rand_x})"
if ! mkdir "${vardatadir}"; then
- error 2 "$(get_msg 'temp_mkdir_fail')" "${vardatadir}"
+ error "$(get_msg 'temp_mkdir_fail')" "${vardatadir}"
+ return 1
fi
for dir in ${VARDATA_DIRS}; do
if ! mkdir "${vardatadir}/${dir}"; then
- error 2 "$(get_msg 'temp_mkdir_fail')" \
+ error "$(get_msg 'temp_mkdir_fail')" \
"${vardatadir}/${dir}"
+ return 1
fi
done
@@ -54,12 +56,14 @@ fini_vardata()
for dir in ${VARDATA_DIRS}; do
if ! rmdir "${vardatadir}/${dir}"; then
- error 2 "$(get_msg 'temp_rmdir_fail')" \
+ error "$(get_msg 'temp_rmdir_fail')" \
"${vardatadir}/${dir}"
+ return 1
fi
done
if ! rmdir "${vardatadir}"; then
- error 2 "$(get_msg 'temp_rmdir_fail')" "${vardatadir}"
+ error "$(get_msg 'temp_rmdir_fail')" "${vardatadir}"
+ return 1
fi
return 0