Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Oct 12, 2023

Conversation

peanutbutterandcrackers
Copy link
Contributor

  • copy *.list files from /etc/apt/sources.list.d into the chroot
    The scripts were not working on Linux Mint 21.2 because it keeps it's sources list inside /etc/apt/sources.list.d instead of the usual place. This change makes it work. Also tested on Ubuntu 22.04 and Debian 12 to make sure nothing breaks - it doesn't.
  • inside the chroot, filter out references to the derivative distro's package sources.
    Otherwise apt-get update fails because of lack of valid signature.

- copy *.list files from /etc/apt/sources.list.d into the chroot
- inside the chroot, filter out references to the derivative distro's
  package sources.
Copy link
Member

@matt335672 matt335672 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments follow:-

scripts/install_pulseaudio_sources_apt.sh Outdated Show resolved Hide resolved
scripts/install_pulseaudio_sources_apt.sh Outdated Show resolved Hide resolved
scripts/install_pulseaudio_sources_apt_wrapper.sh Outdated Show resolved Hide resolved
@matt335672
Copy link
Member

Thanks for this @peanutbutterandcrackers

@peanutbutterandcrackers
Copy link
Contributor Author

@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
Copy link
Member

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
Copy link
Contributor Author

@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 matt335672 merged commit 14bee58 into neutrinolabs:devel Oct 12, 2023
3 checks passed
@matt335672
Copy link
Member

Thank you @peanutbutterandcrackers

@matt335672 matt335672 mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants