diff options
author | davidovski <david@davidovski.xyz> | 2022-03-20 10:46:08 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-03-20 10:46:08 +0000 |
commit | 4103bae6d29b50d2dabb7af7be7676b705944da2 (patch) | |
tree | 863cc298e969bb8259ee3a403f7a9b2ef5d2dec1 /src | |
parent | eac3c122678d19e090742d01e348d800d358733a (diff) |
added file validation
Diffstat (limited to 'src')
-rwxr-xr-x | src/get.sh | 25 | ||||
-rw-r--r-- | src/validate.sh | 17 | ||||
-rwxr-xr-x | src/xi.sh | 12 |
3 files changed, 41 insertions, 13 deletions
@@ -165,38 +165,39 @@ get () { total_download=$((total_download+size)) done - # TODO tidy this ${QUIET} || { [ "${missing}" ] && - printf "${LIGHT_RED}The following packages could not be located:${RED} %s\n${RESET}" $missing + printf "${LIGHT_RED}The following packages could not be located:${RED} $missing\n${RESET}" [ "${update}" ] && - printf "${LIGHT_GREEN}The following packages will be updated:\n\t${GREEN}%s\n${RESET}" $update + printf "${LIGHT_GREEN}The following packages will be updated:\n\t${GREEN}$update\n${RESET}" [ "${install}" ] && - printf "${LIGHT_BLUE}The following packages will be installed:\n\t${BLUE}%s\n${RESET}" $install + printf "${LIGHT_BLUE}The following packages will be installed:\n\t${BLUE}$install\n${RESET}" [ ! "${install}" ] && [ ! "${update}" ] && [ "${already}" ] && - printf "${LIGHT_WHITE}The following packages are already up to date:\n\t${WHITE}%s\n${RESET}" $already + printf "${LIGHT_WHITE}The following packages are already up to date:\n\t${WHITE}$already\n${RESET}" } - [ ! "${#install}" = "0" ] && [ "${#update}" = 0 ] && printf "${LIGHT_RED}Nothing to do!\n" && return 0 + [ "${#install}" = "0" ] && [ "${#update}" = 0 ] && { + printf "${LIGHT_RED}Nothing to do!\n" + return 0 + } ${QUIET} || { [ "${SYSROOT}" = "/" ] || printf "${WHITE}To install to ${LIGHT_WHITE}${SYSROOT}${RESET}\n" printf "${WHITE}Total download size:${LIGHT_WHITE} $(format_bytes $total_download)\n" } - if prompt_question "${WHITE}Continue?"; then - download_packages $total_download ${install} ${update} - else + prompt_question "${WHITE}Continue?" && + download_packages $total_download ${install} ${update} || { ${QUIET} || printf "${RED}Action canceled by user\n" - fi + } } fetch () { - local packages=$@ \ - outputs="" + local packages=$@ + local outputs="" local total_download=0 for package in $packages; do diff --git a/src/validate.sh b/src/validate.sh index 42530bb..0c9dd2d 100644 --- a/src/validate.sh +++ b/src/validate.sh @@ -56,3 +56,20 @@ keyimport () { esac set +o noglob } + +validate_files () { + local package=$1 + local ret=0 + + # TODO ensure that all checksums are the same + for file in $(files $package); do + if [ -f "${SYSROOT}$file" ]; then + ${VERBOSE} && printf "${GREEN}%s is present\n" $file + else + ret=$((ret+1)) + ${QUIET} || printf "${RED}%s is missing\n" $file + fi + done + ${QUIET} || printf "${RESET}" + return $ret +} @@ -47,8 +47,10 @@ Available Commands: search the database for a package files [package] list files belonging to a package + verify [package] + verify that a package's files are intact list - list available packagesa + list available packages list-installed lists installed packages file [path] @@ -176,6 +178,14 @@ else shift file_info $@ ;; + "verify") + shift + [ -z "$*" ] && set -- $(ls ${INSTALLED_DIR}) + while [ ! -z "$*" ]; do + validate_files $1 || printf "${LIGHT_RED}Failed to verify $1\n" + shift + done + ;; "bootstrap") shift . ${LIBDIR}/bootstrap.sh |