Currently, tce-load can only fetch extensions using wget. Therefore, /opt/tcemirror must contain a URL to http(s) or ftp server.
But what if the TC machine has access to a local mirror attached to its filesystem? It would seem silly for the machine to run http sever just to serve a mirror to itself.
I created a simple patch to tce-load. With this patch, tce-load examines the first character of the MIRROR variable. If the first character is / then tce-load uses cp to fetch the extension(s). Otherwise, tce-load uses wget as usual.
For example, if /opt/tcemirror contains something like this:
http://repo.tinycorelinux.net/
Then tce-load uses wget as usual.
On the other hand, if /opt/tcemirror contains something like this:
/mnt/mirror/tinycorelinux/
Then tce-load uses cp.
Here is the patch:
--- tce-load-old 2019-07-08 08:57:49.155847229 -0400
+++ tce-load-new 2019-07-08 10:12:52.121940000 -0400
@@ -7,7 +7,7 @@
checknotroot
PROG_NAME=$(basename $0)
KERNELVER=$(uname -r)
-unset WGET INSTALL COPYINSTALL BOOTING ONDEMAND DOWNLOAD_ONLY LOAD_ONLY SUPPRESS
+unset GET INSTALL COPYINSTALL BOOTING ONDEMAND DOWNLOAD_ONLY LOAD_ONLY SUPPRESS
FORCE="n" # Overwrite system files default to no. Use -f to force overwrite.
SAVED_DIR=`pwd`
@@ -49,7 +49,7 @@
while getopts wilcbosft: OPTION
do
case ${OPTION} in
- w) WGET=TRUE ;;
+ w) GET=TRUE ;;
i) INSTALL=TRUE ;;
l) LOAD_ONLY=TRUE ;;
c) COPYINSTALL=TRUE ;;
@@ -62,7 +62,7 @@
esac
done
shift `expr $OPTIND - 1`
-[ -z "$1" ] || ( [ -z "$WGET" ] && [ -z "$INSTALL" ] ) && abort
+[ -z "$1" ] || ( [ -z "$GET" ] && [ -z "$INSTALL" ] ) && abort
app_exists() {
[ -f "$2/$1" ] && [ -f "$2/$1".md5.txt ] && (cd "$2" && md5sum -cs "$1".md5.txt)
@@ -70,8 +70,13 @@
fetch_app() {
echo "Downloading: $1"
- wget -cq "$MIRROR"/"$1".md5.txt 2>/dev/null
- wget -c "$MIRROR"/"$1"
+ if [ "$MIRROR_IS_PATH" ]; then
+ cp "$MIRROR"/"$1".md5.txt ./
+ cp "$MIRROR"/"$1" ./
+ else
+ wget -cq "$MIRROR"/"$1".md5.txt 2>/dev/null
+ wget -c "$MIRROR"/"$1"
+ fi
md5sum -c "$1".md5.txt
if [ "$?" != 0 ]; then
echo "Error on $1"
@@ -158,7 +163,7 @@
}
recursive_scan_dep() {
- echo -e "$@"|awk '
+ echo -e "$@"|awk -v mirror_is_path="$MIRROR_IS_PATH" '
function recursive_scan(name, optional, mirror, _, depfile, line, i) {
gsub(/[\t ]+/, "", name)
if (name) {
@@ -176,8 +181,12 @@
IRANGE[name"#1"]=IDX
depfile=optional"/"name".dep"
if (mirror && (system("test ! -f "depfile) == 0 || system("test ! -f "optional"/"name) == 0))
- if (system("rm -f "depfile"; wget -c -P "optional" "mirror"/"name".dep 2>/dev/null") == 0 && ! SUPPRESS)
- system("echo "name".dep OK 1>&2")
+ if (mirror_is_path == "TRUE")
+ if (system("rm -f "depfile"; cp "mirror"/"name".dep ./"optional"/ 2>/dev/null") == 0 && ! SUPPRESS)
+ system("echo "name".dep OK 1>&2")
+ else
+ if (system("rm -f "depfile"; wget -c -P "optional" "mirror"/"name".dep 2>/dev/null") == 0 && ! SUPPRESS)
+ system("echo "name".dep OK 1>&2")
MARK[name]=2
if (mirror || system("test -f "optional"/"name) == 0) {
while (getline line < depfile > 0)
@@ -215,7 +224,7 @@
[ -f /etc/sysconfig/showapps ] && SHOWAPPS=TRUE && SUPPRESS=TRUE
# Check for download only
[ -z "$INSTALL" ] && DOWNLOAD_ONLY=1
-[ -z "$WGET" ] && [ "$INSTALL" ] && LOAD_ONLY=1
+[ -z "$GET" ] && [ "$INSTALL" ] && LOAD_ONLY=1
OPTIONAL="`realpath $TCEDIR`/optional"
TARGETSLOCAL=""
@@ -245,7 +254,7 @@
fi
fi
-if [ "$WGET" ]; then
+if [ "$GET" ]; then
if app_exists "$EXTENSION" "$FROMWHERE"; then
echo "$APPNAME is already downloaded."
else
@@ -263,6 +272,7 @@
if [ "$TARGETSFETCH" ]; then
getMirror
+ [ "$(echo $MIRROR | cut -c1)" = "/" ] && MIRROR_IS_PATH=TRUE
TARGETSFETCH="`echo -e $TARGETSFETCH | awk '/\w/ {print $1" . '"$MIRROR"'"}'`"
recursive_scan_dep "$TARGETSFETCH" | while read F; do
{ test "${F%% *}" = "@" && EXTENSION="${F#@ }" && SKIP="" || test "$SKIP"; } && continue
I hope it is useful.
Cheers,
-Bruno