From 10a35e3250db3c413e7292fa4d8090a0e61dc5b8 Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 31 May 2022 11:41:23 +0100 Subject: removed idea of repos --- src/query.sh | 10 ++++++++- src/sync.sh | 72 +++++++++++++++++++++++++----------------------------------- src/xi.sh | 8 ++++++- 3 files changed, 46 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/query.sh b/src/query.sh index dc3846c..14d9adf 100644 --- a/src/query.sh +++ b/src/query.sh @@ -5,10 +5,18 @@ list () { find ${PACKAGES_DIR} -type f | sed "s,${PACKAGES_DIR}/,," } -list_installed () { +installed () { ls -1 ${INSTALLED_DIR} } +list_installed () { + list | while read -r line; do + [ -d ${INSTALLED_DIR}/$line ] \ + && echo $line "[installed]" \ + || echo $line + done +} + search () { if [ $# = 0 ]; then list diff --git a/src/sync.sh b/src/sync.sh index 6462a8a..263d555 100755 --- a/src/sync.sh +++ b/src/sync.sh @@ -4,40 +4,36 @@ # save each listed package in a relevant directory, based on checksum # parse_line() { - [ "$#" = "6" ] && { - local repo=$1 - local repo_url=$2 - local package=$3 - local checksum=$4 - local size=$5 - local files=$6 + [ "$#" = "5" ] && { + local url=$1 + local package=$2 + local checksum=$3 + local size=$4 + local files=$5 local package_name=$(basename $package ".xipkg") - local package_dir="$PACKAGES_DIR/$repo/$package_name.versions" + local package_dir="$PACKAGES_DIR/$package_name.versions" local checksum_file=$package_dir/$checksum [ -d $package_dir ] || mkdir -p $package_dir - printf "$repo_url/$package $checksum $size $files\n" >> $checksum_file + printf "$url/$package $checksum $size $files\n" >> $checksum_file } } list_source () { - local repo=$1 - local src=$2 - + local src=$1 local url=$(echo $src | cut -d":" -f2-) local name=$(echo $src | cut -d":" -f1) - local repo_url="${url}${repo}" - local full_url="${repo_url}/packages.list" - local tmp_file="${SYNC_CACHE}/$name.$repo" + local full_url="${url}/packages.list" + local tmp_file="${SYNC_CACHE}/$name" - ${VERBOSE} && printf "${LIGHT_BLACK}Indexing $repo from $full_url\n" + ${VERBOSE} && printf "${LIGHT_BLACK}Indexing packages from $full_url\n" local status=$(download_file $tmp_file $full_url) - if [ "$status" = "200" ] || [ "$status" = "000" ] && [ -f $tmp_file ]; then + if [ "$status" = "200" ] || [ "$status" = "000" ] && [ -f $tmp_file ]; then while IFS= read -r line; do - parse_line $repo $repo_url $line + parse_line $url $line done < "$tmp_file" else return 1 @@ -55,11 +51,11 @@ dep_graph () { local status=$(download_file $tmp_file $full_url) if [ "$status" = "200" ] || [ "$status" = "000" ]; then while IFS= read -r line; do - local package=$(echo $line | cut -d: -f1) - local new=$(echo $line | cut -d: -f2-) - - [ -z "${package}" ] && + [ "${#line}" != "0" ] && { + local package=$(echo $line | cut -d: -f1) + local new=$(echo $line | cut -d: -f2-) echo $new >> $DEP_DIR/$package + } done < "$tmp_file" fi } @@ -81,7 +77,7 @@ popularity_contest () { return 1 fi - local list=$(ls -1 -d $PACKAGES_DIR/*/*) + local list=$(ls -1 -d $PACKAGES_DIR/*) local total=$(echo $list | wc -l) local completed=0 @@ -94,32 +90,29 @@ popularity_contest () { } index_deps () { - local l=$1 set -- ${SOURCES} local total=$# local completed=0 for src in ${SOURCES}; do + ${QUIET} || hbar -T "${LARGE_CIRCLE} indexing dependencies..." $completed $total dep_graph $src completed=$((completed+1)) - ${QUIET} || hbar -l $l -T "${LARGE_CIRCLE} indexing dependencies..." $completed $total done - ${QUIET} || hbar -l $l ${HBAR_COMPLETE} -T "${CHECKMARK} indexed dependencies" $completed $total + ${QUIET} || hbar ${HBAR_COMPLETE} -T "${CHECKMARK} indexed dependencies" $completed $total } index_repo () { - local repo=$1 l=$2 set -- ${SOURCES} local total=$# local completed=0 - for src in ${SOURCES}; do - list_source $repo $src + ${QUIET} || hbar -T "${LARGE_CIRCLE} syncing sources..." $completed $total + list_source $src completed=$((completed+1)) - ${QUIET} || hbar -l $l -T "${LARGE_CIRCLE} syncing $repo..." $completed $total done - ${QUIET} || hbar -l $l ${HBAR_COMPLETE} -T "${CHECKMARK} synced $repo" $completed $total + ${QUIET} || hbar ${HBAR_COMPLETE} -T "${CHECKMARK} synced sources" $completed $total } sync () { @@ -131,19 +124,14 @@ sync () { mkdir $DEP_DIR ${VERBOSE} && printf "${LIGHT_BLACK}Syncing\n" - # create padding spaces for each hbar - ${QUIET} || for repo in ${REPOS}; do - hbar - done # download package lists and dep graphs at the same time - index_deps 0 & - local i=1 - for repo in ${REPOS}; do - mkdir -p ${PACKAGES_DIR}/$repo - index_repo $repo $i & - i=$((i+1)) - done + mkdir -p ${PACKAGES_DIR} + + # index packages and dependencies + index_repo + ${QUIET} || hbar + index_deps # wait for all jobs to complete wait diff --git a/src/xi.sh b/src/xi.sh index 786547d..4b66025 100755 --- a/src/xi.sh +++ b/src/xi.sh @@ -53,8 +53,10 @@ ${BLUE}Available Commands: ${LIGHT_CYAN}verify that a package's files are intact ${LIGHT_GREEN}list ${LIGHT_CYAN}list available packages - ${LIGHT_GREEN}list-installed + ${LIGHT_GREEN}installed ${LIGHT_CYAN}lists installed packages + ${LIGHT_GREEN}list-installed + ${LIGHT_CYAN}list packages showing the installed ones ${LIGHT_GREEN}file ${LIGHT_BLUE}[path] ${LIGHT_CYAN}shows which package a file belongs to ${LIGHT_GREEN}info ${LIGHT_BLUE}[package] @@ -209,6 +211,9 @@ else "list-installed") list_installed ;; + "installed") + installed + ;; "file") shift file_info $@ @@ -242,6 +247,7 @@ else usage ;; *) + checkroot $DO_SYNC && sync install $@ ;; -- cgit v1.2.1