summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/get.sh197
-rw-r--r--src/install.sh9
-rw-r--r--src/util.sh2
-rwxr-xr-xsrc/xi.sh8
4 files changed, 106 insertions, 110 deletions
diff --git a/src/get.sh b/src/get.sh
index 64fc110..6c23767 100755
--- a/src/get.sh
+++ b/src/get.sh
@@ -18,34 +18,38 @@ resolve_deps () {
local out="${CACHE_DIR}/deps"
local deps=""
local i=0
- if ${RESOLVE_DEPS}; then
- hbar
- while [ "$#" != "0" ]; do
- # pop a value from the args
- local package=$1
+ if ! ${RESOLVE_DEPS}; then
+ echo $@ > $out
+ return 0
+ fi
- #only add if not already added
- if ! echo ${deps} | grep -q "\b$package\b"; then
- deps="$deps $package"
- i=$((i+1))
- fi
+ hbar
+ while [ "$#" != "0" ]; do
+
+ # pop a value from the args
+ local package=$1
- for dep in $(list_deps $package); do
- # if not already checked
- if echo $@ | grep -qv "\b$dep\b"; then
- set -- $@ $dep
- fi
- done
- shift
- ${QUIET} || hbar -T "${CHECKMARK} resolving dependencies" $i $((i + $#))
+ #only add if not already added
+ if ! echo ${deps} | grep -q "\b$package\b"; then
+ deps="$deps $package"
+ i=$((i+1))
+ fi
+
+ for dep in $(list_deps $package); do
+ # if not already checked
+ if echo $@ | grep -qv "\b$dep\b"; then
+ set -- $@ $dep
+ fi
done
- ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} resolved dependencies" $i $((i + $#))
- echo ${deps} > $out
- else
- echo $@ > $out
- fi
+ shift
+
+ ${QUIET} || hbar -T "${CHECKMARK} resolving dependencies" $i $((i + $#))
+ done
+
+ ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} resolved dependencies" $i $((i + $#))
+ echo ${deps} > $out
}
get_package_download_info() {
@@ -82,14 +86,13 @@ download_package () {
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" || printf "${RED}Failed to download info for %s\n" $package) &
- (curl ${CURL_OPTS} -o "$output" "$url" || printf "${RED}Failed to download %s\n" $package) &
+ return 0
fi
+ ${VERBOSE} && printf "${LIGHT_BLACK}downloading $package from $url\n" $package $checksum
+ touch $output
+ (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) &
}
download_packages () {
@@ -110,100 +113,79 @@ download_packages () {
echo
set -- $outputs
- if ! ${UNSAFE}; then
- local i=0
- 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 $pkg_file .xipkg)
- mv "$pkg_file" "${pkg_file}.invalid"
- else
- i=$((i+1))
- fi
- done
- ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} validated downloads" $i $#
- fi
- install $@
+ local i=0
+ ${UNSAFE} || 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 $pkg_file .xipkg)
+ mv "$pkg_file" "${pkg_file}.invalid"
+ else
+ i=$((i+1))
+ fi
+ done &&
+ ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} validated downloads" $i $#
+
+ install $@
}
get () {
local requested=$@
-
- local missing=""
- local already=""
- local install=""
- local update=""
- local urls=""
-
+ local missing="" already="" install="" update="" urls=""
local total_download=0
-
local out="${CACHE_DIR}/deps"
+
touch $out
resolve_deps $@
for package in $(cat $out); do
- if package_exists $package; then
- set -- $(get_package_download_info $package)
- checksum=$2
- size=$3
-
- if is_installed $package; then
- if [ "$(get_installed_version $package)" != "$checksum" ]; then
- update="$update $package"
- total_download=$((total_download+size))
- else
- already="$already $package"
- fi
- else
- install="$install $package"
- total_download=$((total_download+size))
- fi
- else
+ if ! package_exists $package; then
missing="$missing $package"
+ continue
fi
- done
- # TODO tidy this
- if ! ${QUIET}; then
- if [ "${#missing}" != "0" ]; then
- printf "${LIGHT_RED}The following packages could not be located:"
- for package in ${missing}; do
- printf "${RED} $package"
- done
- printf "${RESET}\n"
- fi
- if [ "${#update}" != "0" ]; then
- printf "${LIGHT_GREEN}The following packages will be updated:\n\t"
- for package in ${update}; do
- printf "${GREEN} $package"
- done
- printf "${RESET}\n"
- fi
- if [ "${#install}" != "0" ]; then
- printf "${LIGHT_BLUE}The following packages will be installed:\n\t"
- for package in ${install}; do
- printf "${BLUE} $package"
- done
- printf "${RESET}\n"
+ set -- $(get_package_download_info $package)
+ checksum=$2
+ size=$3
+
+ if ! is_installed $package; then
+ install="$install $package"
+ total_download=$((total_download+size))
+ continue
fi
- if [ "${#install}" = "0" ] && [ "${#update}" = 0 ] && [ "${#already}" != "0" ]; then
- printf "${LIGHT_WHITE}The following packages are already up to date:\n\t"
- for package in ${already}; do
- printf "${WHITE} $package"
- done
- printf "${RESET}\n"
+
+ if [ "$(get_installed_version $package)" = "$checksum" ]; then
+ already="$already $package"
+ continue
fi
- fi
+ update="$update $package"
+ 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
+
+ [ "${update}" ] &&
+ printf "${LIGHT_GREEN}The following packages will be updated:\n\t${GREEN}%s\n${RESET}" $update
+
+ [ "${install}" ] &&
+ printf "${LIGHT_BLUE}The following packages will be installed:\n\t${BLUE}%s\n${RESET}" $install
- [ "${#install}" = "0" ] && [ "${#update}" = 0 ] && printf "${LIGHT_RED}Nothing to do!\n" && return 0
+ [ ! "${install}" ] && [ ! "${update}" ] && [ "${already}" ] &&
+ printf "${LIGHT_WHITE}The following packages are already up to date:\n\t${WHITE}%s\n${RESET}" $already
+ }
-
- ${QUIET} || [ "${SYSROOT}" = "/" ] || printf "${WHITE}To install to ${LIGHT_WHITE}${SYSROOT}${RESET}\n"
- ${QUIET} || printf "${WHITE}Total download size:${LIGHT_WHITE} $(format_bytes $total_download)\n"
+ [ ! "${#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}
@@ -213,8 +195,8 @@ get () {
}
fetch () {
- local packages=$@
- local outputs=""
+ local packages=$@ \
+ outputs=""
local total_download=0
for package in $packages; do
@@ -231,3 +213,4 @@ fetch () {
wait_for_download $total_download ${outputs}
}
+
diff --git a/src/install.sh b/src/install.sh
index 198b4e5..140c6dd 100644
--- a/src/install.sh
+++ b/src/install.sh
@@ -104,7 +104,7 @@ install () {
local total=$(total_filecount $packages 2>/dev/null || echo 1)
local files_files=""
for package in $packages; do
- local name=$(basename package .xipkg | cut -d. -f2)
+ local name=$(basename $package .xipkg | cut -d. -f2)
${VERBOSE} && printf "${BLACK}installing $name from $package \n${RESET}"
install_package $package $name &
@@ -117,3 +117,10 @@ install () {
run_postinstall
fi
}
+
+reinstall () {
+ local packages=$@
+ remove $@
+ install $@
+}
+
diff --git a/src/util.sh b/src/util.sh
index 11db5e3..98af40b 100644
--- a/src/util.sh
+++ b/src/util.sh
@@ -37,7 +37,7 @@ wait_for_download () {
while [ "$downloaded" -lt "$total_download" ]; do
downloaded=0
for output in $@; do
- size=$(stat -c %s $output)
+ size=$(stat -t $output | cut -d" " -f2)
downloaded=$((downloaded+size))
done
diff --git a/src/xi.sh b/src/xi.sh
index 39581e9..6cbb315 100755
--- a/src/xi.sh
+++ b/src/xi.sh
@@ -34,6 +34,8 @@ Available Commands:
update all packages on the system
remove [packages...]
remove packages from the system
+ reinstall [packages..]
+ remove and reinstall package(s) into the system
fetch [package]
download a .xipkg file
keyimport [name] [url]
@@ -116,6 +118,7 @@ done
. ${LIBDIR}/sync.sh
. ${LIBDIR}/install.sh
. ${LIBDIR}/get.sh
+. ${LIBDIR}/remove.sh
shift $((OPTIND-1))
@@ -143,9 +146,12 @@ else
;;
"remove")
shift
- . ${LIBDIR}/remove.sh
remove $@
;;
+ "reinstall")
+ shift
+ reinstall $@
+ ;;
"files")
shift
files $@