summaryrefslogtreecommitdiff
path: root/src/install.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-02-17 02:15:19 +0000
committerdavidovski <david@davidovski.xyz>2022-02-17 02:15:19 +0000
commit35dcb815e217c1135012ba81616496c3ad10b3f5 (patch)
treec1190a25e1cc2ad74674a06f1faac8a0b9db871e /src/install.sh
parent1117f2bef50ec65aa6bfe55e8e22beb5be092275 (diff)
added file installing
Diffstat (limited to 'src/install.sh')
-rw-r--r--src/install.sh62
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
+}