WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Proposal for upgrading .tcz on .tcz.dep changed  (Read 8638 times)

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Proposal for upgrading .tcz on .tcz.dep changed
« on: March 22, 2023, 03:55:04 PM »
Hi Core,

The changes to .tcz.dep files are not so rare. The dark side of changing of the .tcz.dep file without changing of the corresponding .tcz is that tce-update will not take care of such change. I want to propose the (simple?) workaround  for this issue/feature.

The price to be paid is adding 2 lines to tce-update in upgrade() function:

extend
Code: [Select]
        REPO=`grep -w " $TARGET" md5.db`
to
Code: [Select]
        REPO=`grep -w " $TARGET" md5.db`
        REPO_DEP=`grep -w " $TARGET".dep md5.db`

and extend
Code: [Select]
                                echo "$REPO" > "$TARGET".md5.txt
to
Code: [Select]
                                echo "$REPO" > "$TARGET".md5.txt
                                echo "$REPO_DEP" >> "$TARGET".md5.txt

Such change seems to work with all the extensions done in the usual way - REPO_DEP variable will be empty. But in case .tcz.md5.txt file will be created by the extension's maintainer with
Code: [Select]
md5sum some.tcz some.tcz.dep > some.tcz.md5.txt
then it seem to contain information about md5sums of extension itself and its tcz.dep file too and will trigger extension upgrade in case .tcz.dep will be changed even if the extension itself stay unchanged.
If maintainer use traditional
Code: [Select]
md5sum some.tcz > some.tcz.md5.txt
everything works as usual.

This idea is not tested, but if it will be encountered worth spending some time - it would be nice.

What's Your opinion?

Have a nice Core!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11330
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #1 on: March 22, 2023, 05:08:57 PM »
Hi jazzbiker
In the  Apps  GUI:
Click  Apps->Maintenance->Dependencies And Deletions
The  Apps  button will now say  Dependencies.
Now try:
Dependencies->Update .dep files
and:
Dependencies->Fetch Missing Dependencies

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #2 on: March 22, 2023, 06:27:12 PM »
Thanks, Rich!
I didn't know this tip because I rarely use GUI Apps, almost never, if to be correct. Of course it is nice application and as we can see has some functionality absent in the CLI tce-* suite.

Let me summarize the steps to obtain guaranteed update:

1. GUI Apps -> Maintenance -> Dependencies and Deletions
2. GUI Dependencies -> Update .dep files
3. GUI Dependencies -> Fetch Missing Dependencies
4. GUI Dependencies -> Exit Dependency Check
5a. GUI Apps -> Maintenance -> Check for Updates
or
5b. tce-update

Right?

Want to notice that steps 2 and 3 are not very fast, maybe they may be described as the slow ones.
Is all the .dep database scanned during these steps execution?

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1386
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #3 on: March 22, 2023, 07:29:51 PM »
Hi, jazzbiker. I also don't use the Apps GUI. Many moons ago Rich gave me the CLI commands necessary, in correct order, to guarantee a full update. I put the commands into a script which I called update-everything

The script looks like this:

Code: [Select]
#!/bin/sh

echo "Building package database..."
tce-audit builddb

echo "Downloading fresh .dep files..."
tce-audit updatedeps

echo "Looking for missing dependencies..."
tce-audit fetchmissing

echo "Updating extensions..."
tce-update

I wish you a happy Core!

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #4 on: March 22, 2023, 07:47:03 PM »
Hi GNUser,
TinyCore makes me happier, it's true :-) Thank You for this reciept. Hope Rich will not put some awfull curses on You for propagating such esoteric knowledge among the ignoramuses ;-)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11330
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #5 on: March 22, 2023, 08:52:12 PM »
Hi jazzbiker
... Hope Rich will not put some awfull curses on You for propagating such esoteric knowledge among the ignoramuses ;-)
Are you kidding? I'm glad GNUser remembered it when I didn't.  ;D

aus9

  • Guest
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #6 on: March 23, 2023, 09:50:17 AM »
thankyou all for this post.

at the risk of pretending I know something about Apps,
remove any md5.txt for private extensions like
mylocale or repack of large TCEs like some firmware
or private updates that you plan to submit etc ( or not in case the license is too restricted etc )

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1386
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #7 on: March 23, 2023, 10:10:12 AM »
Hi aus9. Yes, removing the md5.txt file is easiest way to keep custom extensions untouched during extension updates. It's also an easy way of marking which extensions are custom/private.

I even have this trivial script called no-md5, which shows me which of the extensions in tcedir/optional directories are custom  :)

Code: [Select]
#!/bin/sh

cd /etc/sysconfig/tcedir/optional
for file in *.tcz; do [ ! -e ${file}.md5.txt ] && echo $file; done
« Last Edit: March 23, 2023, 10:11:57 AM by GNUser »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #8 on: March 23, 2023, 12:07:29 PM »
Continuing the topic. Initial post was just an idea - make tce-update handle .tcz.md5.txt files containing both .tcz and .tcz.dep sums. Proposed in the initial post workaround was wrong. Here is the next attempt. Attached tce-update supposed to provide the handling of extended .tcz.md5.txt files. It is tested updating the working TC13 x86 system - successfully.

Here is the diff:
Code: [Select]
--- tce-update.orig     2022-05-08 15:39:05.000000000 +0300
+++ tce-update  2023-03-23 17:24:42.618946654 +0200
@@ -16,6 +16,7 @@
 fetch(){
        [ -f "$1" ] && rm -f "$1"
        wget -cq "$MIRROR"/"$1"
+       wget -cq "$MIRROR"/"$1".dep
 }
 fetchzsync(){
        [ -f "$1" ] && rm -f "$1"
@@ -23,13 +24,14 @@
                rm -f "$1".zs-old
        else
                wget -cq "$MIRROR"/"$1" # Either there was no zsync file on the server, or it failed
+               wget -cq "$MIRROR"/"$1".dep
        fi
 }

 chkMd5Only(){
        MYMD5=`cat "$F"`
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                [ "$MYMD5" == "$REPO" ] ||  echo $(basename "${F%.md5.txt}")
        else
@@ -37,9 +39,18 @@
        fi
 }

+slice(){
+        while [ "$*" ]
+        do
+                  echo $1"  "$2
+                  shift
+                  shift
+        done
+}
+
 upgrade(){
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                MYMD5=`cat "$F"`
                if [ "$MYMD5" != "$REPO" ]; then
@@ -52,11 +63,10 @@
                                else
                                        fetch "$TARGET" 2>/dev/null
                                fi
-                               echo "$REPO" > "$TARGET".md5.txt
+                               slice $REPO > "$TARGET".md5.txt
                                md5sum -cs "$TARGET".md5.txt
                                if [ "$?" == 0 ]; then
-                                       fetch "$TARGET".dep 2>/dev/null
-                                       if [ "$?" == 0 ]; then
+                                       if [ -f /tmp/"$TARGET".dep ]; then
                                                dep_vars /tmp/"$TARGET".dep
                                                mv /tmp/"$TARGET".dep "$TARGET_DIR"/.
                                        fi
@@ -86,7 +96,7 @@
        for F in $DEPS; do
                for TARGET in `cat "$F"`; do
                        if [ ! -f "$UPGRADE_DIR"/"$TARGET" ] && [ ! -f "$UPGRADE_DIR"/upgrade/"$TARGET" ]; then
-                               REPO=`grep -w "$TARGET" md5.db`
+                               REPO=`grep " $TARGET" md5.db`
                                if [ -n "$REPO" ]; then
                                        echo -n  "Fetching required dependency: $TARGET "
                                        if [ -n "$USEZSYNC" ]; then
@@ -94,7 +104,7 @@
                                        else
                                                fetch "$TARGET" 2>/dev/null
                                        fi
-                                       echo  "$REPO"  > "$TARGET".md5.txt
+                                       slice $REPO  > "$TARGET".md5.txt
                                        md5sum -cs "$TARGET".md5.txt
                                        if [ "$?" == 0 ]; then
                                                mv /tmp/"$TARGET".md5.txt "$TARGET_DIR"/. 2>/dev/null


Some comments.
1. fetch() and fetchzsync() now load both .tcz and .tcz.dep
2. REPO variable may contain two records, that's why function slice() is used to separate them
3. "-w" option for grep is not used. Leading space in " $TARGET" allows to select both .tcz and .tcz.dep (if present)

« Last Edit: March 23, 2023, 12:36:32 PM by jazzbiker »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #9 on: March 24, 2023, 06:03:25 AM »
The next version, fixing errors and using tce-load to load missing dependencies.

Interventions into fetch() and fetchzsync() were wrong, rolled back.

The main changes are made in check_dependencies() function. Original version is able to fetch only the single level of missing dependencies. That's why I used tce-load to make this job. If dependency is missing then we can load it immediately into the tce directory, no need to use upgrade subdir.
tce-load message is redirected into separate "checkdep_errors.lst" file and is appended to the "upgrade_errors.lst" file in case tce-load fails.

Here is the diff:
Code: [Select]
--- tce-update.orig     2022-05-08 15:39:05.000000000 +0300
+++ tce-update  2023-03-24 11:28:10.086770967 +0200
@@ -29,7 +29,7 @@
 chkMd5Only(){
        MYMD5=`cat "$F"`
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                [ "$MYMD5" == "$REPO" ] ||  echo $(basename "${F%.md5.txt}")
        else
@@ -37,9 +37,18 @@
        fi
 }

+slice(){
+       while [ "$*" ]
+       do
+               echo $1"  "$2
+               shift
+               shift
+       done
+}
+
 upgrade(){
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                MYMD5=`cat "$F"`
                if [ "$MYMD5" != "$REPO" ]; then
@@ -49,14 +58,15 @@
                                echo -n  "Updating $TARGET "
                                if [ -n "$USEZSYNC" ]; then
                                        fetchzsync "$TARGET" 2>/dev/null
+                                       fetchzsync "$TARGET".dep 2>/dev/null
                                else
                                        fetch "$TARGET" 2>/dev/null
+                                       fetch "$TARGET".dep 2>/dev/null
                                fi
-                               echo "$REPO" > "$TARGET".md5.txt
+                               slice $REPO > "$TARGET".md5.txt
                                md5sum -cs "$TARGET".md5.txt
                                if [ "$?" == 0 ]; then
-                                       fetch "$TARGET".dep 2>/dev/null
-                                       if [ "$?" == 0 ]; then
+                                       if [ -f /tmp/"$TARGET".dep ]; then
                                                dep_vars /tmp/"$TARGET".dep
                                                mv /tmp/"$TARGET".dep "$TARGET_DIR"/.
                                        fi
@@ -80,37 +90,32 @@


 check_dependencies(){
-#      echo "${BLUE}Checking dependencies:${NORMAL}"
+       echo "${BLUE}Checking dependencies:${NORMAL}"
        DEPS="$(/bin/busybox find "$UPGRADE_DIR" -regex '.*\.tcz\.dep$' | sort)"
        [ -f  $TCEDIR/tcz-black.lst ] && DEPS=$(echo $DEPS | grep -v -f $TCEDIR/tcz-black.lst)
+
+       DEPS_TO_LOAD=""
+
        for F in $DEPS; do
                for TARGET in `cat "$F"`; do
-                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ] && [ ! -f "$UPGRADE_DIR"/upgrade/"$TARGET" ]; then
-                               REPO=`grep -w "$TARGET" md5.db`
-                               if [ -n "$REPO" ]; then
-                                       echo -n  "Fetching required dependency: $TARGET "
-                                       if [ -n "$USEZSYNC" ]; then
-                                               fetchzsync "$TARGET" 2>/dev/null
-                                       else
-                                               fetch "$TARGET" 2>/dev/null
-                                       fi
-                                       echo  "$REPO"  > "$TARGET".md5.txt
-                                       md5sum -cs "$TARGET".md5.txt
-                                       if [ "$?" == 0 ]; then
-                                               mv /tmp/"$TARGET".md5.txt "$TARGET_DIR"/. 2>/dev/null
-                                               mv /tmp/"$TARGET" "$TARGET_DIR"/. 2>/dev/null
-                                               UPDATED_APPS=1
-                                               echo "OK"
-                                       else
-                                               echo "Failed"
-                                               echo "Error occurred while fetching dependency: $TARGET" >> "$ERRLIST"
-                                               rm /tmp/"$TARGET".md5.txt
-                                               rm /tmp/"$TARGET"
-                                       fi
-                               fi
+                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ]; then
+                               DEPS_TO_LOAD="$DEPS_TO_LOAD $TARGET"
                        fi
                done
        done
+
+       if [ "$DEPS_TO_LOAD" ]
+       then
+               tce-load -w $DEPS_TO_LOAD 2>&1 > "$CHECKDEP_LIST"
+               if [ "$?" == 0 ]
+               then
+                       UPDATED_APPS=1
+                       echo "OK"
+               else
+                       echo "Failed"
+                       cat "$CHECKDEP_LIST" >> "$ERRLIST"
+               fi
+       fi
 }

 check_bootoptions(){
@@ -204,6 +209,8 @@
 cd /tmp
 ERRLIST="upgrade_errors.lst"
 > "$ERRLIST"
+CHECKDEP_LIST="checkdep_errors.lst"
+> "$CHECKDEP_LIST"
 UPDATED_APPS=0
 [ -e md5.db ] && rm -f md5.db
 tce-fetch.sh md5.db.gz

The side effect of using tce-load is that it uses wget to fetch extensions, and wget injects some messages directly into the console bypassing the stderr file.
 

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #10 on: March 24, 2023, 06:47:06 AM »
Once again, correcting stderr redirection in check_dependencies(), renaming of CHECKDEP_LIST (it is not errors file) and making it "local" for check_dependencies().

diff:
Code: [Select]
--- tce-update.orig     2022-05-08 15:39:05.000000000 +0300
+++ tce-update  2023-03-24 12:37:26.814252041 +0200
@@ -17,6 +17,7 @@
        [ -f "$1" ] && rm -f "$1"
        wget -cq "$MIRROR"/"$1"
 }
+
 fetchzsync(){
        [ -f "$1" ] && rm -f "$1"
        if zsync -i "$UPGRADE_DIR"/"$1" -q "$MIRROR"/"$1".zsync; then
@@ -29,7 +30,7 @@
 chkMd5Only(){
        MYMD5=`cat "$F"`
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                [ "$MYMD5" == "$REPO" ] ||  echo $(basename "${F%.md5.txt}")
        else
@@ -37,9 +38,18 @@
        fi
 }

+slice(){
+       while [ "$*" ]
+       do
+               echo $1"  "$2
+               shift
+               shift
+       done
+}
+
 upgrade(){
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                MYMD5=`cat "$F"`
                if [ "$MYMD5" != "$REPO" ]; then
@@ -49,14 +59,15 @@
                                echo -n  "Updating $TARGET "
                                if [ -n "$USEZSYNC" ]; then
                                        fetchzsync "$TARGET" 2>/dev/null
+                                       fetchzsync "$TARGET".dep 2>/dev/null
                                else
                                        fetch "$TARGET" 2>/dev/null
+                                       fetch "$TARGET".dep 2>/dev/null
                                fi
-                               echo "$REPO" > "$TARGET".md5.txt
+                               slice $REPO > "$TARGET".md5.txt
                                md5sum -cs "$TARGET".md5.txt
                                if [ "$?" == 0 ]; then
-                                       fetch "$TARGET".dep 2>/dev/null
-                                       if [ "$?" == 0 ]; then
+                                       if [ -f /tmp/"$TARGET".dep ]; then
                                                dep_vars /tmp/"$TARGET".dep
                                                mv /tmp/"$TARGET".dep "$TARGET_DIR"/.
                                        fi
@@ -80,37 +91,34 @@


 check_dependencies(){
-#      echo "${BLUE}Checking dependencies:${NORMAL}"
+       CHECKDEP_LIST="checkdep.lst"
+       > "$CHECKDEP_LIST"
+       echo "${BLUE}Checking dependencies:${NORMAL}"
        DEPS="$(/bin/busybox find "$UPGRADE_DIR" -regex '.*\.tcz\.dep$' | sort)"
        [ -f  $TCEDIR/tcz-black.lst ] && DEPS=$(echo $DEPS | grep -v -f $TCEDIR/tcz-black.lst)
+
+       DEPS_TO_LOAD=""
+
        for F in $DEPS; do
                for TARGET in `cat "$F"`; do
-                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ] && [ ! -f "$UPGRADE_DIR"/upgrade/"$TARGET" ]; then
-                               REPO=`grep -w "$TARGET" md5.db`
-                               if [ -n "$REPO" ]; then
-                                       echo -n  "Fetching required dependency: $TARGET "
-                                       if [ -n "$USEZSYNC" ]; then
-                                               fetchzsync "$TARGET" 2>/dev/null
-                                       else
-                                               fetch "$TARGET" 2>/dev/null
-                                       fi
-                                       echo  "$REPO"  > "$TARGET".md5.txt
-                                       md5sum -cs "$TARGET".md5.txt
-                                       if [ "$?" == 0 ]; then
-                                               mv /tmp/"$TARGET".md5.txt "$TARGET_DIR"/. 2>/dev/null
-                                               mv /tmp/"$TARGET" "$TARGET_DIR"/. 2>/dev/null
-                                               UPDATED_APPS=1
-                                               echo "OK"
-                                       else
-                                               echo "Failed"
-                                               echo "Error occurred while fetching dependency: $TARGET" >> "$ERRLIST"
-                                               rm /tmp/"$TARGET".md5.txt
-                                               rm /tmp/"$TARGET"
-                                       fi
-                               fi
+                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ]; then
+                               DEPS_TO_LOAD="$DEPS_TO_LOAD $TARGET"
                        fi
                done
        done
+
+       if [ "$DEPS_TO_LOAD" ]
+       then
+               tce-load -w $DEPS_TO_LOAD > "$CHECKDEP_LIST"
+               if [ "$?" == 0 ]
+               then
+                       UPDATED_APPS=1
+                       echo "OK"
+               else
+                       echo "Failed"
+                       cat "$CHECKDEP_LIST" >> "$ERRLIST"
+               fi
+       fi
 }

 check_bootoptions(){
« Last Edit: March 24, 2023, 07:06:01 AM by jazzbiker »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #11 on: March 24, 2023, 07:31:32 AM »
Correction in check_dependencies(): only upgrade/*.dep files are processed.

diff:
Code: [Select]
--- tce-update.orig     2022-05-08 15:39:05.000000000 +0300
+++ tce-update  2023-03-24 13:24:18.015689122 +0200
@@ -17,6 +17,7 @@
        [ -f "$1" ] && rm -f "$1"
        wget -cq "$MIRROR"/"$1"
 }
+
 fetchzsync(){
        [ -f "$1" ] && rm -f "$1"
        if zsync -i "$UPGRADE_DIR"/"$1" -q "$MIRROR"/"$1".zsync; then
@@ -29,7 +30,7 @@
 chkMd5Only(){
        MYMD5=`cat "$F"`
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                [ "$MYMD5" == "$REPO" ] ||  echo $(basename "${F%.md5.txt}")
        else
@@ -37,9 +38,18 @@
        fi
 }

+slice(){
+       while [ "$*" ]
+       do
+               echo $1"  "$2
+               shift
+               shift
+       done
+}
+
 upgrade(){
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                MYMD5=`cat "$F"`
                if [ "$MYMD5" != "$REPO" ]; then
@@ -49,14 +59,15 @@
                                echo -n  "Updating $TARGET "
                                if [ -n "$USEZSYNC" ]; then
                                        fetchzsync "$TARGET" 2>/dev/null
+                                       fetchzsync "$TARGET".dep 2>/dev/null
                                else
                                        fetch "$TARGET" 2>/dev/null
+                                       fetch "$TARGET".dep 2>/dev/null
                                fi
-                               echo "$REPO" > "$TARGET".md5.txt
+                               slice $REPO > "$TARGET".md5.txt
                                md5sum -cs "$TARGET".md5.txt
                                if [ "$?" == 0 ]; then
-                                       fetch "$TARGET".dep 2>/dev/null
-                                       if [ "$?" == 0 ]; then
+                                       if [ -f /tmp/"$TARGET".dep ]; then
                                                dep_vars /tmp/"$TARGET".dep
                                                mv /tmp/"$TARGET".dep "$TARGET_DIR"/.
                                        fi
@@ -80,37 +91,34 @@


 check_dependencies(){
-#      echo "${BLUE}Checking dependencies:${NORMAL}"
-       DEPS="$(/bin/busybox find "$UPGRADE_DIR" -regex '.*\.tcz\.dep$' | sort)"
+       echo "${BLUE}Checking dependencies:${NORMAL}"
+       DEPS="$(/bin/busybox find "$TARGET_DIR" -regex '.*\.tcz\.dep$' | sort)"
        [ -f  $TCEDIR/tcz-black.lst ] && DEPS=$(echo $DEPS | grep -v -f $TCEDIR/tcz-black.lst)
+
+       DEPS_TO_LOAD=""
+
        for F in $DEPS; do
                for TARGET in `cat "$F"`; do
-                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ] && [ ! -f "$UPGRADE_DIR"/upgrade/"$TARGET" ]; then
-                               REPO=`grep -w "$TARGET" md5.db`
-                               if [ -n "$REPO" ]; then
-                                       echo -n  "Fetching required dependency: $TARGET "
-                                       if [ -n "$USEZSYNC" ]; then
-                                               fetchzsync "$TARGET" 2>/dev/null
-                                       else
-                                               fetch "$TARGET" 2>/dev/null
-                                       fi
-                                       echo  "$REPO"  > "$TARGET".md5.txt
-                                       md5sum -cs "$TARGET".md5.txt
-                                       if [ "$?" == 0 ]; then
-                                               mv /tmp/"$TARGET".md5.txt "$TARGET_DIR"/. 2>/dev/null
-                                               mv /tmp/"$TARGET" "$TARGET_DIR"/. 2>/dev/null
-                                               UPDATED_APPS=1
-                                               echo "OK"
-                                       else
-                                               echo "Failed"
-                                               echo "Error occurred while fetching dependency: $TARGET" >> "$ERRLIST"
-                                               rm /tmp/"$TARGET".md5.txt
-                                               rm /tmp/"$TARGET"
-                                       fi
-                               fi
+                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ]; then
+                               DEPS_TO_LOAD="$DEPS_TO_LOAD $TARGET"
                        fi
                done
        done
+
+       CHECKDEP_LIST="checkdep.lst"
+
+       if [ "$DEPS_TO_LOAD" ]
+       then
+               tce-load -w $DEPS_TO_LOAD > "$CHECKDEP_LIST"
+               if [ "$?" == 0 ]
+               then
+                       UPDATED_APPS=1
+                       echo "OK"
+               else
+                       echo "Failed"
+                       cat "$CHECKDEP_LIST" >> "$ERRLIST"
+               fi
+       fi
 }

 check_bootoptions(){

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #12 on: March 25, 2023, 07:25:54 AM »
CHECKDEP_LIST is "global" again and is cleared per every tce-update run.
Some cleaning: no need to set UPDATED_APPS in check_dependencies()

diff:
Code: [Select]
--- tce-update.orig
+++ tce-update
@@ -17,6 +17,7 @@
        [ -f "$1" ] && rm -f "$1"
        wget -cq "$MIRROR"/"$1"
 }
+
 fetchzsync(){
        [ -f "$1" ] && rm -f "$1"
        if zsync -i "$UPGRADE_DIR"/"$1" -q "$MIRROR"/"$1".zsync; then
@@ -29,7 +30,7 @@
 chkMd5Only(){
        MYMD5=`cat "$F"`
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                [ "$MYMD5" == "$REPO" ] ||  echo $(basename "${F%.md5.txt}")
        else
@@ -37,9 +38,18 @@
        fi
 }

+slice(){
+       while [ "$*" ]
+       do
+               echo $1"  "$2
+               shift
+               shift
+       done
+}
+
 upgrade(){
        TARGET="$(getbasefile "$F" 2)"
-       REPO=`grep -w " $TARGET" md5.db`
+       REPO=`grep " $TARGET" md5.db`
        if [ -n "$REPO" ]; then
                MYMD5=`cat "$F"`
                if [ "$MYMD5" != "$REPO" ]; then
@@ -49,14 +59,15 @@
                                echo -n  "Updating $TARGET "
                                if [ -n "$USEZSYNC" ]; then
                                        fetchzsync "$TARGET" 2>/dev/null
+                                       fetchzsync "$TARGET".dep 2>/dev/null
                                else
                                        fetch "$TARGET" 2>/dev/null
+                                       fetch "$TARGET".dep 2>/dev/null
                                fi
-                               echo "$REPO" > "$TARGET".md5.txt
+                               slice $REPO > "$TARGET".md5.txt
                                md5sum -cs "$TARGET".md5.txt
                                if [ "$?" == 0 ]; then
-                                       fetch "$TARGET".dep 2>/dev/null
-                                       if [ "$?" == 0 ]; then
+                                       if [ -f /tmp/"$TARGET".dep ]; then
                                                dep_vars /tmp/"$TARGET".dep
                                                mv /tmp/"$TARGET".dep "$TARGET_DIR"/.
                                        fi
@@ -80,37 +91,27 @@


 check_dependencies(){
-#      echo "${BLUE}Checking dependencies:${NORMAL}"
-       DEPS="$(/bin/busybox find "$UPGRADE_DIR" -regex '.*\.tcz\.dep$' | sort)"
+       echo "${BLUE}Checking dependencies:${NORMAL}"
+       DEPS="$(/bin/busybox find "$TARGET_DIR" -regex '.*\.tcz\.dep$' | sort)"
        [ -f  $TCEDIR/tcz-black.lst ] && DEPS=$(echo $DEPS | grep -v -f $TCEDIR/tcz-black.lst)
+
+       DEPS_TO_LOAD=""
+
        for F in $DEPS; do
                for TARGET in `cat "$F"`; do
-                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ] && [ ! -f "$UPGRADE_DIR"/upgrade/"$TARGET" ]; then
-                               REPO=`grep -w "$TARGET" md5.db`
-                               if [ -n "$REPO" ]; then
-                                       echo -n  "Fetching required dependency: $TARGET "
-                                       if [ -n "$USEZSYNC" ]; then
-                                               fetchzsync "$TARGET" 2>/dev/null
-                                       else
-                                               fetch "$TARGET" 2>/dev/null
-                                       fi
-                                       echo  "$REPO"  > "$TARGET".md5.txt
-                                       md5sum -cs "$TARGET".md5.txt
-                                       if [ "$?" == 0 ]; then
-                                               mv /tmp/"$TARGET".md5.txt "$TARGET_DIR"/. 2>/dev/null
-                                               mv /tmp/"$TARGET" "$TARGET_DIR"/. 2>/dev/null
-                                               UPDATED_APPS=1
-                                               echo "OK"
-                                       else
-                                               echo "Failed"
-                                               echo "Error occurred while fetching dependency: $TARGET" >> "$ERRLIST"
-                                               rm /tmp/"$TARGET".md5.txt
-                                               rm /tmp/"$TARGET"
-                                       fi
-                               fi
+                       if [ ! -f "$UPGRADE_DIR"/"$TARGET" ]; then
+                               DEPS_TO_LOAD="$DEPS_TO_LOAD $TARGET"
                        fi
                done
        done
+
+       if [ "$DEPS_TO_LOAD" ] && ! tce-load -w $DEPS_TO_LOAD > "$CHECKDEP_LIST"
+       then
+               echo "Failed"
+               cat "$CHECKDEP_LIST" >> "$ERRLIST"
+       else
+               echo "OK"
+       fi
 }

 check_bootoptions(){
@@ -204,6 +205,8 @@
 cd /tmp
 ERRLIST="upgrade_errors.lst"
 > "$ERRLIST"
+CHECKDEP_LIST="checkdep.lst"
+> "$CHECKDEP_LIST"
 UPDATED_APPS=0
 [ -e md5.db ] && rm -f md5.db
 tce-fetch.sh md5.db.gz

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #13 on: March 26, 2023, 10:02:28 AM »
... I put the commands into a script which I called update-everything ...

I've made in the same way, and everything is nice but execution time. Something like 1m50s against 15s for tce-update. Of course it is not the critical time, but difference is quite significant, while my tce13/optional is not the biggest one I suppose. Still it is correct way to update the system.

Thanks You and Rich!

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Proposal for upgrading .tcz on .tcz.dep changed
« Reply #14 on: March 26, 2023, 08:58:33 PM »
In the http://forum.tinycorelinux.net/index.php/topic,26164.0.html thread GNUser arose the question about the behaviour of squashfs tools, concerning resquashing causing the md5 sum change. Later in the same thread Rich explains why it is natural and correct. In appliance to my thread subject, this squashfs tools fature can be used for signaling to tce tools the necessity of refreshing some extension even without changing its content.

In case the .dep file of some extension has changed the maintainer of the extension resquash an extension, this action leads to md5 sum change and triggers extension upgade (both .tcz and .tcz.dep) by tce-update without the need to use tce-audit functions.

I think the thread can be marked as solved, thanks Rich, GNUser and aus9!

Have a nice Core!
« Last Edit: March 26, 2023, 09:03:44 PM by jazzbiker »