From 267fdd978daccfdf776047417498d9bd087c20be Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 25 Apr 2019 18:33:29 -0400 Subject: src/install.sh: Define functions before references --- (limited to 'src') diff --git a/src/install.sh b/src/install.sh index 74d8101..1d7eed6 100644 --- a/src/install.sh +++ b/src/install.sh @@ -24,68 +24,6 @@ install_md5sums= install_sha256sums= install_feed_url= -install_system() -{ - local mirror="${1}" - local suite="${2}" - local arch="${3}" - local plat="${4}" - local root="${5}" - local foreign="${6}" - shift 6 - - if [ "x${arch}" = 'x' ]; then - arch="$(profile_detect_arch)" - fi - if [ "x${plat}" = 'x' ]; then - plat="$(profile_default_plat)" - fi - if [ "x${mirror}" = 'x' ]; then - mirror="$(profile_select_mirror)" - fi - - if ! profile_validate_archplat "${mirror}" "${arch}" "${plat}" \ - "${suite}"; then - error "$(get_msg 'install_bad_archplat')" "${arch}" "${plat}" - return 1 - fi - - info "$(get_msg 'install_selected_arch')" "${arch}" - info "$(get_msg 'install_selected_plat')" "${plat}" - info "$(get_msg 'install_selected_mirror')" "${mirror}" - - info "$(get_msg 'install_setting_up_chroot')" - if [ -d "${root}" ] && ! dir_is_empty "${root}" 'lost+found'; then - error "$(get_msg 'install_chroot_dir_exists')" "${root}" - return 1 - fi - if ! mkdir -p "${root}/.prokit" "${root}/prokit"; then - error "$(get_msg 'install_mkdir_chroot_fail')" "${root}" - return 1 - fi - >"${root}/prokit/installing" - - info "$(get_msg 'install_find_pkgs')" - 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 - profile_configure_system_native "${root}" "${arch}" "${plat}" - else - profile_configure_system_foreign "${root}" "${arch}" "${plat}" - fi - - rm -f "${root}/prokit/installing" - - return 0 -} - _usign_fingerprint() { local key_data="${1}" @@ -108,6 +46,53 @@ _usign_fingerprint() fi } +install_deps_cb() +{ + local pkg="${1}" + local deps="${2}" + shift 2 + + install_deps="${install_deps}${pkg}: ${deps}${LF}" + + return 0 +} + +install_fname_cb() +{ + local pkg="${1}" + local fname="${2}" + shift 2 + + install_urls="$(printf '%s\n%s %s/%s' "${install_urls}" \ + "${pkg}" "${install_feed_url}" "${fname}")" + + return 0 +} + +install_md5sum_cb() +{ + local pkg="${1}" + local md5sum="${2}" + shift 2 + + install_md5sums="$(printf '%s\n%s %s' "${install_md5sums}" \ + "${pkg}" "${md5sum}")" + + return 0 +} + +install_sha256sum_cb() +{ + local pkg="${1}" + local sha256sum="${2}" + shift 2 + + install_sha256sums="$(printf '%s\n%s %s' \ + "${install_sha256sums}" "${pkg}" "${sha256sum}")" + + return 0 +} + install_find_pkgs() { local mirror="${1}" @@ -205,53 +190,6 @@ install_find_pkgs() return 0 } -install_deps_cb() -{ - local pkg="${1}" - local deps="${2}" - shift 2 - - install_deps="${install_deps}${pkg}: ${deps}${LF}" - - return 0 -} - -install_fname_cb() -{ - local pkg="${1}" - local fname="${2}" - shift 2 - - install_urls="$(printf '%s\n%s %s/%s' "${install_urls}" \ - "${pkg}" "${install_feed_url}" "${fname}")" - - return 0 -} - -install_md5sum_cb() -{ - local pkg="${1}" - local md5sum="${2}" - shift 2 - - install_md5sums="$(printf '%s\n%s %s' "${install_md5sums}" \ - "${pkg}" "${md5sum}")" - - return 0 -} - -install_sha256sum_cb() -{ - local pkg="${1}" - local sha256sum="${2}" - shift 2 - - install_sha256sums="$(printf '%s\n%s %s' \ - "${install_sha256sums}" "${pkg}" "${sha256sum}")" - - return 0 -} - install_get_pkgs() { local root="${1}" @@ -372,3 +310,65 @@ install_get_pkgs() return 1 fi } + +install_system() +{ + local mirror="${1}" + local suite="${2}" + local arch="${3}" + local plat="${4}" + local root="${5}" + local foreign="${6}" + shift 6 + + if [ "x${arch}" = 'x' ]; then + arch="$(profile_detect_arch)" + fi + if [ "x${plat}" = 'x' ]; then + plat="$(profile_default_plat)" + fi + if [ "x${mirror}" = 'x' ]; then + mirror="$(profile_select_mirror)" + fi + + if ! profile_validate_archplat "${mirror}" "${arch}" "${plat}" \ + "${suite}"; then + error "$(get_msg 'install_bad_archplat')" "${arch}" "${plat}" + return 1 + fi + + info "$(get_msg 'install_selected_arch')" "${arch}" + info "$(get_msg 'install_selected_plat')" "${plat}" + info "$(get_msg 'install_selected_mirror')" "${mirror}" + + info "$(get_msg 'install_setting_up_chroot')" + if [ -d "${root}" ] && ! dir_is_empty "${root}" 'lost+found'; then + error "$(get_msg 'install_chroot_dir_exists')" "${root}" + return 1 + fi + if ! mkdir -p "${root}/.prokit" "${root}/prokit"; then + error "$(get_msg 'install_mkdir_chroot_fail')" "${root}" + return 1 + fi + >"${root}/prokit/installing" + + info "$(get_msg 'install_find_pkgs')" + 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 + profile_configure_system_native "${root}" "${arch}" "${plat}" + else + profile_configure_system_foreign "${root}" "${arch}" "${plat}" + fi + + rm -f "${root}/prokit/installing" + + return 0 +} -- cgit v0.9.1