diff --git a/scripts/tc-docker b/scripts/tc-docker index 1fccf3c..74dbbb5 100755 --- a/scripts/tc-docker +++ b/scripts/tc-docker @@ -2,7 +2,7 @@ # # @file tc-docker # @description tc-docker, helper script for building innovarew/docker-tinycore -# @author innovarew (c) Copyright 2022 +# @author innovarew (c) Copyright 2022 GPLv2 # @copyright All rights reserved. Read LICENSE.txt file for the license terms. # @url github.com/innovarew/docker-tinycore # @@ -19,8 +19,9 @@ # PROGNAME=${0##*/} -PROGAUTHOR="innovarew (c) 2022." PROGVERSION=v1.2 +PROGAUTHOR="innovarew" +PROGURL="https://github.com/innovarew/docker-tinycore" set -euf @@ -38,7 +39,7 @@ fi tce_rootfs_init() { - TC_VER=$(echo $TC_URL | awk -F/ '{print $4"-"$5}') + TC_VER=$(echo "$TC_URL" | awk -F/ '{print $4"-"$5}') TC_TAR="rootfs-$TC_VER.tar.xz" TC_PATCH="rootfs-$TC_VER.patch" @@ -57,11 +58,11 @@ tce_rootfs_init() tce_rootfs_unpack "$@" # rootfs contains .ko.gz not used by docker - find $PWD/root/ -name '*.ko.gz' -exec rm {} \; + find "$PWD/root/" -name '*.ko.gz' -exec rm {} \; # get unsquashfs into container to unpack tcz - tce_install liblzma.tcz $PWD/root/ - tce_install squashfs-tools.tcz $PWD/root/ + tce_install liblzma.tcz "$PWD/root/" + tce_install squashfs-tools.tcz "$PWD/root/" patch -p2 < $TC_PATCH ) @@ -71,7 +72,7 @@ tce_rootfs_init() tce_rootfs_unpack() { - ISO_FILE=$(basename "$ISO_URL") + ISO_FILE="${ISO_URL##*/}" wget -qc "$ISO_URL" # wget -qc "$ISO_URL.md5.txt" && md5sum -c $(basename "$ISO_URL.md5.txt") @@ -107,7 +108,7 @@ tce_install() local app=$1 local root=$2 - if [ -e $root/usr/local/tce.installed/${app%.tcz} ] + if [ -e "$root/usr/local/tce.installed/${app%.tcz}" ] then usage "warn: $app already installed in $root" fi @@ -115,25 +116,25 @@ tce_install() ( tce_cddir - if wget -qc $TCZ_URL/$app.dep + if wget -qc "$TCZ_URL/$app.dep" then - for dep in `cat $app.dep` + for dep in $(cat "$app.dep") do tce_install $dep $root done fi - wget -qc $TCZ_URL/$app - wget -qc $TCZ_URL/$app.md5.txt - [ -e "$app.md5.txt" ] && md5sum -c $app.md5.txt + wget -qc "$TCZ_URL/$app" + wget -qc "$TCZ_URL/$app.md5.txt" + [ -e "$app.md5.txt" ] && md5sum -c "$app.md5.txt" if [ -n "$UNSQUASHFS" ] then - unsquashfs -n -d "$root" -f $app >/dev/null + unsquashfs -n -d "$root" -f "$app" >/dev/null # update system - mkdir -p $root/usr/local/tce.installed/ - touch $root/usr/local/tce.installed/${app%.tcz} + mkdir -p "$root/usr/local/tce.installed/" + touch "$root/usr/local/tce.installed/${app%.tcz}" fi # update libs @@ -150,8 +151,8 @@ tce_info() local app=$1 ( tce_cddir - [ ! -e $app.info ] && wget -qc $TCZ_URL/$app.info - cat $app.info + [ ! -e "$app.info" ] && wget -qc "$TCZ_URL/$app.info" + cat "$app.info" ) } @@ -161,8 +162,8 @@ tce_list() local app=$1 ( tce_cddir - [ ! -e $app.list ] && wget -qc $TCZ_URL/$app.list - cat $app.list + [ ! -e "$app.list" ] && wget -qc "$TCZ_URL/$app.list" + cat "$app.list" ) } @@ -172,8 +173,8 @@ tce_dep() local app=$1 ( tce_cddir - [ ! -e $app.list ] && wget -qc $TCZ_URL/$app.dep - cat $app.dep + [ ! -e "$app.list" ] && wget -qc "$TCZ_URL/$app.dep" + cat "$app.dep" ) } @@ -181,8 +182,8 @@ tce_search() { ( tce_cddir - wget -qc $TCZ_URL - cat $(basename "$TCZ_URL") + wget -qc "$TCZ_URL" + cat "${TCZ_URL##*/}" ) } @@ -190,7 +191,7 @@ usage() { if [ $# -eq 0 ] then - echo "usage: $PROGNAME [tce_rootfs_init|tce_install] # @version $PROGVERSION @copyright $PROGAUTHOR"; + echo "usage: $PROGNAME [tce_rootfs_init|tce_install] # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL"; exit; else echo "$@"