WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline Leee

  • Wiki Author
  • Full Member
  • *****
  • Posts: 204
Re: Script to download extensions+dependencies on other Linux distros
« Reply #60 on: February 16, 2026, 03:14:03 PM »
Hi GNUser
A question from another thread gave me an idea.
Suppose you wanted to update to a newer version of Tinycore.
Then you decide to do this:
Code: [Select]
# Create your new tce directory:
mkdir NewTceOptional
cd NewTceOptional
# Download current version of FetchExt.sh:
wget https://forum.tinycorelinux.net/index.php?action=dlattach;topic=23034.0;attach=7078
# Make it executable:
chmod 755 FetchExt.sh
# Create list of currently installed extensions:
ls -1 /etc/sysconfig/tcedir/optional/*.tcz | cut -d '/' -f 6 > Ext.lst
# Fetch the extensions from the newer Tinycore repository:
for F in $(cat Ext.lst); do ./FetchExt.sh "$F"; done

Only problem is, when it encounters alsa-modules-6.12.11-tinycore64.tcz
when downloading from a repo with a 6.18.2 kernel, it fails.

Since you are limited to the kernel versions in a repo, it makes no sense
to specify a kernel version. As it is, the script currently downloads all
versions of a kernel module extension requested. This ensures the end
user has a version that matches their system. Then tce-load selects
the correct version when loading extensions.

So my idea is, when the script encounters an extension name with
a kernel version attached, we replace that part of the extension name
with  KERNEL  so the script can process it with available versions.

Do you (or anyone else) see a problem with this?
Comments requested.
Hi Rich,
I have a copy of your FetchExt.sh, though I surely haven't yet given it the attention it deserves because I already had a script of my own that I wrote for similar purposes (initially, for updating to a newer version of Tiny Core and pulling down extensions for the new one).
In my tce-lode script I have a function that resolves -KERNEL to the appropriate X.X.X-tinycore for whatever version is being downloaded.  But my script has no provision for going the other way, though I guess I'll have to think about that.  It's somewhat inconvenient that I have to update the kernel resolution function for each new version of Tiny Core but, overall, well worth the tiny effort that takes.  The relevant functions look like this:
Code: [Select]
get_kernel(){
  # ARG 1 : the core version level in the form n.x where n is the major
  #         version number and x is literally 'x'.  In the list below, note
  #         that 4.0 through 4.3 had a different kernel than the remainder
  #         of the 4.x series.  The later 4.x releases are considered more
  #         mainline and this function will return only the later kernel
  #         version for 4.x even though extensions with modules for the
  #         earlier kernel do also appear in the repo.
  #         Similarly, there was a minor kernel update in the 5.x
  #         series after 5.0 and the later kernel is returned by this
  #         function
  #
  # Output: kernel version number (not including "-tinycore" nor "64")
  #
  # This function does not concern itself with the non-x86*
  # architectures nor with the 32 bit / 64 bit issue.  The calling
  # routine should append "64" to the end of the kernel name if
  # the architecture x86_64.
  #
  case $1 in
    2.x )  KERNEL=2.6.29.1     ;;
    3.x )  KERNEL=2.6.33.3     ;;
    4.3 )  KERNEL=3.0.3        ;;
    4.x )  KERNEL=3.0.21       ;;
    5.0 )  KERNEL=3.8.10       ;;
    5.x )  KERNEL=3.8.13       ;;
    6.x )  KERNEL=3.16.6       ;;
    7.x )  KERNEL=4.2.9        ;;
    8.x )  KERNEL=4.8.17       ;;
    9.x )  KERNEL=4.14.10      ;;
    10.x ) KERNEL=4.19.10      ;;
    11.x ) KERNEL=5.4.3        ;;
    12.x ) KERNEL=5.10.3       ;;
    13.x ) KERNEL=5.15.10      ;;
    14.x ) KERNEL=6.1.2        ;;
    15.x ) KERNEL=6.6.8        ;;
    16.x ) KERNEL=6.12.11      ;;
    17.x ) KERNEL=6.18.2       ;;
    *)     KERNEL="BAD_KERNEL" ;;
  esac
  echo "${KERNEL}-tinycore"
}


Code: [Select]
#####
#
# fix_kern - replace "-KERNEL" in file name with actual kernal name
#
# ARG 1 : an extension name that includes "-KERNEL"
#
# Output: extension name that includes the actual kernel version.
#
fix_kern(){
  [ -z "${1}" ] && echo "`basename "${0}"` fix_kern: ERROR: argument required" && exit 10
  echo "${1}" |sed "s/-KERNEL/-${KERNEL}/"
}
#
#####

FWIW, I'll eventually post the entire script but not today - I've recently made some sweeping structural changes to it that I haven't yet full tested/debugged and I don't want to embarrass myself too badly.     ;)     @Rich - Can you make me a wiki author so I can post the full script in the wiki?

At this point it's almost a thousand lines long (though half of that is comments / built-in help).  It can do a lot of the installation bits (get the kernel and the initrd files, get the ISO file(s) if you want, etc) though the script does not concern itself with partitioning, formatting or bootloader installation.  Scope creep is such a wonderful thing.
core 16.0 x86_64

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1793
Re: Script to download extensions+dependencies on other Linux distros
« Reply #61 on: February 16, 2026, 08:23:15 PM »
So my idea is, when the script encounters an extension name with
a kernel version attached, we replace that part of the extension name
with  KERNEL  so the script can process it with available versions.
Hi Rich. I like your idea a lot--I can think of scenarios where this behavior would be very convenient. I cannot think of any scenarios when this behavior would pose a problem.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12589
Re: Script to download extensions+dependencies on other Linux distros
« Reply #62 on: February 16, 2026, 08:39:46 PM »
Hi nick65go
my remark is about your code example how to download it, not about the very-good fetch.sh  ;) ...
You are absolutely correct. I forgot attachments are not visible
if you are not logged in.

Quote
... I do not think that the script is somewhere on https://github.com/tinycorelinux ...
If there is interest, I'm OK with it being added to github.

Quote
... maybe you could have a dedicated folder with "unofficial" scripts. ...
An  Unofficial  folder on the repo server might be another possibility.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12589
Re: Script to download extensions+dependencies on other Linux distros
« Reply #63 on: February 16, 2026, 08:47:53 PM »
Hi Leee
... @Rich - Can you make me a wiki author so I can post the full script in the wiki? ...
Done. :)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12589
Re: Script to download extensions+dependencies on other Linux distros
« Reply #64 on: February 16, 2026, 09:13:55 PM »
Hi GNUser
... I cannot think of any scenarios when this behavior would pose a problem.
That was my thinking too.

One of the goals of the script was to avoid unexpected failures
which can be especially frustrating for beginners.

I feel this change will make this script more robust and user friendly.

If you have a chance, give the script a couple of shakes and see if my
change cause any bugs to fall out.

I've attached the updated Fetch.sh (Version 0.8 Feb 16, 2026).
The current version of ShowErrors.sh is also attached to keep them in the same post.
The posted versions in reply#57 will eventually be deleted.

Offline Leee

  • Wiki Author
  • Full Member
  • *****
  • Posts: 204
Re: Script to download extensions+dependencies on other Linux distros
« Reply #65 on: February 17, 2026, 12:04:49 AM »
Hi Leee
... @Rich - Can you make me a wiki author so I can post the full script in the wiki? ...
Done. :)
Thanks Rich.  I'll post that as son as I'm done updating the help screens.
core 16.0 x86_64

Offline CNK

  • Wiki Author
  • Sr. Member
  • *****
  • Posts: 416
Re: Script to download extensions+dependencies on other Linux distros
« Reply #66 on: February 18, 2026, 08:44:54 PM »
Suppose you wanted to update to a newer version of Tinycore.
Then you decide to do this:
Code: [Select]
# Create your new tce directory:
mkdir NewTceOptional
cd NewTceOptional
# Download current version of FetchExt.sh:
wget https://forum.tinycorelinux.net/index.php?action=dlattach;topic=23034.0;attach=7078
# Make it executable:
chmod 755 FetchExt.sh
# Create list of currently installed extensions:
ls -1 /etc/sysconfig/tcedir/optional/*.tcz | cut -d '/' -f 6 > Ext.lst
# Fetch the extensions from the newer Tinycore repository:
for F in $(cat Ext.lst); do ./FetchExt.sh "$F"; done

This is much like what I do (with a modified version of your script designed to minimise downloaded data by copying unchanged extensions from the old tce directory and using Zsync when available). But the problem with listing all the old extensions is you then include dependency extensions such as ones named something like 'fancylib3.tcz' which no longer exists in the newer TC repo where everything has been updated to use 'fancylib4.tcz' or something else. Therefore you get lots of errors for extensions that don't exist anymore, and have to decide whether it matters or not. You also end up installing dependencies that aren't needed at all anymore.

I've instead started manually keeping a list of extensions I want, not including any dependencies, so the dependencies can be resolved by the script according to the dep files for the new TC version. Keeping extensions that I've made myself complicates matters though.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12589
Re: Script to download extensions+dependencies on other Linux distros
« Reply #67 on: February 19, 2026, 01:12:08 AM »
Hi CNK
That was just an example of what can be done.
... you then include dependency extensions such as ones named something like 'fancylib3.tcz' which no longer exists in the newer TC repo where everything has been updated to use 'fancylib4.tcz' or something else. ...
That's where the Log.txt file comes in. It keeps a record of those
failures as a trouble shooting aid.

The reason I originally created the script was to allow someone to download
extensions and their dependencies from specific repos regardless of which
version of Linux they were running.


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12589
Re: Script to download extensions+dependencies on other Linux distros
« Reply #68 on: February 19, 2026, 01:29:10 AM »
Hi GNUser
A couple more upgrades.
The TC version and ARCH can now be included in the command line.
The Usage message has been updated to reflect this:
Code: [Select]
FetchExt.sh Version 0.9 Feb 18, 2026

Fetches the extension(s) and its dependencies. Extension is case sensitive.

Usage:

        FetchExt.sh [ TCn ] [ ARCH ] Extension Extension Extension

        FetchExt.sh info        Displays the list of available extensions.

        FetchExt.sh Log         Displays the Log.txt file (if it exists).

        See the User variables section to select the version and architecture.
        Current settings are  TC=17    ARCH=x86

        Or, you can select either or both of those settings at the commandline.

        Example:
                FetchExt.sh TC9 armv6 Extension Extension Extension
       
        Note about ARCH:
        Up to TC14,  options are  x86  x86_64  armv6  armv7  armv7l  aarch64
        TC15 and up, options are  x86  x86_64  armhf  aarch64

There was also a bug. If you changed the repo you were using, and info.lst
was less than an hour old, it would fail on kernel modules because it no
longer matched the repo. So I added a test to see if info.lst matches the repo:
1. I grep the info.lst file for the first kernel module in the list.
2. Then I use  wget -q --spider  to see if that file exists in the repo.
3. If not, delete info.lst. That triggers a fresh download.

I've attached the updated Fetch.sh (Version 0.9 Feb 18, 2026).
The current version of ShowErrors.sh is also attached to keep them in the same post.

Offline CNK

  • Wiki Author
  • Sr. Member
  • *****
  • Posts: 416
Re: Script to download extensions+dependencies on other Linux distros
« Reply #69 on: February 19, 2026, 01:46:25 AM »
The reason I originally created the script was to allow someone to download
extensions and their dependencies from specific repos regardless of which
version of Linux they were running.

Yes and thanks. I happen to find it easier to do upgrades to my main TC installation from another system, so the new TC version can be booted up with everything ready the first time. Your script helps a lot with that.