neutrinolabs / pulseaudio-module-xrdp

xrdp sink / source pulseaudio modules
GNU Lesser General Public License v2.1
211 stars 40 forks source link

scripts: further update scripts to work better with derivative distros. #103

Closed peanutbutterandcrackers closed 11 months ago

peanutbutterandcrackers commented 11 months ago
matt335672 commented 11 months ago

Thanks for this @peanutbutterandcrackers

peanutbutterandcrackers commented 11 months ago

@matt335672 - I'm happy to help (: I have made some more changes (as per your suggestion) and also added one extra stuff, and comments.

I have tested these recent changes on Debian 11, Debian 12, Ubuntu 22.04 and Linux Mint 21.2 (with and without source repositories enabled).

matt335672 commented 11 months ago

That makes a lot more sense with the comments - thanks @peanutbutterandcrackers.

A couple of comments; 1) I've tried to keep to the xrdp coding style in these scripts, so I've used spaces rather than tabs and kept comments to 80 characters width. I should probably make this clearer somewhere. 2) Looking at the resulting code, there's a lot of scope for doing stuff in the main loop. For example, you can check for other suites and look for the deb-src lines to add at the same time. This avoids a lot of temporary files as it can all be done in one pass. 3) The pipeline cat $file | sort | uniq is more simply written as sort -u < $file avoiding a UUOC plus an unnecessary invocation of uniq. sort -u is part of POSIX

Putting all that together, I'd like to suggest you consider this fragment. I may of course have missed something. Please come back to me if I have.

    # Scan the source repositories. Add sources for all repositories
    # in this suite.
    # Ignore other suites. This is needed when running the wrapper in a
    # derivative-distro (like Linux Mint 21.2 'victoria') with --suite
    # option (--suite=jammy).
    echo "- Adding source repositories" >&2
    SRCLIST=$(find /etc/apt/ /etc/apt/sources.list.d -maxdepth 1 -type f -name '*.list')
    for srclst in $SRCLIST; do
        while read type url suite rest; do
            case "$suite" in
                $codename | $codename-updates | $codename-security)
                    if [ "$type" = deb ]; then
                        echo "deb $url $suite $rest"
                        echo "deb-src $url $suite $rest"
                    fi
                    ;;
            esac
        done <$srclst
    done >/tmp/combined_sources.list

    sudo rm $SRCLIST ;# Remove source respositories

    # remove duplicates from the combined source.list in order to prevent
    # apt warnings/errors; this is useful in cases where the user has
    # already configured source code repositories.
    sort -u < /tmp/combined_sources.list | \
        sudo tee /etc/apt/sources.list > /dev/null

    sudo apt-get update
peanutbutterandcrackers commented 11 months ago

@matt335672 - Brilliant refinements! I've tested this with Debian 11, Debian 12 and Linux Mint 21.2, and it works. I will try to follow the style guide from now on. Thank you!

matt335672 commented 11 months ago

Thank you @peanutbutterandcrackers