diff options
Diffstat (limited to 'src/install.sh')
-rw-r--r-- | src/install.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/install.sh b/src/install.sh new file mode 100644 index 0000000..3623473 --- /dev/null +++ b/src/install.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +extract () { + tar -h --no-overwrite-dir -vvxf $1 -C ${SYSROOT} | grep ^- +} + +install_package () { + local pkg_file="$1" + local name="$2" + local info_file="$pkg_file.info" + + local installed_dir="${INSTALLED_DIR}/$name" + local info="$installed_dir/info" + local files="$installed_dir/files" + local checksum="$installed_dir/checksum" + + mkdir -p "$installed_dir" + extract $1 > $files + cp $info_file $info + + md5sum $pkg_file | cut -d' ' -f1 > $checksum +} + +get_package_filecount() { + local info=($(get_package_download_info $1)) + echo ${info[3]} +} + +total_filecount() { + local packages=($@) + local count=0 + for package in ${packages[*]}; do + local name=$(basename -s .xipkg $package | cut -d. -f2) + local c=$(get_package_filecount $name) + count=$((count+c)) + done + echo $count +} + +install () { + local packages=($@) + + local missing=() + for package in ${packages[*]}; do + [ ! -f $package ] && missing+=($(basename $package)) + done + + if [ "${#missing[@]}" != "0" ]; then + # warning: potential recursion loop here + fetch ${missing[*]} + else + + local total=$(total_filecount ${packages[*]}) + local files_files=() + for package in ${packages[*]}; do + local name=$(basename -s .xipkg $package | cut -d. -f2) + install_package $package $name & + files_files+=("${INSTALLED_DIR}/$name/files") + done + wait_for_extract $total ${files_files[*]} + fi +} |