diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-02-22 18:46:25 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-02-22 18:46:25 +0100 |
commit | cf1d76de8338aa56f144cb107651ec9374809af9 (patch) | |
tree | e27610d82cf33c2bcc6d4e013d52636d9b545587 | |
parent | 1fed326455d5e0f2109999bc054bbf725910aa13 (diff) | |
parent | 44666b2a78154602485ebfd79aea5259ad3a7d9d (diff) | |
download | alsa-driver-build-unstable-cf1d76de8338aa56f144cb107651ec9374809af9.tar.gz |
Merge remote branch 'alsa/master'
-rwxr-xr-x | utils/alsa-compile.sh | 1008 | ||||
-rwxr-xr-x | utils/insert | 531 | ||||
-rwxr-xr-x | utils/remove | 15 |
3 files changed, 1008 insertions, 546 deletions
diff --git a/utils/alsa-compile.sh b/utils/alsa-compile.sh new file mode 100755 index 000000000..6c16d6669 --- /dev/null +++ b/utils/alsa-compile.sh @@ -0,0 +1,1008 @@ +#!/bin/sh + +version=0.1.0 +protocol= +distrib=unknown +distribver=0.0 +tmpdir=$TMPDIR +if test -z "$tmpdir"; then + tmpdir="/tmp" +fi +tmpdir=$tmpdir/alsa-compile-script +baseurl="http://www.alsa-project.org/snapshot/?package=" +package=alsa-driver +packagedefault=true +url= +urldefault= +gittree="git://git.alsa-project.org/" +usegit=false +httpdownloader= +compile= +install= +quiet= +yes= +kernelmodules= +kmodlist= +kmodremove= +depmodbin= +modinfobin= +runargs= + +usage() { + echo "Usage: $0 [OPTION]..." + cat <<EOF + +This is a script version $version doing ALSA code compilation and installation. +Report any problems to <alsa-devel@alsa-project.org> mailing list. + +Operation modes: + -h, --help print this help, then exit + -e, --examples print text with examples, then exit + -q, --quiet quiet mode + -y, --yes do not ask any questions - answer is always yes + -c, --clean[=package] do overall clean, do package clean + --url=url package url + --git=giturl work with git tree + --compile force compilation + --install install binaries and headers + --tmpdir=dir set temporary directory (overrides TMPDIR envval) + --kmodules[=mods] reinstall kernel modules or install specified modules + --kmodlist list ALSA toplevel kernel modules + --kmodremove remove ALSA kernel modules + --run program [args] run a program using fresh alsa-lib + +Package selection: + --driver compile alsa-driver package (default) + --lib compile alsa-lib package + --utils compile alsa-utils package + --plugins compile alsa-plugins package + --firmware compile alsa-firmware package + --oss compile alsa-oss package +EOF +} + +examples() { + cat <<EOF +$0 examples: + + Install latest ALSA driver snapshot to system: + + alsa-compile.sh --driver --install + + Try new ALSA driver snapshot without installing it to system. The existing + ALSA kernel modules are replaced with fresh ones: + + alsa-compile.sh --driver --kmodules + + Do both (installation and modules replacement): + + alsa-compile.sh --driver --install --kmodules + + Install latest ALSA library snapshot to system: + + alsa-compile.sh --lib --install + + Run application using latest ALSA library snapshot. The new alsa-lib is not + installed to system: + + alsa-compile.sh --run <your_program_including_arguments> + + Do not want to fetch sources? Use file: protocol to specify current or + explicit directory containing sources: + + alsa-compile.sh --driver --url=file:///home/alsa/alsa-driver +EOF +} + +while : +do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -e|--examples) + examples + exit 0 + ;; + -q|--quiet) + quiet=true ;; + -y|--yes) + yes=true ;; + -c*|--clean*) + rmpkg= + case "$#,$1" in + *,*=*) + rmpkg=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + ;; + *) + rmpkg="$2" + shift ;; + esac + if test -z $rmpkg; then + echo -n "Removing tree $tmpdir:" + if test -d $tmpdir; then + if ! rm -rf $tmpdir; then + echo " failed" + exit 1 + fi + fi + echo " success" + else + echo -n "Removing package $package:" + rm $tmpdir/environment.* 2> /dev/null + packagedir="$tmpdir/$package.dir" + if test "$package" = "alsa-driver"; then + rm -rf $tmpdir/modules.* + rm -rf $tmpdir/run.awk + fi + if test -r $packagedir; then + tree=$(cat $packagedir) + if test -d $tmpdir/$tree; then + if ! rm -rf $tmpdir/$tree; then + echo " failed" + exit 1 + fi + fi + rm -f $packagedir + echo " success" + elif test -d $package; then + rm -rf $package + if test "$package" = "alsa-driver"; then + rm -rf alsa-kmirror 2> /dev/null + fi + echo " success" + else + echo " success" + fi + fi + exit 0 + ;; + --url*) + case "$#,$1" in + *,*=*) + url=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + url="$2" + shift ;; + esac + ;; + --git*) + case "$#,$1" in + *,*=*) + url=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + url="$gittree" ;; + *) + url="$2" + shift ;; + esac + ;; + --compile) + compile=true + ;; + --install) + install=true + ;; + --driver|--lib|--utils|--plugins|--firmware|--oss) + pkg="$1" + pkg=${pkg:2} + package="alsa-$pkg" + packagedefault= + test -z "$url" && url="$baseurl$package" + ;; + --run) + package="alsa-lib" + packagedefault= + test -z "$url" && url="$baseurl$package" + shift + runargs="$@" + break + ;; + --tmpdir*) + case "$#,$1" in + *,*=*) + tmpdir=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + tmpdir="$2" + shift ;; + esac + tmpdir="$tmpdir/alsa-compile-script" + ;; + --kmodules*) + case "$#,$1" in + *,*=*) + kernelmodules=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + kernelmodules="reinstall" ;; + *) + kernelmodules="$2" + shift ;; + esac + ;; + --kmodlist) + kmodlist=true + ;; + --kmodremove) + kmodremove=true + ;; + *) + test -n "$1" && echo "Unknown parameter '$1'" + break + ;; + esac + shift +done +if test -z "$url"; then + url="$baseurl$package" + urldefault=true +fi + +question_bool() { + if test "$yes" = "yes"; then + echo "true" + else + echo >&2 -n "$1 (Y/ ) " + read i + i=${i:0:1} + if test "$i" = "Y" -o "$i" = "y"; then + echo "true" + else + echo "false" + fi + fi +} + +check_distribution() { + distrib=$(lsb_release -ds 2> /dev/null | cut -d ' ' -f 1) + distrib=${distrib:1} + distribver=$(lsb_release -rs 2> /dev/null) + if test -z "$distrib"; then + echo >&2 "Unable to determine Linux distribution!" + exit 1 + fi + if test -z "$distribver"; then + echo >&2 "Unable to determine Linux distribution version!" + exit 1 + fi + echo "Detected Linux distribution '$distrib $distribver'." +} + +is_rpm_installed() { + a=$(rpm -qi $1 | head -1 | cut -d ' ' -f 1) + if test "$a" = "Name"; then + echo "frue" + else + echo "false" + fi +} + +install_package() { + echo "Trying to install package '$1':" + case "$distrib" in + openSUSE) + if zypper install $1; then + echo "Cannot install package '$1'." + exit 1 + fi + ;; + Fedora) + if yum install $1; then + echo "Cannot install package '$1'." + exit 1 + fi + ;; + *) + echo >&2 "install_package: Unsupported distribution $distrib" + exit 1 + esac + echo " installed" +} + +check_kernel_source() { + echo "Checking kernel build environment:" + case "$distrib" in + openSUSE) + if test $(is_rpm_installed kernel-source) = "false" ; then + install_package kernel-source + fi + ;; + Fedora) + if test $(is_rpm_installed kernel-devel) = "false" ; then + install_package kernel-devel + fi + ;; + *) + echo >&2 "check_kernel_source: Unsupported distribution $distrib" + exit 1 + ;; + esac + echo " passed" +} + +check_environment() { + env="$tmpdir/environment.base" + if ! test -s $env; then + if ! test -d $tmpdir ; then + mkdir -p $tmpdir + if ! test -d $tmpdir; then + echo >&2 "Unable to create directory $tmpdir" + exit 1 + fi + fi + echo "Using temporary tree $tmpdir" + check_distribution + test -x /bin/depmod && depmodbin=/bin/depmod + test -x /sbin/depmod && depmodbin=/sbin/depmod + if test -z "$depmodbin"; then + echo >&2 "Unable to find depmod utility" + exit 1 + fi + test -x /bin/modinfo && modinfobin=/bin/modinfo + test -x /sbin/modinfo && modinfobin=/sbin/modinfo + if test -z "$modinfobin"; then + echo >&2 "Unable to find modinfo utility" + exit 1 + fi + echo "protocol=$protocol" >> $env + echo "distrib=\"$distrib\"" >> $env + echo "distribver=\"$distribver\"" >> $env + echo "url=\"$url\"" >> $env + echo "package=\"$package\"" >> $env + echo "depmodbin=\"$depmodbin\"" >> $env + echo "modinfobin=\"$modinfobin\"" >> $env + b=$(basename $env) + echo "File $b has been created." + else + b=$(basename $env) + echo "File $b is cached." + opackage="$package" + ourl="$url" + . $env + if test "$packagedefault" != "true"; then + package="$opackage" + fi + if test "$urldefault" != "true"; then + url="$ourl" + fi + fi +} + +check_compilation_environment() { + env="environment.compile" + if ! test -s $env; then + a=$(wget --version | head -1 | cut -d ' ' -f 2) + if test "$a" = "Wget"; then + httpdownloader="wget" + else + a=$(curl --version | head -1 | cut -d ' ' -f 1 ) + if test "$a" = "curl"; then + httpdownloader="curl" + fi + fi + if test -z "$httpdownloader"; then + echo >&2 "Unable to determine HTTP downloader." + exit 1 + fi + a=$(git --version | head -1 | cut -d ' ' -f 1) + if test "$a" != "git"; then + install_package git + else + echo "Program git found." + fi + a=$(autoconf --version | head -1 | cut -d ' ' -f 1) + if test "$a" != "autoconf"; then + install_package autoconf + else + echo "Program autoconf found." + fi + a=$(gcc --version | head -1 | cut -d ' ' -f 1) + if test "$a" != "gcc" ; then + install_package gcc + else + echo "Program gcc found." + fi + if test "$protocol" = "git"; then + a=$(git --version | head -1 | cut -d ' ' -f 1) + if test "$a" != "git"; then + install_package git + else + echo "Program git found." + fi + fi + check_kernel_source + echo "httpdownloader=$httpdownloader" >> $env + echo "File $env has been created." + else + echo "File $env is cached." + . $env + fi +} + +download_http_file() { + echo "Downloading '$1':" + case "$httpdownloader" in + wget) + wget -q -O $2 $1 + ;; + curl) + curl -s -o $2 $1 + ;; + *) + echo >&2 "Unknown httpdownloader '$httpdownloader'." + exit 1 + ;; + esac + size=$(stat -c%s $2) + if test -z "$size" -o $size -le 0; then + echo " failed ($size)" + echo >&2 "Unable to download file '$1'." + exit 1 + else + echo " success ($size bytes)" + fi +} + +do_compile() { + cmd="./gitcompile" + case "$package" in + alsa-driver) + test -r acore/hwdep.o && cmd="make" + ;; + alsa-lib) + test -r src/.libs/libasound.so.2.0.0 && cmd="make" + ;; + esac + echo "Running $cmd:" + if ! $cmd; then + a=$(pwd) + echo >&2 "Working directory $a" + echo >&2 "Compilation of $package tree failed." + echo >&2 "Report this problem to the <alsa-devel@alsa-project.org> mailing list." + exit 1 + fi +} + +do_install() { + if ! test "$UID" -eq 0 ; then + echo >&2 "Root priviledges required for installation." + echo >&2 "Login as root to continue." + exit 1 + fi + cmd="make install" + case "$package" in + alsa-driver) + cat <<EOF +WARNING! You chose to install new ALSA kernel modules. The current ALSA +kernel modules will be removed from your system pernamently. In case of +problems, reinstall your kernel package. +EOF + if test $(question_bool "Really continue (Ctrl-C to abort)?") = "true"; then + cmd="make install-modules" + fi + ;; + esac + $cmd || exit 1 +} + +do_git() { + echo "do git" +} + +do_cmd() { + echo "> $@" + $@ || exit 1 +} + +kill_audio_apps() { + pids0=$(fuser /dev/snd/* 2> /dev/null) + pids1=$(fuser /dev/mixer* 2> /dev/null) + pids2=$(fuser /dev/sequencer* 2> /dev/null) + pids= + for pid in $pids0 $pids1 $pids2; do + pids="$pids $pid" + done + if ! test -z "$pids"; then + echo + echo "WARNING! An audio application uses ALSA driver:" + echo + for pid in $pids; do + ps --no-headers -p $pids || exit 1 + done + echo + if test $(question_bool "Would you like to kill these apps?") = "true"; then + for pid in $pids; do + do_cmd kill $pid + done + sleep 2 + killed= + for pid in $pids; do + a=$(ps --no-headers -p $pids) + if test -n "$a"; then + do_cmd kill -9 $pid + killed="true" + fi + done + if test "$killed" = "true"; then + sleep 2 + for pid in $pids; do + a=$(ps --no-headers -p $pids) + if test -n "$a"; then + echo >&2 "Unable to kill application:" + echo >&2 " $a" + exit 1 + fi + done + fi + else + echo >&2 "Terminated by user." + exit 1 + fi + fi +} + +parse_modules() { + if ! test -s ../modules.dep; then + rel=$(uname -r) + pdst="xxxx/lib/modules/$rel" + mkdir -p $pdst/modules || exit 1 + for i in modules/*.*o; do + ln -sf ../../../../../$i $pdst/$i || exit 1 + done + p=$(pwd) + if ! $depmodbin -b $p/xxxx ; then + echo >&2 "depmod failed." + exit 1 + fi + + if ! cp $pdst/modules.dep ../modules.dep ; then + echo >&2 "cp problem." + exit 1 + fi + rm -rf xxxx || exit 1 + echo "File modules.dep has been created." + else + echo "File modules.dep is cached." + fi + + if ! test -s ../modules.top ; then + for i in modules/*.*o; do + if test -r $i; then + a=$($modinfobin $i | grep "parm:" | grep "enable:") + if ! test -z "$a"; then + a=$(basename $i | cut -d . -f 1) + echo $a >> ../modules.top + fi + else + echo >&2 "permissions $tmpdir/$i problem" + exit 1 + fi + done + echo "File modules.top has been created." + else + echo "File modules.top is cached." + fi +} + +current_modules() { + lsmod | cut -d ' ' -f 1 | grep -E "^(snd[_-]|snd$)" +} + +my_rmmod() { + while test -n "$1"; do + if ! rmmod $1 2> /dev/null > /dev/null; then + phase2="$phase2 $1" + else + echo "> rmmod $1" + fi + shift + done + for mod in $phase2; do + echo "> rmmod $mod" + if ! rmmod $mod ; then + echo >&2 "Unable to remove kernel module $mod" + exit 1 + fi + done +} + +my_insmod() { + while test -n "$1"; do + if test -r modules/$1.ko; then + mod=modules/$1.ko + echo "> insmod $1.ko" + if ! insmod modules/$1.ko ; then + echo >&2 "Unable to insert kernel module $1.ko" + exit 1 + fi + else + if test -r modules/$1.o; then + mod=modules/$1.o + echo "> insmod $1.o" + if ! insmod modules/$1.o ; then + echo >&2 "Unable to insert kernel module $1.o" + exit 1 + fi + else + echo >&2 "Unable to find kernel module $1" + exit 1 + fi + fi + shift + done +} + +do_kernel_modules() { + usermods="$@" + curmods=$(current_modules) + if test -z "$curmods" -a -z "$usermods"; then + echo >&2 "Unable to determine current ALSA kernel modules." + exit 1 + fi + if test -n "$usermods"; then + loadmods="$usermods" + dst="../modules.user" + rm -f $dst || exit 1 + else + loadmods="$curmods" + dst="../modules.insmod" + fi + parse_modules + if ! test -s $dst; then + topmods=$(cat ../modules.top) + cat > run.awk <<EOF +function basename(name) { + split(name, y, "[/.]") + return y[length(y)-1] +} +function skipempty(dst, src, delim, x) { + split(src, y, delim) + for (x in y) { + if (length(y[x]) > 0) + dst[x] = y[x] + } +} +function skipemptyuser(dst, src, delim, x, m) { + split(src, y, delim) + for (x in y) { + if (length(y[x]) > 0) { + m = y[x] + if (substr(m, 0, 4) != "snd-") + m = "snd-" m + dst[x] = m + } + } +} +function moduleindex(mod, x) { + for (x in modules) { + if (modules[x] == mod) + return x + } + return 0; +} +function addmodule(mod, v, j, k) { + if (moduleindex(mod) > 0) + return + v = split(deps[mod], j, " ") + for (k = 1; k <= v; k++) + addmodule(j[k]) + modules[length(modules)+1] = mod +} +function addslavemodules(mod, exclude, m, v, j, k) +{ + for (m in deps) { + v = split(deps[m], j, " ") + for (k = 1; k <= v; k++) { + if (j[k] == mod && m != exclude) { + addmodule(m) + } + } + } +} +function addtopmodule(mod, v, j, k, z) +{ + v = split(deps[mod], j, " ") + for (k = 1; k <= v; k++) { + for (z = 1; z <= length(alldeps); z++) { + if (j[k] == alldeps[z]) + addslavemodules(j[k], mod) + } + } + addmodule(mod) + addslavemodules(mod) +} +BEGIN { + skipempty(akmods, kmods, ",") + if (length(usermods) > 0) + skipemptyuser(acurmods, usermods, " ") + else + skipempty(acurmods, curmods, " ") + skipempty(atopmods, topmods, " ") + for (b in atopmods) + alldeps[b] = atopmods[b] + # hack to load HDA codec modules + alldeps[length(alldeps)+1] = "snd-hda-codec" + } + { + split(\$0, a, "[: ]") + first = 1 + for (b = 1; b <= length(a); b++) { + if (length(a[b]) <= 0) + continue + base = basename(a[b]) + if (first) { + mod = base + deps[mod] = "" + first = 0 + } else { + if (length(deps[mod]) > 0) + deps[mod] = deps[mod] " " base + else + deps[mod] = base + } + } + delete a + + } +END { + addmodule("snd-page-alloc") + + # all direct toplevel modules dependencies + for (mod in deps) { + split(deps[mod], mods, " ") + for (d in atopmods) { + if (mod != atopmods[d]) + continue + for (b in acurmods) { + mod1 = acurmods[b] + v = gsub("_", "-", mod1) + if (mod != acurmods[b] && mod != mod1) + continue + addtopmodule(mod) + break + } + } + } + + addmodule("snd-seq") + addmodule("snd-mixer-oss") + for (b in modules) { + if ("snd-pcm" == modules[b]) + addmodule("snd-pcm-oss") + } + + for (b = 1; b <= length(modules); b++) { + mod = modules[b] + if (length(mod) > 0) + print mod + } + } +EOF + awk -f run.awk -v kmods="$kernelmodules" \ + -v curmods="$curmods" \ + -v usermods="$usermods" \ + -v topmods="$topmods" \ + ../modules.dep > $dst || exit 1 + rm run.awk || exit 1 + if ! test -s $dst; then + if test -n "$usermods"; then + echo >&2 "Unable to determine specified ALSA kernel modules." + else + echo >&2 "Unable to determine current ALSA kernel modules." + fi + exit 1 + fi + if test -z "$usermods"; then + echo "File modules.insmod has been created." + fi + else + if test -z "$usermods"; then + echo "File modules.insmod is cached." + fi + fi + kill_audio_apps + my_rmmod $curmods + my_insmod $(cat $dst) + echo "Kernel modules ready:" + cat /proc/asound/cards + if ! alsactl init 2> /dev/null > /dev/null ; then + echo "Mixer initialized using 'alsactl init' command." + else + echo "Use a mixer application (like alsamixer) to set reasonable volume levels." + fi +} + +kernel_modules() { + if test "$package" != "alsa-driver"; then + echo >&2 "--kernel-modules works only for alsa-driver package." + exit 1 + fi + if test "$kernelmodules" = "reinstall"; then + do_kernel_modules + else + a=$(echo $kernelmodules | sed -e 's/,/ /g') + do_kernel_modules $a + fi +} + +kernel_modules_list() { + if test "$package" != "alsa-driver"; then + echo >&2 "--kmodlist works only for alsa-driver package." + exit 1 + fi + parse_modules + topmods=$(cat ../modules.top) + for mod in $topmods; do + desc=$($modinfobin -F description modules/$mod.*o) + echo "$mod: $desc" + done +} + +kernel_modules_remove() { + if test "$package" != "alsa-driver"; then + echo >&2 "--kmodremove works only for alsa-driver package." + exit 1 + fi + curmods=$(current_modules) + if test -z "$curmods"; then + echo "No ALSA kernel modules to remove." + exit 0 + fi + kill_audio_apps + my_rmmod $curmods + echo "ALSA kernel modules removed." +} + +git_clone() { + do_cmd git clone "$1$2.git" "$2" +} + +rundir=$(pwd) +export LANG=C +protocol=$(echo $url | cut -d ':' -f 1) +check_environment $protocol +do_cmd cd $tmpdir +if test "$kmodremove" = "true"; then + kernel_modules_remove + exit 0 +fi +if test "$kmodlist" = "true" -a -z "$compile"; then + packagedir="$package.dir" + if test -r $packagedir; then + tree=$(cat $package.dir) + fi + do_cmd cd $tree + kernel_modules_list + exit 0 +fi +if test -n "$kernelmodules" -a -z "$compile"; then + packagedir="$package.dir" + if test -r $packagedir; then + tree=$(cat $package.dir) + fi + do_cmd cd $tree + kernel_modules + exit 0 +fi +case "$protocol" in +http|https|file) + packagedir="$package.dir" + check_compilation_environment $protocol + if test -r $packagedir; then + tree=$(cat $packagedir) + echo "$package tree $tree is present." + echo "Reusing it." + echo "Use '$0 --clean=$package' command to refetch and rebuild." + else + snapshot="snapshot.tar.bz2" + if test "$protocol" = "file"; then + tree=$(echo $url | cut -d ':' -f 2) + if test "${tree:0:1}" = "/"; then + tree=${tree:1} + fi + if test "${tree:0:1}" = "/"; then + tree=${tree:1} + fi + if test -r "$rundir/$tree/gitcompile"; then + tree="$rundir/$tree" + elif test -r "$rundir/$tree/../gitcompile"; then + tree="$rundir/$tree/.." + elif test -r "$rundir/$tree/../$package/gitcompile"; then + tree="$rundir/$tree/../$package" + fi + if test -d "$tree"; then + tree=$(cd "$tree" && pwd) + else + echo >&2 "Fatal: $package tree '$tree' not found" + exit 1 + fi + else + download_http_file $url $snapshot + do_cmd tar xjf $snapshot + rm $snapshot + tree=$(ls | grep $package) + fi + fi + if ! test -x $tree/gitcompile ; then + echo >&2 "Fatal: $package tree '$tree' not found" + exit 1 + fi + echo "Sources unpacked to $tree" + echo $tree > $packagedir + do_cmd cd $tree + do_compile + if test "$install" = "true"; then + do_install + else + echo "ALSA package $package was successfully built." + echo "Binaries are in $tmpdir/$tree directory." + fi + ;; +git) + packagedir="$package.dir" + check_compilation_environment $protocol + if test -r $packagedir ; then + echo "$package tree $package is present." + echo "Reusing it." + echo "Use '$0 --clean=$package' command to refetch and rebuild." + else + if test "$package" = "alsa-driver"; then + git_clone $url "alsa-kmirror" + fi + git_clone $url $package + echo "alsa-driver" > $packagedir + fi + do_cmd cd alsa-driver + do_compile + if test "$install" = "true"; then + do_install + else + echo "ALSA package $package was successfully built." + echo "Binaries are in $tmpdir/$package directory." + fi + ;; +*) + echo >&2 "Unknown protocol '$protocol'." + exit 1 +esac + +if test "$kmodlist" = "true"; then + packagedir="$package.dir" + if test -r $packagedir; then + tree=$(cat $package.dir) + fi + do_cmd cd $tree + kernel_modules_list +fi +if test -n "$kernelmodules"; then + do_cmd cd $tmpdir + packagedir="$package.dir" + if test -r $packagedir; then + tree=$(cat $package.dir) + fi + do_cmd cd $tree + kernel_modules + exit 0 +fi +if test -n "$runargs"; then + packagedir="alsa-lib.dir" + if test -r $packagedir; then + tree=$(cat $package.dir) + fi + f="$tmpdir/$tree/src/.libs/libasound.so.2.0.0" + if test -r $f; then + do_cmd "export LD_PRELOAD=$f" + do_cmd "export ALSA_CONFIG_PATH=\"$tmpdir/$tree/src/conf/alsa.conf\"" + do_cmd $runargs + else + echo >&2 "Unable to find alsa-lib.so" + exit 1 + fi +fi + +exit 0 diff --git a/utils/insert b/utils/insert deleted file mode 100755 index 8e1962e98..000000000 --- a/utils/insert +++ /dev/null @@ -1,531 +0,0 @@ -#!/bin/bash - -INSMOD="/sbin/insmod" -INSMODM="/sbin/insmod -m" -MODPROBE="/sbin/modprobe" -MODDIR="../modules" -SUFF=".o" -MAP="../snd.map" -OLDMAP="../snd.map.old" -CARDS_LIMIT=2 -KERNEL26="false" - -# 2.6 check -tmp=`insmod -V | cut -d ' ' -f 1` -if [ "$tmp" = "module-init-tools" ]; then - INSMODM="$INSMOD" - SUFF=".ko" - KERNEL26="true" -fi - -if grep -E "^alias snd-card" /etc/modprobe.d/sound > /dev/null 2> /dev/null ; then - echo "*********************************************" - echo "Warning: disabling system sound configuration" - echo "File /etc/modprobe.d/sound has been modified" - echo "Please, revert it manually" - echo "*********************************************" - sed -e 's/^alias snd-card/#alias snd-card/g' /etc/modprobe.d/sound > /dev/shm/alsa.sound.x1 - cp /dev/shm/alsa.sound.x1 /etc/modprobe.d/sound -fi - -function banner() { - echo > /dev/null -# echo "Inserting $1.." -# sleep 1 -} - -function isapnp() { - if [ -r $MODDIR/isapnp$SUFF ]; then - banner "isapnp" - if ! $INSMOD $MODDIR/isapnp$SUFF >> $MAP; then exit 1; fi - fi -} - -function basic() { - $MODPROBE -q soundcore 2> /dev/null - banner "snd-page-alloc" - if ! $INSMOD $MODDIR/snd-page-alloc$SUFF >> $MAP; then exit 1; fi - banner "snd" - if ! $INSMOD $MODDIR/snd$SUFF cards_limit=$CARDS_LIMIT >> $MAP; then exit 1; fi - if [ -r $MODDIR/snd-mixer-oss$SUFF ]; then - banner "snd-mixer-oss" - if ! $INSMOD $MODDIR/snd-mixer-oss$SUFF >> $MAP; then exit 1; fi - fi - banner "snd-timer" - if ! $INSMOD $MODDIR/snd-timer$SUFF >> $MAP; then exit 1; fi - banner "snd-pcm" - if ! $INSMOD $MODDIR/snd-pcm$SUFF preallocate_dma=1 >> $MAP; then exit 1; fi - if [ -r $MODDIR/snd-pcm-oss$SUFF ]; then - banner "snd-pcm-oss" - if ! $INSMOD $MODDIR/snd-pcm-oss$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-seq-device$SUFF ]; then - banner "snd-seq-device" - if ! $INSMOD $MODDIR/snd-seq-device$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-rawmidi$SUFF ]; then - banner "snd-rawmidi" - if ! $INSMOD $MODDIR/snd-rawmidi$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-hwdep$SUFF ]; then - banner "snd-hwdep" - if ! $INSMOD $MODDIR/snd-hwdep$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-seq$SUFF ]; then - banner "snd-seq" - if ! $INSMOD $MODDIR/snd-seq$SUFF seq_default_timer_class=2 seq_default_timer_card=0 seq_default_timer_device=0 seq_default_timer_subdevice=0 >> $MAP; then exit 1; fi - if [ -r $MODDIR/snd-seq-midi-event$SUFF ]; then - banner "snd-seq-midi-event" - if ! $INSMOD $MODDIR/snd-seq-midi-event$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-seq-midi$SUFF ]; then - banner "snd-seq-midi" - if ! $INSMOD $MODDIR/snd-seq-midi$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-seq-midi-emul$SUFF ]; then - banner "snd-seq-midi-emul" - if ! $INSMOD $MODDIR/snd-seq-midi-emul$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-seq-instr$SUFF ]; then - banner "snd-seq-instr" - if ! $INSMOD $MODDIR/snd-seq-instr$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-ainstr-simple$SUFF ]; then - banner "snd-ainstr-simple" - if ! $INSMOD $MODDIR/snd-ainstr-simple$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-ainstr-gf1$SUFF ]; then - banner "snd-ainstr-gf1" - if ! $INSMOD $MODDIR/snd-ainstr-gf1$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-ainstr-iw$SUFF ]; then - banner "snd-ainstr-iw" - if ! $INSMOD $MODDIR/snd-ainstr-iw$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-ainstr-fm$SUFF ]; then - banner "snd-ainstr-fm" - if ! $INSMOD $MODDIR/snd-ainstr-fm$SUFF >> $MAP; then exit 1; fi - fi - if [ -r $MODDIR/snd-seq-oss$SUFF ]; then - banner "snd-seq-oss" - if ! $INSMOD $MODDIR/snd-seq-oss$SUFF >> $MAP; then exit 1; fi - fi - fi -} - -function insert() { - if ! $INSMOD $MODDIR/$@ >> $MAP; then exit 1; fi -} - -function restore() { - sleep 1 - if [ -r /etc/asound/$1 ]; then - /usr/sbin/alsactl -f /etc/asound/$1 restore - fi -} - -function ac97() { - if [ "$KERNEL26" = "yes" ]; then - insert snd-ac97-bus$SUFF - fi - insert snd-ac97-codec$SUFF -} - -if [ -z "$1" ]; then - echo "Specify soundcard ID..." - exit -fi - -if [ -w $MAP ]; then - mv -f $MAP $OLDMAP -fi - -./remove - -case "$1" in - interwave-stb|stb) - basic; isapnp - insert snd-cs4231-lib$SUFF - insert snd-gus$SUFF - insert snd-gus-synth$SUFF - insert snd-i2c$SUFF - insert snd-tea6330t$SUFF - insert snd-interwave-stb$SUFF port=0x240 irq=7 dma1=5 dma2=6 midi=1 pcm_channels=8 - restore interwave-stb.conf - ;; - interwave|iw) - basic; isapnp - insert snd-cs4231-lib$SUFF - insert snd-gus$SUFF - insert snd-gus-synth$SUFF - insert snd-interwave$SUFF irq=7 dma1=5 dma2=6 midi=1 - restore interwave.conf - ;; - es1688) - basic - insert snd-es1688-lib$SUFF - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-es1688$SUFF mpu_port=0x330 - restore es1688.conf - ;; - es18xx) - basic; isapnp - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-es18xx$SUFF irq=7 dma1=0 dma2=1 - restore es18xx.conf - ;; - sb16) - basic; isapnp - insert snd-sb-common$SUFF - insert snd-mpu401-uart$SUFF - insert snd-sb16-dsp$SUFF - insert snd-sb16-csp$SUFF - insert snd-opl3-lib$SUFF - insert snd-sb16$SUFF irq=7 dma8=1 dma16=5 - restore sb16.conf - ;; - sb) - basic; isapnp - insert snd-sb-common$SUFF - insert snd-sb8-dsp$SUFF - insert snd-opl3-lib$SUFF - insert snd-sb8$SUFF port=0x220 irq=7 dma8=1 - restore sb.conf - ;; - sbawe) - basic; isapnp - insert snd-sb-common$SUFF - insert snd-sb16-dsp$SUFF - insert snd-sb16-csp$SUFF - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - if [ -r $MODDIR/snd-emu8000$SUFF ]; then - insert snd-emu8000$SUFF - fi - insert snd-sbawe$SUFF irq=7 dma8=1 dma16=5 - restore sbawe.conf - ;; - emu10k1|live) - basic - ac97 - insert snd-util-mem$SUFF - insert snd-emu10k1$SUFF - insert snd-seq-virmidi$SUFF - insert snd-emux-synth$SUFF - insert snd-emu10k1-synth$SUFF - restore emu10k1.conf - ;; - sb8) - basic - insert snd-sb-common$SUFF - insert snd-sb8-dsp$SUFF - insert snd-opl3-lib$SUFF - insert snd-sb8$SUFF irq=5 dma8=1 - restore sb8.conf - ;; - gusm*|max) - basic - insert snd-cs4231-lib$SUFF - insert snd-gus$SUFF - insert snd-gus-synth$SUFF - insert snd-gusmax$SUFF irq=7 pcm_channels=8 dma1=6 dma2=7 - restore gusmax.conf - ;; - gusc*|clas*) - basic - insert snd-gus$SUFF - insert snd-gus-synth$SUFF - insert snd-gusclassic$SUFF irq=7 dma1=6 dma2=7 - restore gusclassic.conf - ;; - guse*|ext*) - basic - insert snd-es1688$SUFF - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-gus$SUFF - insert snd-gus-synth$SUFF - insert snd-opl3-synth$SUFF - insert snd-gusextreme$SUFF irq=5 gf1_irq=11 mpu_port=0x300 - restore gusextreme.conf - ;; - opl3sa2) - basic; isapnp - insert snd-cs4231$SUFF - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-opl3sa2$SUFF port=0x100 wss_port=0xe80 \ - fm_port=0x388 midi_port=0x300 \ - irq=5 dma1=0 dma2=1 - restore opl3sa2.conf - ;; - mozart) - basic - insert snd-ad1848$SUFF - insert snd-mozart$SUFF - restore mozart.conf - ;; - p1) - basic; isapnp - insert snd-sb16-dsp$SUFF - insert snd-mpu401-uart$SUFF - insert snd-sb16$SUFF irq=5 dma8=1 dma16=5 mpu_port=0x330 - insert snd-gus$SUFF - insert snd-gusclassic$SUFF dma2=-1 - restore p1.conf - ;; - p2) - basic - insert snd-cs4231$SUFF - insert snd-es1688$SUFF - insert snd-mpu401-uart$SUFF - insert snd-gus$SUFF - insert snd-gusmax$SUFF - insert snd-gusextreme$SUFF irq1=11 mpu_port=0x300 - restore p2.conf - ;; - s3) - basic - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-sonicvibes$SUFF reverb=1 - restore sonicvibes.conf - ;; - ens1370) - basic - insert snd-ak4531-codec$SUFF - insert snd-ens1370$SUFF - restore ens1370.conf - ;; - ens1371) - basic - ac97 - insert snd-ens1371$SUFF -# insert snd-share$SUFF - restore ens1371.conf - ;; - trident) - basic - insert snd-mpu401-uart$SUFF - ac97 - insert snd-util-mem$SUFF - insert snd-trident$SUFF - insert snd-trident-synth$SUFF - restore trident.conf - ;; - cs46xx) - basic - ac97 - insert snd-cs46xx$SUFF - restore cs46xx.conf - ;; - cs4281) - basic - ac97 - insert snd-opl3-lib$SUFF - insert snd-cs4281$SUFF - restore cs4281.conf - ;; - fm801) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-tea575x-tuner$SUFF - insert snd-fm801$SUFF - restore fm801.conf - ;; - fm801-radio) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-tea575x-tuner$SUFF - insert snd-fm801$SUFF tea575x_tuner=1 - restore fm801.conf - ;; - es1938|solo1) - basic - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-es1938$SUFF - restore solo1.conf - ;; - cs4232) - basic; isapnp - insert snd-mpu401-uart$SUFF - insert snd-cs4231-lib$SUFF - insert snd-opl3-lib$SUFF - insert snd-cs4232$SUFF port=0x534 \ - fm_port=0x388 mpu_port=0x330 jport=0x208 \ - dma1=1 dma2=0 \ - irq=5 mpu_irq=7 - restore cs4232.conf - ;; - cs4236) - basic; isapnp - insert snd-mpu401-uart$SUFF - insert snd-cs4231$SUFF - insert snd-cs4236$SUFF - insert snd-opl3-lib$SUFF -# insert snd-cs4236$SUFF port=0x534 cport=0x120 \ -# fm_port=0x388 mpu_port=0x330 jport=0x208 \ -# dma1=1 dma2=0 \ -# irq=5 mpu_irq=7 - insert snd-cs4236$SUFF irq=7 - restore cs4236.conf - ;; - ice1712|envy24) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-i2c$SUFF - insert snd-cs8427$SUFF - insert snd-ak4xxx-adda$SUFF - insert snd-ice17xx-ak4xxx$SUFF - insert snd-ice1712$SUFF enable=1,1 cs8427_timeout=5 - restore ice1712.conf - ;; - ice1724|envy24ht) - basic - ac97 - insert snd-mpu401-uart$SUFF - #insert snd-i2c$SUFF - #insert snd-cs8427$SUFF - insert snd-ak4114$SUFF - insert snd-ak4xxx-adda$SUFF - insert snd-ice17xx-ak4xxx$SUFF - insert snd-ice1724$SUFF enable=1,1 - restore ice1724.conf - ;; - i8x0|ich) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-intel8x0$SUFF ac97_clock=48000 - restore intel8x0.conf - ;; - hda) - basic - insert snd-hda-codec$SUFF - insert snd-hda-codec-analog$SUFF - insert snd-hda-codec-nvhdmi$SUFF - insert snd-hda-codec-atihdmi$SUFF - insert snd-hda-codec-realtek$SUFF - insert snd-hda-codec-cmedia$SUFF - insert snd-hda-codec-si3054$SUFF - insert snd-hda-codec-conexant$SUFF - insert snd-hda-codec-via$SUFF - insert snd-hda-codec-idt$SUFF - insert snd-hda-codec-intelhdmi$SUFF - insert snd-hda-intel$SUFF - restore hda.conf - echo 1 > /proc/asound/card0/pcm0p/xrun_debug - ;; - pdplus|prodif-plus) - basic - insert snd-pdplus$SUFF - restore prodif-plus.conf - ;; - via686*|via8233*|via) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-via82xx$SUFF mpu_port=0x330 - restore via82xx.conf - ;; - ymfpci|yamaha) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-ymfpci$SUFF - restore ymfpci.conf - ;; - ctxfi) - basic - insert snd-ctxfi$SUFF - restore ctxfi.conf - ;; - dummy) - basic - insert snd-dummy$SUFF enable=1,1 pcm_devs=4,4 - #restore dummy.conf - ;; - virmidi) - basic - insert snd-seq-virmidi$SUFF - insert snd-virmidi$SUFF enable=1,1 midi_devs=8,8 - ;; - serialmidi) - basic - insert snd-serialmidi$SUFF - ;; - usb) - basic - insert snd-usb-lib$SUFF - insert snd-usb-audio$SUFF - ;; - vxpocket2) - basic - insert snd-vx-lib$SUFF - insert snd-vx-cs$SUFF - insert snd-vxpocket$SUFF - ;; - pdaudiocf) - basic - insert snd-ak4117$SUFF - insert snd-pdaudiocf$SUFF - ;; - t1) - basic; isapnp - insert snd-mpu401-uart$SUFF - insert snd-cs4231-lib$SUFF - insert snd-cs4236-lib$SUFF - insert snd-opl3-lib$SUFF - insert snd-sb16-dsp$SUFF - insert snd-sb16-csp$SUFF - insert snd-sb16$SUFF irq=10 dma8=1 dma16=5 - insert snd-cs4236$SUFF - ;; - t2) - basic - ac97 - insert snd-util-mem$SUFF - insert snd-emu10k1$SUFF - insert snd-seq-virmidi$SUFF - insert snd-emux-synth$SUFF - insert snd-emu10k1-synth$SUFF - insert snd-mpu401-uart$SUFF - insert snd-ice1712$SUFF - restore t2.conf - ;; - t3) - basic - ac97 - insert snd-mpu401-uart$SUFF - insert snd-opl3-lib$SUFF - insert snd-ymfpci$SUFF - insert snd-i2c$SUFF - insert snd-cs8427$SUFF - insert snd-ice1712$SUFF - restore t3.conf - ;; - t4) - basic - insert snd-ak4117$SUFF - insert snd-pdaudiocf$SUFF - insert snd-mpu401-uart$SUFF - ac97 - insert snd-util-mem$SUFF - insert snd-trident$SUFF - #insert snd-trident-synth$SUFF - restore trident.conf - ;; - *) - echo "Unknown soundcard $1..." - ;; -esac -echo "Insert done..." diff --git a/utils/remove b/utils/remove deleted file mode 100755 index 1b044d315..000000000 --- a/utils/remove +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -LSMOD="/sbin/lsmod" -RMMOD="/sbin/rmmod" - -if [ -r /proc/asound/seq/drivers ]; then - aconnect -x -fi -$LSMOD | grep "^snd" | while read line; do \ - XX=`echo $line | cut -d ' ' -f 1`; \ - $RMMOD $XX; \ -done -rmmod isapnp 2> /dev/null -echo "Remove done..." - |