diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/get.sh | 6 | ||||
-rw-r--r-- | src/install.sh | 2 | ||||
-rwxr-xr-x | src/profile.sh | 2 | ||||
-rw-r--r-- | src/query.sh | 5 | ||||
-rwxr-xr-x | src/sync.sh | 20 | ||||
-rw-r--r-- | src/util.sh | 5 | ||||
-rwxr-xr-x | src/xi.sh | 6 |
7 files changed, 33 insertions, 13 deletions
@@ -81,16 +81,18 @@ download_packages () { if 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 touch $output - curl ${CURL_OPTS} -o "$output_info" "$url.info" & - curl ${CURL_OPTS} -o "$output" "$url" & + (curl ${CURL_OPTS} -o "$output_info" "$url.info" || printf "${RED}Failed to download info for %s\n" $package) & + (curl ${CURL_OPTS} -o "$output" "$url" || printf "${RED}Failed to download %s\n" $package) & fi outputs="$outputs $output" done wait_for_download $total_download ${outputs} + echo local i=0 set -- $outputs diff --git a/src/install.sh b/src/install.sh index 63120be..432af27 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,7 +1,7 @@ #!/bin/sh extract () { - tar -h --no-overwrite-dir -vvxf $1 -C ${SYSROOT} | grep ^- + tar -h --no-overwrite-dir -vvxf $1 -C ${SYSROOT} | grep ^- | tr -s " " | cut -d" " -f6 | cut -c2- } install_package () { diff --git a/src/profile.sh b/src/profile.sh index 915f1c9..f05271b 100755 --- a/src/profile.sh +++ b/src/profile.sh @@ -7,7 +7,7 @@ export CONF_FILE="/etc/xipkg.conf" -export CURL_OPTS="-SsL" +export CURL_OPTS="-sL" export DEP_DIR=$(parseconf -v dir.deps) export REPOS="$(parseconf -v repos)" diff --git a/src/query.sh b/src/query.sh new file mode 100644 index 0000000..7e66b7c --- /dev/null +++ b/src/query.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +search () { + find ${PACKAGES_DIR} -type f | sed "s,${PACKAGES_DIR}/,," | grep$(echo $@ | sed "s/ /\\|/g") +} diff --git a/src/sync.sh b/src/sync.sh index c0dd36c..3d1c7d1 100755 --- a/src/sync.sh +++ b/src/sync.sh @@ -30,12 +30,15 @@ list_source () { local full_url="${repo_url}/packages.list" local tmp_file="${SYNC_CACHE}/$name.$repo" + ${VERBOSE} && printf "${LIGHT_BLACK}Indexing $repo from $full_url\n" local status=$(download_file $tmp_file $full_url) - if [ "$status" = "200" ]; then + if [ "$status" = "200" ] || [ "$status" = "000" ]; then while IFS= read -r line; do parse_line $repo $repo_url $line done < "$tmp_file" + else + return 1 fi } @@ -47,7 +50,8 @@ dep_graph () { local tmp_file="${SYNC_CACHE}/$name.deps.graph" [ -f $tmp_file ] && rm $tmp_file; touch $tmp_file - if [ "$(download_file $tmp_file $full_url)" = "200" ]; then + 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-) @@ -68,6 +72,11 @@ contest () { } popularity_contest () { + if [ "$(find $PACKAGES_DIR -type f | wc -l)" = "0" ]; then + printf "${RED}No packages found!\n"; + return 1 + fi + local list=$(ls -1 -d $PACKAGES_DIR/*/*) local total=$(echo $list | wc -l) @@ -75,9 +84,9 @@ popularity_contest () { for package_dir in $list; do contest $package_dir & completed=$((completed+1)) - hbar -T "${LARGE_CIRCLE} contesting packages..." $completed $total + ${QUIET} || hbar -T "${LARGE_CIRCLE} contesting packages..." $completed $total done - hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} contested packages" $completed $completed + ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} contested packages" $completed $completed } index_deps () { @@ -100,6 +109,7 @@ index_repo () { local total=$# local completed=0 + for src in ${SOURCES}; do list_source $repo $src completed=$((completed+1)) @@ -108,7 +118,6 @@ index_repo () { ${QUIET} || hbar -l $l ${HBAR_COMPLETE} -T "${CHECKMARK} synced $repo" $completed $total } - sync () { # prepare the file structure for the sync mkdir -p ${SYNC_CACHE} @@ -117,6 +126,7 @@ sync () { rm -r $DEP_DIR mkdir $DEP_DIR + ${VERBOSE} && printf "${LIGHT_BLACK}Syncing\n" # create padding spaces for each hbar ${QUIET} || for repo in ${REPOS}; do hbar diff --git a/src/util.sh b/src/util.sh index 82d26ca..11db5e3 100644 --- a/src/util.sh +++ b/src/util.sh @@ -35,7 +35,7 @@ wait_for_download () { local downloaded=0 while [ "$downloaded" -lt "$total_download" ]; do - + downloaded=0 for output in $@; do size=$(stat -c %s $output) downloaded=$((downloaded+size)) @@ -56,8 +56,7 @@ wait_for_extract () { shift while [ "$extracted" -lt "$total_filecount" ]; do - local extracted=0 - + extracted=0 for output in $@; do if [ -f $output ]; then size=$(cat $output | wc -l) @@ -44,6 +44,7 @@ done . ${LIBDIR}/util.sh . ${LIBDIR}/validate.sh +. ${LIBDIR}/query.sh . ${LIBDIR}/sync.sh . ${LIBDIR}/install.sh . ${LIBDIR}/get.sh @@ -59,9 +60,12 @@ else ;; "install" | "update") shift - $DO_SYNC && sync install $@ ;; + "search") + shift + search $@ + ;; *) $DO_SYNC && sync fetch $@ |