From 8f02115e50573be0a5c6653f2a4a2bb6d7459911 Mon Sep 17 00:00:00 2001 From: davidovski Date: Sun, 20 Feb 2022 02:45:55 +0000 Subject: added file lookup --- src/get.sh | 31 ++++++++++++++++--------------- src/install.sh | 8 ++++++++ src/query.sh | 18 ++++++++++++++++++ src/remove.sh | 8 ++++++++ src/xi.sh | 10 +++++++++- 5 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 src/remove.sh (limited to 'src') diff --git a/src/get.sh b/src/get.sh index a6821a1..3e23f78 100755 --- a/src/get.sh +++ b/src/get.sh @@ -78,7 +78,7 @@ download_packages () { local output="${out_dir}/${checksum}.${package}.xipkg" local output_info="${output}.info" - if validate_checksum $output $checksum; then + if ${UNSAFE} || validate_checksum $output $checksum; then ${VERBOSE} && printf "${LIGHT_BLACK}skipping download for %s already exists with checksum %s${RESET}\n" $package $checksum else ${VERBOSE} && printf "${LIGHT_BLACK}downloading $package from $url\n" $package $checksum @@ -94,22 +94,23 @@ download_packages () { wait_for_download $total_download ${outputs} echo - local i=0 - set -- $outputs - for pkg_file in ${outputs}; do + if ! ${UNSAFE}; then + local i=0 + set -- $outputs + for pkg_file in ${outputs}; do - ${QUIET} || hbar -T "${LARGE_CIRCLE} validating downloads..." $i $# - - info_file="${pkg_file}.info" - if ! validate_sig $pkg_file $info_file; then - printf "${RED}Failed to verify signature for ${LIGHT_RED}%s${RED}\n" $(basename -s .xipkg $pkg_file) - mv "$pkg_file" "${pkg_file}.invalid" - else - i=$((i+1)) - fi - done - ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} validated downloads" $i $# + ${QUIET} || hbar -T "${LARGE_CIRCLE} validating downloads..." $i $# + info_file="${pkg_file}.info" + if ! validate_sig $pkg_file $info_file; then + printf "${RED}Failed to verify signature for ${LIGHT_RED}%s${RED}\n" $(basename -s .xipkg $pkg_file) + mv "$pkg_file" "${pkg_file}.invalid" + else + i=$((i+1)) + fi + done + ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} validated downloads" $i $# + fi install $@ } diff --git a/src/install.sh b/src/install.sh index 432af27..6c02fab 100644 --- a/src/install.sh +++ b/src/install.sh @@ -15,10 +15,18 @@ install_package () { local checksum="$installed_dir/checksum" mkdir -p "$installed_dir" + [ -f $files ] && mv $files $files.old extract $1 > $files cp $info_file $info md5sum $pkg_file | cut -d' ' -f1 > $checksum + + if [ -f "$files.old" ]; then + for file in $(diff $files $files.old | grep ^\> | cut -d' ' -f2); do + rm -f ${SYSROOT}$file + done + rm $files.old + fi } get_package_filecount() { diff --git a/src/query.sh b/src/query.sh index 7e66b7c..0697005 100644 --- a/src/query.sh +++ b/src/query.sh @@ -3,3 +3,21 @@ search () { find ${PACKAGES_DIR} -type f | sed "s,${PACKAGES_DIR}/,," | grep$(echo $@ | sed "s/ /\\|/g") } + +files () { + for package in $@; do + local file="${INSTALLED_DIR}/$package/files" + [ -f $file ] && cat $file || >&2 printf "${RED}Package ${LIGHT_RED}$package${RED} is not installed" + done +} + +file () { + for file in $@; do + [ ! -f ${SYSROOT}$file ] && file=$(realpath $file) + for list in ${INSTALLED_DIR}/*/files; do + package=$(dirname $list | xargs basename) + grep -q $file $list && + printf "${LIGHT_BLUE}%s${BLUE} belongs to ${LIGHT_BLUE}%s${RESET}\n" $file $package + done + done +} diff --git a/src/remove.sh b/src/remove.sh new file mode 100644 index 0000000..727bcec --- /dev/null +++ b/src/remove.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +remove () { + + # TODO ask to remove package + # TODO calculate broken dependencies + # TODO +} diff --git a/src/xi.sh b/src/xi.sh index 0311a56..afff70f 100755 --- a/src/xi.sh +++ b/src/xi.sh @@ -14,7 +14,7 @@ export NOCONFIRM=false while getopts ":r:c:qnluyv" opt; do case "${opt}" in r) - SYSROOT="${OPTARG}" + SYSROOT=$(realpath ${OPTARG}) ;; c) CONF_FILE="${OPTARG}" @@ -66,6 +66,14 @@ else shift search $@ ;; + "files") + shift + files $@ + ;; + "file") + shift + file $@ + ;; *) $DO_SYNC && sync fetch $@ -- cgit v1.2.1