WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: script to add custom extensions to local mirror  (Read 2537 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1528
script to add custom extensions to local mirror
« on: March 24, 2023, 04:56:16 PM »
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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11666
Re: script to add custom extensions to local mirror
« Reply #1 on: March 24, 2023, 05:08:03 PM »
Hi GNUser
Is the  length  command really required?:
Code: [Select]
j = length(SARRAY); for (i = 1; i <= j; i++)
Isn't  NR (or FNR)  already set to the correct value?:
Code: [Select]
for (i = 1; i <= NR; i++)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1528
Re: script to add custom extensions to local mirror
« Reply #2 on: March 24, 2023, 06:51:16 PM »
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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11666
Re: script to add custom extensions to local mirror
« Reply #3 on: March 24, 2023, 08:11:43 PM »
Hi GNUser
... Please feel free to edit the script in post #1 accordingly.
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.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1528
Re: script to add custom extensions to local mirror
« Reply #4 on: March 24, 2023, 08:25:46 PM »
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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11666
Re: script to add custom extensions to local mirror
« Reply #5 on: March 24, 2023, 10:19:08 PM »
Hi GNUser
... What do you do in real life? ...
Let's see, after I dropped out of college, I worked as a technician debugging the circuits
engineers designed at several companies. Eventually I was promoted to engineer and
and got to debug my own designs. Taught myself assembly language and did some work
writing software for 8085 based measurement equipment. I taught myself C just for the
fun of it. Later it proved useful when I got involved working on an embedded system that
was programmed in C. Also dabbled with single chip micros (PIC16C55, 16C71, Signetics
87C750, 87C752, etc.). I retired in 2000 and life is simpler now.

Quote
... Retired professor? :) ...
Hardly. Though I still have memories of teachers whose answer to "I don't understand" was
"Read the textbook". A byproduct of their poor attitude is if someone wants to learn something
and I have something to offer, I do my best to help them out.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1528
Re: script to add custom extensions to local mirror
« Reply #6 on: March 25, 2023, 01:57:37 AM »
Hi Rich. Thank you for sharing your background. I have often wondered about it. Given that you always seem able to view problems from all levels--from high all the way down to electrons--I'm not too surprised that you are experienced in C, assembly language, and embedded circuits.

if someone wants to learn something and I have something to offer, I do my best to help them out.
You sure do, and I'm very grateful for it. Please keep it coming. One would have to be very unwilling or very incapable (or just plain foolish) not to learn something from you.

Happy hacking!

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1528
Re: script to add custom extensions to local mirror
« Reply #7 on: April 01, 2023, 09:54:03 AM »
I updated the script so that it also updates dep.db.gz. I will keep the latest version of the script at this link:

http://gnuser.ddns.net/public/add-tcz-extra

Happy hacking!