From 35dcb815e217c1135012ba81616496c3ad10b3f5 Mon Sep 17 00:00:00 2001 From: davidovski Date: Thu, 17 Feb 2022 02:15:19 +0000 Subject: added file installing --- src/install.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/install.sh (limited to 'src/install.sh') 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 +} -- cgit v1.2.1