[alsa-devel] [PATCH 0/4] alsa-info.sh updates
Hi Takashi, This patchset mainly disables the auto-upload of alsa info by default. Comments are welcome. Thanks, Fengguang --
- the greeting dialog informs that the script collects info, waits for OK button. It affords a concrete listing of information to collect: /proc/asound/, aplay, etc. This not only shows respect for user privacy, but also serves as basic debugging tips for ALSA newbies. - when --upload option is given, the data will be automatically uploaded. - when --no-upload option is given, the data is just stored locally and quit. - when neither options are given, show a dialog to ask to upload or not. The above ideas mostly come from Takashi. CC: Takashi Iwai <tiwai@suse.de> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- utils/alsa-info.sh | 115 +++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 52 deletions(-) --- alsa-driver.orig/utils/alsa-info.sh +++ alsa-driver/utils/alsa-info.sh @@ -36,10 +36,12 @@ PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0 #Define some simple functions pbcheck(){ + [[ $UPLOAD = "no" ]] && return + if [[ -z $PASTEBIN ]]; then - [[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" NOUPLOAD="yes" PBERROR="yes" + [[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes" else - [[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" NOUPLOAD="yes" PBERROR="yes" + [[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes" fi } @@ -289,18 +291,24 @@ SNDOPTIONS=$(modprobe -c|sed -n 's/^opti PASTEBIN="" WWWSERVICE="www.alsa-project.org" -QUESTION="yes" +WELCOME="yes" PROCEED="yes" +UPLOAD="ask" REPEAT="" while [ -z "$REPEAT" ]; do REPEAT="no" case "$1" in --update|--help|--about) - QUESTION="no" + WELCOME="no" PROCEED="no" ;; + --upload) + UPLOAD="yes" + WELCOME="no" + ;; --no-upload) - NOUPLOAD="yes" + UPLOAD="no" + WELCOME="no" ;; --pastebin) PASTEBIN="yes" @@ -313,28 +321,18 @@ case "$1" in ;; --stdout) DIALOG="" - NOUPLOAD="yes" - QUESTION="no" + UPLOAD="no" + WELCOME="no" TOSTDOUT="yes" ;; esac done - + #Script header output. -if [ "$QUESTION" = "yes" ]; then -if [[ -n "$DIALOG" ]] -then -if [ -z "$NOUPLOAD" ]; then - dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nBy default, this script will AUTOMATICALLY UPLOAD your information to a $WWWSERVICE site.\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0 -else - dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0 -fi -DIALOG_EXIT_CODE=$? -if [ $DIALOG_EXIT_CODE != 0 ]; then -echo "Thank you for using the ALSA-Info Script" -exit 0; -fi +if [ "$WELCOME" = "yes" ]; then +if [[ -n "$DIALOG" ]]; then + dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --msgbox "\nThis script visits the following commands/files to collect diagnostic information about your ALSA installation and sound related hardware.\n\n lspci\n lsmod\n aplay\n amixer\n alsactl\n /proc/asound/\n /sys/class/sound/\n ~/.asoundrc (etc.)\n\nSee '$0 --help' for command line options.\n" 20 80 else echo "ALSA Information Script v $SCRIPT_VERSION" @@ -342,27 +340,8 @@ echo "--------------------------------" echo "" echo "This script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem." echo "" -if [ -z "$NOUPLOAD" ]; then -if [[ -n "$TPUT" ]]; then -tput bold -echo "By default, the collected information will be AUTOMATICALLY uploaded to a $WWWSERVICE site." -echo "If you do not wish for this to occur, run the script with the --no-upload argument" -tput sgr0 -else -echo "By default, the collected information will be AUTOMATICALLY uploaded to a $WWWSERVICE site." -echo "If you do not wish for this to occur, run the script with the --no-upload argument" -fi -echo "" -fi # NOUPLOAD -echo -n "Do you want to run this script? [y/n] : " -read -e CONFIRM -if [ "$CONFIRM" != "y" ]; then -echo "" -echo "Thank you for using the ALSA-Info Script" -exit 0; -fi -fi -fi # question +fi # dialog +fi # WELCOME #Set the output file TEMPDIR=`mktemp -p /tmp -d alsa-info.XXXXXXXXXX` @@ -609,8 +588,18 @@ then update exit ;; + --upload) + UPLOAD="yes" + withdevices + withconfigs + withaplay + withamixer + withalsactl + withlsmod + withsysfs + ;; --no-upload) - NOUPLOAD="yes" + UPLOAD="no" withdevices withconfigs withaplay @@ -681,7 +670,7 @@ then fi ;; --stdout) - NOUPLOAD="yes" + UPLOAD="no" withdevices withconfigs withaplay @@ -714,6 +703,7 @@ then echo " --with-devices (shows the device nodes in /dev/snd/)" echo "" echo " --update (check server for script updates)" + echo " --upload (upload contents to remote server)" echo " --no-upload (do not upload contents to remote server)" echo " --pastebin (use http://pastebin.ca) as remote server" echo " instead www.alsa-project.org" @@ -733,7 +723,28 @@ if [ "$PROCEED" = "no" ]; then exit 1 fi -if [ -n "$NOUPLOAD" ]; then +if [ "$UPLOAD" = "ask" ]; then + if [[ -n "$DIALOG" ]]; then + dialog --backtitle "$BGTITLE" --title "Information collected" --yes-label " UPLOAD / SHARE " --no-label " SAVE LOCALLY " --defaultno --yesno "\n\nAutomatically upload ALSA information to $WWWSERVICE?" 10 80 + DIALOG_EXIT_CODE=$? + if [ $DIALOG_EXIT_CODE != 0 ]; then + UPLOAD="no" + else + UPLOAD="yes" + fi + else + echo -n "Automatically upload ALSA information to $WWWSERVICE? [y/N] : " + read -e CONFIRM + if [ "$CONFIRM" != "y" ]; then + UPLOAD="no" + else + UPLOAD="yes" + fi + fi + +fi + +if [ "$UPLOAD" = "no" ]; then if [ -z "$TOSTDOUT" ]; then mv $FILE $NFILE || exit 1 @@ -742,23 +753,23 @@ if [ -n "$NOUPLOAD" ]; then if [[ -n $DIALOG ]] then if [[ -n $PBERROR ]]; then - dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "An error occurred while contacting the $WWWSERVICE. Your information was NOT automatically uploaded.\n\nYour ALSA information can be seen by looking in $NFILE" 10 100 + dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "An error occurred while contacting the $WWWSERVICE.\n Your information was NOT automatically uploaded.\n\nYour ALSA information is in $NFILE" 10 100 else - dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "You requested that your information was NOT automatically uploaded to the $WWWSERVICE\n\nYour ALSA information can be seen by looking in $NFILE" 10 100 + dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60 fi else echo if [[ -n $PBERROR ]]; then - echo "An error occurred while contacting the $WWWSERVICE. Your information was NOT automatically uploaded." + echo "An error occurred while contacting the $WWWSERVICE." + echo "Your information was NOT automatically uploaded." echo "" - echo "Your ALSA information can be seen by looking in $NFILE" + echo "Your ALSA information is in $NFILE" echo "" else if [ -z "$TOSTDOUT" ]; then - echo "You requested that your information was NOT automatically uploaded to the $WWWSERVICE" echo "" - echo "Your ALSA information can be seen by looking in $NFILE" + echo "Your ALSA information is in $NFILE" echo "" fi fi @@ -766,7 +777,7 @@ if [ -n "$NOUPLOAD" ]; then exit -fi # noupload +fi # UPLOAD #Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. if --
On Wed, Jul 08, 2009 at 09:07:23PM +0800, Wu, Fengguang wrote:
- the greeting dialog informs that the script collects info, waits for OK button. It affords a concrete listing of information to collect: /proc/asound/, aplay, etc. This not only shows respect for user privacy, but also serves as basic debugging tips for ALSA newbies. - when --upload option is given, the data will be automatically uploaded. - when --no-upload option is given, the data is just stored locally and quit. - when neither options are given, show a dialog to ask to upload or not.
The above ideas mostly come from Takashi.
With this patch the dialogs will look like: ┌─────────────────────────ALSA-Info script v 0.4.56────────────────────────────┐ │ │ │ This script visits the following commands/files to collect diagnostic │ │ information about your ALSA installation and sound related hardware. │ │ │ │ lspci │ │ lsmod │ │ aplay │ │ amixer │ │ alsactl │ │ /proc/asound/ │ │ /sys/class/sound/ │ │ ~/.asoundrc (etc.) │ │ │ │ See './alsa-info.sh --help' for command line options. │ │ │ │ │ ├──────────────────────────────────────────────────────────────────────────────┤ │ < OK > │ └──────────────────────────────────────────────────────────────────────────────┘ ┌───────────────────────────Information collected──────────────────────────────┐ │ │ │ │ │ Automatically upload ALSA information to www.alsa-project.org? │ │ │ │ │ │ │ ├──────────────────────────────────────────────────────────────────────────────┤ │ < UPLOAD / SHARE > < SAVE LOCALLY > │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─────────────────Information collected────────────────────┐ │ │ │ │ │ Your ALSA information is in /tmp/alsa-info.txt │ │ │ │ │ │ │ ├──────────────────────────────────────────────────────────┤ │ < OK > │ └──────────────────────────────────────────────────────────┘ Thanks, Fengguang
Redirect the "echo \t" outputs to the desired file, and avoid messing up stdio. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- utils/alsa-info.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- alsa-driver.orig/utils/alsa-info.sh +++ alsa-driver/utils/alsa-info.sh @@ -519,7 +519,10 @@ echo "!!--------------------------" >> $ echo "" >> $FILE for mod in `cat /proc/asound/modules|awk {'print $2'}`;do echo "!!Module: $mod" >> $FILE -for params in `ls $SYSFS/module/$mod/parameters/*`; do /bin/echo -ne "\t";/bin/echo "$params : `cat $params`"|sed 's:.*/::' >> $FILE;done +for params in `echo $SYSFS/module/$mod/parameters/*`; do + echo -ne "\t"; + echo "$params : `cat $params`" | sed 's:.*/::'; +done >> $FILE echo "" >> $FILE done echo "" >> $FILE --
When mv cannot overwrite target file, it will prompt and return TRUE. Add the '-f' option so that it returns FALSE when failed. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- utils/alsa-info.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- alsa-driver.orig/utils/alsa-info.sh +++ alsa-driver/utils/alsa-info.sh @@ -74,7 +74,7 @@ update() { echo "Please re-run the script" rm $SHFILE 2>/dev/null else - mv $SHFILE /tmp/alsa-info.sh || exit 1 + mv -f $SHFILE /tmp/alsa-info.sh || exit 1 echo "ALSA-Info script has been downloaded as /tmp/alsa-info.sh." echo "Please re-run the script from new location." fi @@ -92,7 +92,7 @@ update() { echo "ALSA-Info script has been updated. Please re-run it." rm $SHFILE 2>/dev/null else - mv $SHFILE /tmp/alsa-info.sh || exit 1 + mv -f $SHFILE /tmp/alsa-info.sh || exit 1 echo "ALSA-Info script has been downloaded as /tmp/alsa-info.sh." echo "Please, re-run it from new location." fi @@ -750,7 +750,7 @@ fi if [ "$UPLOAD" = "no" ]; then if [ -z "$TOSTDOUT" ]; then - mv $FILE $NFILE || exit 1 + mv -f $FILE $NFILE || exit 1 fi if [[ -n $DIALOG ]] @@ -863,7 +863,7 @@ echo "" #We couldnt find a suitable wget, so tell the user to upload manually. else - mv $FILE $NFILE || exit 1 + mv -f $FILE $NFILE || exit 1 if [[ -z $DIALOG ]] then if [[ -z $PASTEBIN ]]; then --
This merges duplicate code. The only behavior change is, we will now call withsysfs() when no options are provided. I guess this is desired info. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- utils/alsa-info.sh | 64 +++++++++++-------------------------------- 1 file changed, 17 insertions(+), 47 deletions(-) --- alsa-driver.orig/utils/alsa-info.sh +++ alsa-driver/utils/alsa-info.sh @@ -243,6 +243,16 @@ withsysfs() { fi } +withall() { + withdevices + withconfigs + withaplay + withamixer + withalsactl + withlsmod + withsysfs +} + get_alsa_library_version() { ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'` @@ -559,12 +569,7 @@ fi if [[ -z "$1" ]] then update - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod + withall pbcheck fi @@ -578,13 +583,7 @@ then case "$1" in --pastebin) update - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod - withsysfs + withall pbcheck ;; --update) @@ -593,44 +592,20 @@ then ;; --upload) UPLOAD="yes" - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod - withsysfs + withall ;; --no-upload) UPLOAD="no" - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod - withsysfs + withall ;; --debug) echo "Debugging enabled. $FILE and $TEMPDIR will not be deleted" KEEP_FILES="yes" echo "" - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod - withsysfs + withall ;; --with-all) - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod - withsysfs + withall ;; --with-aplay) withaplay @@ -674,12 +649,7 @@ then ;; --stdout) UPLOAD="no" - withdevices - withconfigs - withaplay - withamixer - withalsactl - withlsmod + withall cat $FILE rm $FILE ;; --
At Wed, 08 Jul 2009 21:07:22 +0800, Wu Fengguang wrote:
Hi Takashi,
This patchset mainly disables the auto-upload of alsa info by default.
Comments are welcome.
I'd like these changes... Anyone still against changing the default behavior not to upload? Takashi
On Thu, Jul 9, 2009 at 12:51 PM, Takashi Iwai<tiwai@suse.de> wrote:
Anyone still against changing the default behavior not to upload?
For some time the default behaviour for interactive debugging in various IRC channels has been to use --no-upload, so no, no protest from me.
On Thu, Jul 09, 2009 at 01:03:22PM -0400, Daniel Chen wrote:
On Thu, Jul 9, 2009 at 12:51 PM, Takashi Iwai<tiwai@suse.de> wrote:
Anyone still against changing the default behavior not to upload?
For some time the default behaviour for interactive debugging in various IRC channels has been to use --no-upload, so no, no protest from me.
It's also good from a general privacy point of view.
At Wed, 08 Jul 2009 21:07:22 +0800, Wu Fengguang wrote:
Hi Takashi,
This patchset mainly disables the auto-upload of alsa info by default.
I pushed the patches now. Thanks! Takashi
On Thu, Jul 16, 2009 at 05:42:09PM +0800, Takashi Iwai wrote:
At Wed, 08 Jul 2009 21:07:22 +0800, Wu Fengguang wrote:
Hi Takashi,
This patchset mainly disables the auto-upload of alsa info by default.
I pushed the patches now. Thanks!
Thank you! btw, I find it often necessary to query user for the dmesg info. How about adding dmesg to alsa-info? Thanks, Fengguang --- alsa-info.sh: add dmesg info on ALSA/HDA Add outputs: dmesg | grep -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' which should cover most ALSA HDA kernel messages. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- utils/alsa-info.sh | 44 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) --- alsa-driver.orig/utils/alsa-info.sh +++ alsa-driver/utils/alsa-info.sh @@ -243,6 +243,15 @@ withsysfs() { fi } +withdmesg() { + echo "!!ALSA/HDA dmesg" >> $FILE + echo "!!------------------" >> $FILE + echo "" >> $FILE + dmesg | grep -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' >> $FILE + echo "" >> $FILE + echo "" >> $FILE +} + withall() { withdevices withconfigs @@ -251,6 +260,7 @@ withall() { withalsactl withlsmod withsysfs + withdmesg } get_alsa_library_version() { @@ -341,15 +351,31 @@ done #Script header output. if [ "$WELCOME" = "yes" ]; then +greeting_message="\ + +This script visits the following commands/files to collect diagnostic +information about your ALSA installation and sound related hardware. + + dmesg + lspci + lsmod + aplay + amixer + alsactl + /proc/asound/ + /sys/class/sound/ + ~/.asoundrc (etc.) + +See '$0 --help' for command line options. +" if [[ -n "$DIALOG" ]]; then - dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --msgbox "\nThis script visits the following commands/files to collect diagnostic information about your ALSA installation and sound related hardware.\n\n lspci\n lsmod\n aplay\n amixer\n alsactl\n /proc/asound/\n /sys/class/sound/\n ~/.asoundrc (etc.)\n\nSee '$0 --help' for command line options.\n" 20 80 + dialog --backtitle "$BGTITLE" \ + --title "ALSA-Info script v $SCRIPT_VERSION" \ + --msgbox "$greeting_message" 20 80 else - -echo "ALSA Information Script v $SCRIPT_VERSION" -echo "--------------------------------" -echo "" -echo "This script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem." -echo "" + echo "ALSA Information Script v $SCRIPT_VERSION" + echo "--------------------------------" + echo "$greeting_message" fi # dialog fi # WELCOME @@ -619,6 +645,9 @@ then --with-devices) withdevices ;; + --with-dmesg) + withdmesg + ;; --with-configs) if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] then @@ -674,6 +703,7 @@ then echo " --with-configs (includes the output of ~/.asoundrc and" echo " /etc/asound.conf if they exist)" echo " --with-devices (shows the device nodes in /dev/snd/)" + echo " --with-dmesg (shows the ALSA/HDA kernel messages)" echo "" echo " --update (check server for script updates)" echo " --upload (upload contents to remote server)"
At Thu, 16 Jul 2009 19:24:06 +0800, Wu Fengguang wrote:
On Thu, Jul 16, 2009 at 05:42:09PM +0800, Takashi Iwai wrote:
At Wed, 08 Jul 2009 21:07:22 +0800, Wu Fengguang wrote:
Hi Takashi,
This patchset mainly disables the auto-upload of alsa info by default.
I pushed the patches now. Thanks!
Thank you!
btw, I find it often necessary to query user for the dmesg info. How about adding dmesg to alsa-info?
A good idea. Applied now. Thanks! Takashi
Thanks, Fengguang --- alsa-info.sh: add dmesg info on ALSA/HDA
Add outputs: dmesg | grep -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' which should cover most ALSA HDA kernel messages.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- utils/alsa-info.sh | 44 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-)
--- alsa-driver.orig/utils/alsa-info.sh +++ alsa-driver/utils/alsa-info.sh @@ -243,6 +243,15 @@ withsysfs() { fi }
+withdmesg() { + echo "!!ALSA/HDA dmesg" >> $FILE + echo "!!------------------" >> $FILE + echo "" >> $FILE + dmesg | grep -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' >> $FILE + echo "" >> $FILE + echo "" >> $FILE +} + withall() { withdevices withconfigs @@ -251,6 +260,7 @@ withall() { withalsactl withlsmod withsysfs + withdmesg }
get_alsa_library_version() { @@ -341,15 +351,31 @@ done
#Script header output. if [ "$WELCOME" = "yes" ]; then +greeting_message="\ + +This script visits the following commands/files to collect diagnostic +information about your ALSA installation and sound related hardware. + + dmesg + lspci + lsmod + aplay + amixer + alsactl + /proc/asound/ + /sys/class/sound/ + ~/.asoundrc (etc.) + +See '$0 --help' for command line options. +" if [[ -n "$DIALOG" ]]; then - dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --msgbox "\nThis script visits the following commands/files to collect diagnostic information about your ALSA installation and sound related hardware.\n\n lspci\n lsmod\n aplay\n amixer\n alsactl\n /proc/asound/\n /sys/class/sound/\n ~/.asoundrc (etc.)\n\nSee '$0 --help' for command line options.\n" 20 80 + dialog --backtitle "$BGTITLE" \ + --title "ALSA-Info script v $SCRIPT_VERSION" \ + --msgbox "$greeting_message" 20 80 else - -echo "ALSA Information Script v $SCRIPT_VERSION" -echo "--------------------------------" -echo "" -echo "This script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem." -echo "" + echo "ALSA Information Script v $SCRIPT_VERSION" + echo "--------------------------------" + echo "$greeting_message" fi # dialog fi # WELCOME
@@ -619,6 +645,9 @@ then --with-devices) withdevices ;; + --with-dmesg) + withdmesg + ;; --with-configs) if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] then @@ -674,6 +703,7 @@ then echo " --with-configs (includes the output of ~/.asoundrc and" echo " /etc/asound.conf if they exist)" echo " --with-devices (shows the device nodes in /dev/snd/)" + echo " --with-dmesg (shows the ALSA/HDA kernel messages)" echo "" echo " --update (check server for script updates)" echo " --upload (upload contents to remote server)"
participants (4)
-
Daniel Chen -
Mark Brown -
Takashi Iwai -
Wu Fengguang