WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Script to download extensions+dependencies on other Linux distros  (Read 421 times)

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6831
This is my attempt to try to ease a situation that comes up on a regular basis:
I can't get the extension(s) I need because I can't get my wireless connection up.

This is for Linux machines only that have an Internet connection. I tried to avoid any Tinycore specific references and kept command
options as simple as possible. Dependencies are resolved by reducing the  .tree  file to a sorted list of unique entries. Files are
downloaded to the directory you are in when you invoke the script.

I think the script is fairly well documented if you want to see what's going on. Comments and criticism are welcomed.

FetchExt.sh ExtensionName  without the  .tcz  will download the extension+dependencies including .dep and .md5 files
FetchExt.sh info  will download a list  of available extensions and attempt to display it using the  less  command in a separate terminal.
                          If that fails, just open  info.lst  with your favorite file viewer.

This is what the  ./Log.txt  file it generates looks like:
Code: [Select]
Mon Jul  8 00:55:48 UTC 2019
Processing http://repo.tinycorelinux.net/10.x/x86/tcz/wifi.tcz.tree
libiw.tcz downloaded.
libiw.tcz.md5.txt downloaded.
libnl.tcz downloaded.
libnl.tcz.md5.txt downloaded.
ncursesw.tcz downloaded.
ncursesw.tcz.md5.txt downloaded.
openssl.tcz downloaded.
openssl.tcz.md5.txt downloaded.
readline.tcz downloaded.
readline.tcz.md5.txt downloaded.
readline.tcz.dep downloaded.
wifi.tcz downloaded.
wifi.tcz.md5.txt downloaded.
wifi.tcz.dep downloaded.
wireless-4.19.10-tinycore.tcz downloaded.
wireless-4.19.10-tinycore.tcz.md5.txt downloaded.
wireless_tools.tcz downloaded.
wireless_tools.tcz.md5.txt downloaded.
wireless_tools.tcz.dep downloaded.
wpa_supplicant.tcz downloaded.
wpa_supplicant.tcz.md5.txt downloaded.
wpa_supplicant.tcz.dep downloaded.

Mon Jul  8 15:06:48 UTC 2019
Processing http://repo.tinycorelinux.net/10.x/x86/tcz/wireless-rtl8822be-4.19.10-tinycore.tcz.tree
firmware-rtlwifi.tcz downloaded.
firmware-rtlwifi.tcz.md5.txt downloaded.
wireless-4.19.10-tinycore.tcz already downloaded.
wireless-rtl8822be-4.19.10-tinycore.tcz downloaded.
wireless-rtl8822be-4.19.10-tinycore.tcz.md5.txt downloaded.
wireless-rtl8822be-4.19.10-tinycore.tcz.dep downloaded.

The line after each timestamp is what you add to your  onboot.lst  file, in this case  wireless-rtl8822be-4.19.10-tinycore.tcz
and  wifi,tcz.

Then copy  *.tcz*  from your download directory to your  tce/optional directory.

This is what the script looks like:
Code: [Select]
# Script to download an extension and its dependencies written by Richard A. Rost July 7,2019
# The script downloads to the directory you are in when you start the script.
# There are no Tinycore specific commands, variables, or directories required so it should work
# on any Linux box.
# Some error checking is done, though it might not be as thorough as it should be.
# The script downloads the  .tcz,  .tcz.dep,  and  .tcz.md5.txt  files for each extension.
# MD5 is verified.
# File ownership is changed to tc:staff.
# A running timestamped log is kept in  ./Log.txt
# ./Extension.list  is a sorted  .tree  file with duplicates removed of the last extension downloaded.
# Usage:
# FetchExt.sh ExtensionName Fetches the extension and its dependencies. ExtensionName is
# case sensitive and should NOT include the  .tcz  extension.
# FetchExt.sh info Fetches the list of available extensions in the listed repository.

# Repository to download from

# Tinycore version

# Processor architecture, current options are  x86  x86_64  armv6  armv7

# This is where the extensions get downloaded from.

if [ "$EXT" = "info" ]


# This is a running log of all downloads

# Remove previous copy of file if it exists so that  wget  doesn't create numbered backups.
rm -rf "$EXT$TYPE"

wget -q "$TREE" > /dev/null 2>&1
if [ "$?" != "0" ]
wget -q --spider "$URL$EXT.tcz" > /dev/null 2>&1 # No .tcz.tree found, check for .tcz
if [ "$?" == "0" ]
then # Extension exists but has no dependencies so create a tree file.
echo -e "$EXT.tcz\n" > "$EXT.tcz.tree"
echo "$TREE  not found."
exit 1

if [ "$EXT$TYPE" = "info.lst" ]
then # Dispaly the  info.lst  file in a terminal using the  less  command.
xterm +tr +sb -T "info.lst" -e less info.lst &
exit 0

# awk '$1=$1' removes all whitespaces, sort -u sorts alphabetically and removes duplicate entries.
awk '$1=$1' "$EXT$TYPE" | sort -u > Extension.list
rm -rf "$EXT$TYPE"

# Update the log file with a newline, timestamp, a newline, and the name of the extension being processed.
echo -e "\n`date`\nProcessing $TREE" >> $LOG

for FILE in `cat Extension.list`
if [ -f "$FILE" ]
echo "$FILE already downloaded." >> $LOG

# Fetch extension
wget -q "$URL$FILE" > /dev/null 2>&1
if [ "$?" != "0" ]
echo "$FILE download failed." >> $LOG
echo "$FILE downloaded." >> $LOG
# Change ownership. Numeric values used because foreign Linux box won't have tc:staff.
chown 1001:50 "$FILE"

# Fetch MD5
wget -q "$URL$FILE.md5.txt" > /dev/null 2>&1
if [ "$?" != "0" ]
echo "$FILE.md5.txt download failed." >> $LOG
echo "$FILE.md5.txt downloaded." >> $LOG
# Change ownership. Numeric values used because foreign Linux box won't have tc:staff.
chown 1001:50 "$FILE.md5.txt"

# Fetch dependency file
wget -q "$URL$FILE.dep" > /dev/null 2>&1
if [ "$?" == "0" ]
echo "$FILE.dep downloaded." >> $LOG
# Change ownership. Numeric values used because foreign Linux box won't have tc:staff.
chown 1001:50 "$FILE.dep"

# Verify MD%
md5sum -c "$FILE.md5.txt"
if [ "$?" != "0" ]
echo "$FILE md5 checksum failed." >> $LOG


exit 0

A copy is attached for downloading.