# HG changeset patch # User Stanislas Leduc # Date 1710448119 0 # Node ID 3c2b1b2d0d5912464d6b39802a7839519d8415f4 # Parent a8b1ac48fc8d73df1e0a39ae2177ac138e6920e0 Add checkspace / fetchall feature for tazpkg diff -r a8b1ac48fc8d -r 3c2b1b2d0d59 tazpkg/receipt --- a/tazpkg/receipt Thu Mar 14 12:45:31 2024 +0000 +++ b/tazpkg/receipt Thu Mar 14 20:28:39 2024 +0000 @@ -45,8 +45,14 @@ # Patch for upgrade core system package first patch -p1 < $stuff/upgrade-core-pkg.patch + + # Add fetchall, checkspace feature + cp -a $stuff/checkspace modules/ + patch -p1 < $stuff/checkspace-module.patch + patch -p1 < $stuff/upgrade-fetch-all.patch + patch -p1 < $stuff/translation-fetchall.patch rm modules/upgrade.orig - + sed -i 's|\. receipt|. ./receipt|' */* make && make DESTDIR=$DESTDIR VERSION=$VERSION install } diff -r a8b1ac48fc8d -r 3c2b1b2d0d59 tazpkg/stuff/checkspace --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpkg/stuff/checkspace Thu Mar 14 20:28:39 2024 +0000 @@ -0,0 +1,48 @@ +#!/bin/sh + +export LC_ALL=C +size=0 +result=0 +unit="Mo" + +size_package() +{ + lpkg=${1//-/\-} + sizepkg=$(grep "^$lpkg$(printf '\t')" /var/lib/tazpkg/packages.info | awk -F "\t" '{print $7}' | awk -F' ' '{print $1}') + sizedisk=$(grep "^$lpkg$(printf '\t')" /var/lib/tazpkg/packages.info | awk -F "\t" '{print $7}' | awk -F' ' '{print $2}') + + # Need both packed / unpacked size + for tmpsize in $sizepkg $sizedisk; do + if [ "$tmpsize" != "${tmpsize%K}" ]; then + size=$(awk "BEGIN {print ${tmpsize%K} / 1024; exit}") + elif [ "$tmpsize" != "${tmpsize%G}" ]; then + size=$(awk "BEGIN {print ${tmpsize%G} * 1024; exit}") + else + size=${tmpsize%M} + fi + result=$(awk "BEGIN {print $result + $size; exit}") + done +} + +check_space() +{ +for pkg in $(cat "$UP_LIST"); do + size_package $pkg + + # Check size of deps if not installed to avoid issue + deps=$(grep "^$pkg$(printf '\t')" /var/lib/tazpkg/packages.info | awk -F "\t" '{print $8}') + for dep in $deps; do + if [ ! -d /var/lib/tazpkg/installed/$dep ]; then + size_package $dep + fi + done +done + +# Adjust unit for Go +if $(echo $result | awk '{print ($1 > 1024) ? "true" : "false" }'); then + result=$(awk "BEGIN {print $result / 1024; exit}") + unit="Go" +fi + +echo "$(printf '%0.2f' $result) $unit" +} diff -r a8b1ac48fc8d -r 3c2b1b2d0d59 tazpkg/stuff/checkspace-module.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpkg/stuff/checkspace-module.patch Thu Mar 14 20:28:39 2024 +0000 @@ -0,0 +1,31 @@ +--- a/modules/upgrade ++++ b/modules/upgrade +@@ -16,6 +16,9 @@ + # Get TazPkg working environment + . @@MODULES@@/getenv + ++# Get TazPkg checkspace module ++. @@MODULES@@/checkspace ++ + time="$(date +%s)" + + # Recharge packages databases (if necessary) (respects already exported "root" value) +@@ -114,6 +122,7 @@ + install="n" + _ 'System is up-to-date...' + else ++ spaceneed=$(check_space) + blocked_count=$(wc -m < "$blocked_counter") + + blocked=$(_p \ +@@ -131,6 +139,10 @@ + '%s installed packages scanned in %ds' "$pkgs" \ + "$pkgs" "$time")" + ++emsg "$(_p \ ++ 'You need %s free space' \ ++ 'You need %s free space' "$spaceneed" \ ++ "$spaceneed")" + + # Clean + rm "$blocked_counter" "$tmp_up_list" diff -r a8b1ac48fc8d -r 3c2b1b2d0d59 tazpkg/stuff/translation-fetchall.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpkg/stuff/translation-fetchall.patch Thu Mar 14 20:28:39 2024 +0000 @@ -0,0 +1,26 @@ +--- a/po/fr.po ++++ b/po/fr.po +@@ -1329,6 +1329,10 @@ + msgid "Do you wish to install them now? (y/N)" + msgstr "Voulez-vous les installer maintenant ? (o/N)" + ++#: modules/upgrade:151 ++msgid "Fetch all updates..." ++msgstr "Téléchargment des mises à jour..." ++ + #: modules/upgrade:157 + msgid "Leaving without any upgrades installed." + msgstr "Sortie sans avoir installé de mise à jour." +--- a/po/tazpkg.pot ++++ b/po/tazpkg.pot +@@ -1314,6 +1314,10 @@ + msgid "Do you wish to install them now? (y/N)" + msgstr "" + ++#: modules/upgrade:151 ++msgid "Fetch all updates..." ++msgstr "" ++ + #: modules/upgrade:157 + msgid "Leaving without any upgrades installed." + msgstr "" diff -r a8b1ac48fc8d -r 3c2b1b2d0d59 tazpkg/stuff/upgrade-fetch-all.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpkg/stuff/upgrade-fetch-all.patch Thu Mar 14 20:28:39 2024 +0000 @@ -0,0 +1,16 @@ +--- a/modules/upgrade ++++ b/modules/upgrade +@@ -147,6 +147,13 @@ + fi + case "$answer" in + 0) ++ # Fetch all pkgs upgrade ++ _ 'Fetch all updates...' ++ cd $SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages ++ for pkg in $(cat "$UP_LIST"); do ++ tazpkg get $pkg ++ done ++ cd - > /dev/null + for pkg in $(cat "$UP_LIST"); do + echo 'y' | tazpkg -gi "$pkg" --forced #--reason="upgrade" + done