wok-current rev 25685
Add checkspace / fetchall feature for tazpkg
author | Stanislas Leduc <shann@slitaz.org> |
---|---|
date | Thu Mar 14 20:28:39 2024 +0000 (9 months ago) |
parents | a8b1ac48fc8d |
children | ece35c6e0e49 |
files | tazpkg/receipt tazpkg/stuff/checkspace tazpkg/stuff/checkspace-module.patch tazpkg/stuff/translation-fetchall.patch tazpkg/stuff/upgrade-fetch-all.patch |
line diff
1.1 --- a/tazpkg/receipt Thu Mar 14 12:45:31 2024 +0000 1.2 +++ b/tazpkg/receipt Thu Mar 14 20:28:39 2024 +0000 1.3 @@ -45,8 +45,14 @@ 1.4 1.5 # Patch for upgrade core system package first 1.6 patch -p1 < $stuff/upgrade-core-pkg.patch 1.7 + 1.8 + # Add fetchall, checkspace feature 1.9 + cp -a $stuff/checkspace modules/ 1.10 + patch -p1 < $stuff/checkspace-module.patch 1.11 + patch -p1 < $stuff/upgrade-fetch-all.patch 1.12 + patch -p1 < $stuff/translation-fetchall.patch 1.13 rm modules/upgrade.orig 1.14 - 1.15 + 1.16 sed -i 's|\. receipt|. ./receipt|' */* 1.17 make && make DESTDIR=$DESTDIR VERSION=$VERSION install 1.18 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tazpkg/stuff/checkspace Thu Mar 14 20:28:39 2024 +0000 2.3 @@ -0,0 +1,48 @@ 2.4 +#!/bin/sh 2.5 + 2.6 +export LC_ALL=C 2.7 +size=0 2.8 +result=0 2.9 +unit="Mo" 2.10 + 2.11 +size_package() 2.12 +{ 2.13 + lpkg=${1//-/\-} 2.14 + sizepkg=$(grep "^$lpkg$(printf '\t')" /var/lib/tazpkg/packages.info | awk -F "\t" '{print $7}' | awk -F' ' '{print $1}') 2.15 + sizedisk=$(grep "^$lpkg$(printf '\t')" /var/lib/tazpkg/packages.info | awk -F "\t" '{print $7}' | awk -F' ' '{print $2}') 2.16 + 2.17 + # Need both packed / unpacked size 2.18 + for tmpsize in $sizepkg $sizedisk; do 2.19 + if [ "$tmpsize" != "${tmpsize%K}" ]; then 2.20 + size=$(awk "BEGIN {print ${tmpsize%K} / 1024; exit}") 2.21 + elif [ "$tmpsize" != "${tmpsize%G}" ]; then 2.22 + size=$(awk "BEGIN {print ${tmpsize%G} * 1024; exit}") 2.23 + else 2.24 + size=${tmpsize%M} 2.25 + fi 2.26 + result=$(awk "BEGIN {print $result + $size; exit}") 2.27 + done 2.28 +} 2.29 + 2.30 +check_space() 2.31 +{ 2.32 +for pkg in $(cat "$UP_LIST"); do 2.33 + size_package $pkg 2.34 + 2.35 + # Check size of deps if not installed to avoid issue 2.36 + deps=$(grep "^$pkg$(printf '\t')" /var/lib/tazpkg/packages.info | awk -F "\t" '{print $8}') 2.37 + for dep in $deps; do 2.38 + if [ ! -d /var/lib/tazpkg/installed/$dep ]; then 2.39 + size_package $dep 2.40 + fi 2.41 + done 2.42 +done 2.43 + 2.44 +# Adjust unit for Go 2.45 +if $(echo $result | awk '{print ($1 > 1024) ? "true" : "false" }'); then 2.46 + result=$(awk "BEGIN {print $result / 1024; exit}") 2.47 + unit="Go" 2.48 +fi 2.49 + 2.50 +echo "$(printf '%0.2f' $result) $unit" 2.51 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tazpkg/stuff/checkspace-module.patch Thu Mar 14 20:28:39 2024 +0000 3.3 @@ -0,0 +1,31 @@ 3.4 +--- a/modules/upgrade 3.5 ++++ b/modules/upgrade 3.6 +@@ -16,6 +16,9 @@ 3.7 + # Get TazPkg working environment 3.8 + . @@MODULES@@/getenv 3.9 + 3.10 ++# Get TazPkg checkspace module 3.11 ++. @@MODULES@@/checkspace 3.12 ++ 3.13 + time="$(date +%s)" 3.14 + 3.15 + # Recharge packages databases (if necessary) (respects already exported "root" value) 3.16 +@@ -114,6 +122,7 @@ 3.17 + install="n" 3.18 + _ 'System is up-to-date...' 3.19 + else 3.20 ++ spaceneed=$(check_space) 3.21 + blocked_count=$(wc -m < "$blocked_counter") 3.22 + 3.23 + blocked=$(_p \ 3.24 +@@ -131,6 +139,10 @@ 3.25 + '%s installed packages scanned in %ds' "$pkgs" \ 3.26 + "<c 32>$pkgs</c>" "$time")" 3.27 + 3.28 ++emsg "$(_p \ 3.29 ++ 'You need %s free space' \ 3.30 ++ 'You need %s free space' "$spaceneed" \ 3.31 ++ "<c 32>$spaceneed</c>")" 3.32 + 3.33 + # Clean 3.34 + rm "$blocked_counter" "$tmp_up_list"
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/tazpkg/stuff/translation-fetchall.patch Thu Mar 14 20:28:39 2024 +0000 4.3 @@ -0,0 +1,26 @@ 4.4 +--- a/po/fr.po 4.5 ++++ b/po/fr.po 4.6 +@@ -1329,6 +1329,10 @@ 4.7 + msgid "Do you wish to install them now? (y/N)" 4.8 + msgstr "Voulez-vous les installer maintenant ? (o/N)" 4.9 + 4.10 ++#: modules/upgrade:151 4.11 ++msgid "Fetch all updates..." 4.12 ++msgstr "Téléchargment des mises à jour..." 4.13 ++ 4.14 + #: modules/upgrade:157 4.15 + msgid "Leaving without any upgrades installed." 4.16 + msgstr "Sortie sans avoir installé de mise à jour." 4.17 +--- a/po/tazpkg.pot 4.18 ++++ b/po/tazpkg.pot 4.19 +@@ -1314,6 +1314,10 @@ 4.20 + msgid "Do you wish to install them now? (y/N)" 4.21 + msgstr "" 4.22 + 4.23 ++#: modules/upgrade:151 4.24 ++msgid "Fetch all updates..." 4.25 ++msgstr "" 4.26 ++ 4.27 + #: modules/upgrade:157 4.28 + msgid "Leaving without any upgrades installed." 4.29 + msgstr ""
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/tazpkg/stuff/upgrade-fetch-all.patch Thu Mar 14 20:28:39 2024 +0000 5.3 @@ -0,0 +1,16 @@ 5.4 +--- a/modules/upgrade 5.5 ++++ b/modules/upgrade 5.6 +@@ -147,6 +147,13 @@ 5.7 + fi 5.8 + case "$answer" in 5.9 + 0) 5.10 ++ # Fetch all pkgs upgrade 5.11 ++ _ 'Fetch all updates...' 5.12 ++ cd $SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages 5.13 ++ for pkg in $(cat "$UP_LIST"); do 5.14 ++ tazpkg get $pkg 5.15 ++ done 5.16 ++ cd - > /dev/null 5.17 + for pkg in $(cat "$UP_LIST"); do 5.18 + echo 'y' | tazpkg -gi "$pkg" --forced #--reason="upgrade" 5.19 + done