diff options
author | davidovski <david@davidovski.xyz> | 2022-02-20 02:45:55 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-02-20 02:45:55 +0000 |
commit | 8f02115e50573be0a5c6653f2a4a2bb6d7459911 (patch) | |
tree | c1c8fb3335bf9f940abd6aae8b2713e4443319db /src | |
parent | e5bc87ffc368799685b9c9bf0e01db35ee974540 (diff) |
added file lookup
Diffstat (limited to 'src')
-rwxr-xr-x | src/get.sh | 31 | ||||
-rw-r--r-- | src/install.sh | 8 | ||||
-rw-r--r-- | src/query.sh | 18 | ||||
-rw-r--r-- | src/remove.sh | 8 | ||||
-rwxr-xr-x | src/xi.sh | 10 |
5 files changed, 59 insertions, 16 deletions
@@ -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 +} @@ -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 $@ |