General TC > Programming & Scripting - Unofficial

script to add custom extensions to local mirror

(1/2) > >>

GNUser:
I have long dealt with this problem: I have a local mirror of TCL's official repository, which includes some custom extensions. Every time I sync my local mirror with upstream, my custom extensions are wiped away. My local metadata files (which contain information about my custom extensions) are also wiped away.

One solution would be to create two local repositories (one a TCL mirror with only official extensions, and a second one containing only custom extensions). The problem with this is that I'd have to change /opt/tcemirror back and forth on all my TCL boxes, depending on whether I want to install/upgrade official extensions or custom ones. I do not like this solution.

[An aside: Unfortunately, in TCL there is no ability to use multiple repositories concurrently à la /etc/apt/sources.list.d/ in Debian. This is in keeping with TCL's minimalism and I totally respect that.]

So, after mulling over this problem for several days, I came up with a solution.

My http server still has its usual tinycorelinux/14.x/x86_64/tcz directory. But now it also has a tinycorelinux/14.x/x86_64/tcz-extra directory (for custom extensions) and a script in my PATH called add-tcz-extra.

Now, after I sync my tcz directory with upstream, all I have to do is run add-tcz-extra on my http server. The script copies over all the *tcz* files from tcz-extra directory to tcz directory, then adds the metadata of my custom extensions back into the metadata files in the tcz directory. This allows my local mirror to stay in sync with upstream, without losing my custom extensions :)

I will attach the script here in case it is useful to anyone.

Rich:
Hi GNUser
Is the  length  command really required?:

--- Code: ---j = length(SARRAY); for (i = 1; i <= j; i++)
--- End code ---

Isn't  NR (or FNR)  already set to the correct value?:

--- Code: ---for (i = 1; i <= NR; i++)
--- End code ---

GNUser:
Hi Rich. I tested it and, of course, you are correct :)

The  j  variable is superfluous because  NR  is already set to the correct value. Please feel free to edit the script in post #1 accordingly.

Rich:
Hi GNUser

--- Quote from: GNUser on March 24, 2023, 06:51:16 PM --- ... Please feel free to edit the script in post #1 accordingly.
--- End quote ---
No need, what you wrote works too. Just wanted to point out 2 of the built in variables:
FNR   Number of records that have been read from the current file.
NR    Total number of records read from all files.

NR == FNR  when only dealing with one file.

GNUser:
Thank you, Rich. I always learn when you are around. What do you do in real life? Retired professor? :)

I have always admired  awk  but never took a deep dive. Thank you for helping me discover its incredible power (I'm talking about this, which became the sort_providesdb function in add-tcz-extra). Going forward I will give  awk  the attention and respect it deserves.

Navigation

[0] Message Index

[#] Next page

Go to full version