Riporto qui la nuova patch:
Codice: Seleziona tutto
--- pkgtool 2007-08-13 18:55:00.000000000 +0200
+++ pkgtool.test 2007-08-13 18:54:45.000000000 +0200
@@ -1,5 +1,14 @@
#!/bin/sh
#
+# Unofficial modified version of pkgtool made by Gabriele Inghirami
+# <suonodelsilenzio aA-tT tiscalinet D0_T it> on August 13, 2007
+# to solve a bug with Remove and View when there is big number of
+# installed packages.
+# Please, look at www.slackware.org to see if Patrick Volkerding
+# has released a more recent fixed official version of pkgtool.
+# This modified version is intended only for temporary use at you own
+# risk at the same conditions and with the same disclaimer written below!
+#
# Copyright 1993, 1994, 1995, 1996, 1997,
# 1998, 1999 Patrick Volkerding, Moorhead, MN USA
# Copyright 2001, 2004 Slackware Linux, Inc., Concord, CA USA
@@ -103,7 +112,7 @@
}
remove_packages() {
- for pkg_name in $*
+ for pkg_name in $(cat $TMP/return | tr -d "\042")
do
if [ -r $ADM_DIR/packages/$pkg_name ]; then
dialog --title "PACKAGE REMOVAL IN PROGRESS" --cr-wrap --infobox \
@@ -123,6 +132,30 @@
done
}
+create_list_of_installed_packages()
+{
+ FILES=`ls $ADM_DIR/packages`
+ if [ -n "$FILES" ]; then
+ cd $ADM_DIR/packages
+ { grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \
+ | sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g
+ s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" "View information about package \1" \\/;p' > $TMP/list_of_installed_packages \
+
+ fi
+}
+
+ create_list_of_files_to_remove ()
+{
+FILES=`ls $ADM_DIR/packages`
+ if [ -n "$FILES" ]; then
+ cd $ADM_DIR/packages
+ { grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \
+ | sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g
+ s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" off "Select\/Unselect removing package \1" \\/;p' > $TMP/temporary_list \
+
+ fi
+}
+
# Here, we read the list of arguments passed to the pkgtool script.
if [ $# -gt 0 ]; then # there are arguments to the command
while [ $# -gt 0 ]; do
@@ -195,21 +228,17 @@
rm -f $TMP/return $TMP/setupscr
continue
fi # end Setup
+
if [ "$REPLY" = "View" ]; then
+create_list_of_installed_packages
DEFITEM=""
export DEFITEM
#dialog --title "SCANNING" --infobox "Please wait while \
#Pkgtool scans your system to determine which packages you have \
#installed and prepares a list for you." 0 0
(
- echo 'dialog $DEFITEM --item-help --menu "Please select the package you wish to view." 17 68 10 \'
- FILES=`ls $ADM_DIR/packages`
- if [ -n "$FILES" ]; then
- cd $ADM_DIR/packages
- { grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \
- | sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g
- s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" "View information about package \1" \\/;p'
- fi
+ echo 'dialog $DEFITEM --item-help --menu "Please select the package you wish to view." 17 68 10 \
+ --file $TMP/list_of_installed_packages \'
echo "2> $TMP/return"
) > $TMP/viewscr
while [ 0 ]; do
@@ -222,32 +251,28 @@
break
fi
done
- rm -f $TMP/return $TMP/viewscr $TMP/tmpmsg
+ rm -f $TMP/return $TMP/viewscr $TMP/tmpmsg $TMP/list_of_installed_packages
# This will clean up after most defective packages:
chmod 755 /
chmod 1777 /tmp
continue
fi
+
if [ "$REPLY" = "Remove" ]; then
#dialog --title "SCANNING" --infobox "Please wait while Pkgtool scans \
#your system to determine which packages you have installed and prepares \
#a list for you." 0 0
# end section
(
+create_list_of_files_to_remove #call the function to create a list of installed packages
cat << EOF
dialog --title "SELECT PACKAGES TO REMOVE" --item-help --checklist \
"Please select the \
packages you wish to Remove. Use the \
spacebar to select packages to delete, and the UP/DOWN arrow keys to \
-scroll up and down through the entire list." 20 75 11 \\
+scroll up and down through the entire list." 20 75 11 \
+--file $TMP/temporary_list \\
EOF
- FILES=`ls $ADM_DIR/packages`
- if [ -n "$FILES" ]; then
- cd $ADM_DIR/packages
- { grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \
- | sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g
- s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" off "Select\/Unselect removing package \1" \\/;p'
- fi
echo "2> $TMP/return"
) > $TMP/rmscript
if [ -L $LOG -o -r $LOG ]; then
@@ -258,7 +283,7 @@
chmod 700 $TMP/rmscript
export ADM_DIR;
$TMP/rmscript
- remove_packages `cat $TMP/return | tr -d "\042"`
+ remove_packages
if [ "`cat $TMP/PKGTOOL.REMOVED`" = "" ]; then
rm -f $TMP/PKGTOOL.REMOVED
dialog --title "NO PACKAGES REMOVED" --msgbox "Hit OK to return \
@@ -268,7 +293,7 @@
been removed. A complete log of the files that were removed has been created \
in $TMP: PKGTOOL.REMOVED." 0 0
fi
- rm -f $TMP/rmscript $TMP/return $TMP/tmpmsg $TMP/SeT*
+ rm -f $TMP/rmscript $TMP/return $TMP/tmpmsg $TMP/SeT* $TMP/temporary_list
chmod 755 /
chmod 1777 /tmp
# No, return to the main menu:Ho semplicemente scritto una funzione che scrive in un file temporaneo l'elenco dei pacchetti installati usando pari pari lo script fatto da Patrick e l'ho passata a dialog con l'opzione file, come già fatto l'altra volta, avendo poi cura di mettere il nome del file temporaneo fra quelli da rimuovere all'uscita da View.
Per remove_packages ho tolto la lista come argomento e ho messo il cat | tr che prepara tale lista dentro la funzione, passando ciò che produce direttamente a for, che prima pescava invece fra gli argomenti della funzione (se guardate il codice è chiarissimo, qui non sono stato molto chiaro).
La nota iniziale è per evitare confusioni con il pkgtool ufficiale.
Mi sembra che funzioni bene, comunque provate anche voi...
Il tarball è in http://www.inghi.it/download/pkgtool-test.tar.bz2.
Preparare il pacchetto con il nuovo pkgtool è banale, basta sostituirlo all'altro e lanciare lo slackbuild, aggiungendo semmai un suffisso per distinguerlo dall'originale.
Ma prima proviamolo, poi sentiamo un po' di pareri e, soprattutto, quello di Loris...
Se funziona bene, ancor prima di mettere (eventualmente!) il pacchetto su slacky, scrivo a Patrick una nuova email per segnalare l'aggiornamento.
Saluti a tutti!
