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

install_prereq: Fix package so asterisk can install on debian buster,bullseye, and bookworm. #489

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jackdpeterson
Copy link

@jackdpeterson jackdpeterson commented Dec 11, 2023

  • update list of debian packages to ones that are installable on debian:bullseye
  • switch from aptitude to apt-get (so we can get specific error messages when packages aren't found)
  • switch for aptitude check to dpkg since that's also built into the docker debian OS image

Other notes: this is a pretty messy script as-is and should probably have those constants split by version of OS. For example, debian bullseye doesn't have the mysql dependency available -- that's replaced w/ mariaDB equivalent client connector library. Furthermore, certain legacy libraries are replaced by newer versions.

Copy link
Member

@gtjoseph gtjoseph left a comment

Choose a reason for hiding this comment

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

A few things...

  • Please open a corresponding "improvement" issue and add a "Fixes" or 'Resolves" line to the commit message per Commit Messages
  • Is this really docker specific? Doesn't seem so.
  • Update the commit message summary line so it's clear that it's only install_prereq that's changing:
    install_prereq: Update for debian:bullseye might be better.
  • Add the cherry-pick comment per Code-Contribution
  • You might want to list the packages that were actually changed in the commit message.
  • How far back in ubuntu and debian versions are the changes still good? If this breaks installing on ubuntu:18 or debian:buster for instance, this would be a problem.

Remember to follow the procedure for force pushing an amended commit described in Code-Contribution.
After you re-push up the commit, don't forget to change the PR description. It doesn't update automatically.

Copy link

REMINDER: If this PR applies to other branches, please add a comment with the appropriate "cherry-pick-to" headers as per the Create a Pull Request process.

If you don't want it cherry-picked, please add a comment with cherry-pick-to: none so we don't keep asking.

If, after adding "cherry-pick-to" comments, you change your mind, please edit the comment to DELETE the header lines and add cherry-pick-to: none.

The currently active branches are now 18, 20, 21 and master.

@asteriskteam
Copy link
Contributor

This PR has been marked stale because it has been in "Changes Requested" or "submitter-action-required" state for 28 days or more. Please make the requested changes within 14 days or the PR will be closed.

@jackdpeterson
Copy link
Author

✅ Please open a corresponding "improvement" issue and add a "Fixes" or 'Resolves" line to the commit message per Is

this really docker specific? Doesn't seem so.
Correct, updated messaging to reflect that this isn't docker-specific. That's just the environment I was testing in.

✅ Update the commit message summary line so it's clear that it's only install_prereq that's changing

✅ Add the cherry-pick comment per Code-Contribution

✅ You might want to list the packages that were actually changed in the commit message.
-- Added package differences into commit.

How far back in ubuntu and debian versions are the changes still good? If this breaks installing on ubuntu:18 or debian:buster for instance, this would be a problem.
📆 -- Need to test this.

Comment on lines 192 to 247
EXISTS=`dpkg -l | cut -d ' ' -f 3 | grep ^"${pack}"\\$ | wc -l`
if [ ${EXISTS} -eq 0 ]; then
echo "${pack}"
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

if ! dpkg -l | awk 'NR > 5 {print $2}' | grep -q ^"${pack}"$; then
    echo "${pack}"
fi

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it may be as simple as:

dpkg -l "${pack}" >/dev/null 2>&1 || echo "${pack}"

Copy link
Author

Choose a reason for hiding this comment

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

Hey @seanbright -- your suggestion here isn't quite safe:

cat test.sh

#!/usr/bin/env sh

PACK="SOMETHING_I_DONT_HAVE"

EXISTS=`dpkg -l "${pack}" >/dev/null 2>&1 || echo "${pack}"`
if [ ${EXISTS} -eq 0 ]; then
  echo "${pack}"
fi

./test.sh
./test.sh: 6: [: -eq: unexpected operator


The approach I have is guaranteed to provide a numeric output with the | wc -l

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you misunderstood my suggestion. I was suggesting this:

check_installed_debs() {
  for pack in "$@" ; do
    dpkg -l "${pack}" >/dev/null 2>&1 || echo "${pack}"
  done
}

Copy link
Contributor

@seanbright seanbright left a comment

Choose a reason for hiding this comment

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

You're going to have to switch between package lists based on the Debian/Ubuntu version. lsb_release -a gives you some of this info (at least on Ubuntu, I don't know about Debian).

@asteriskteam
Copy link
Contributor

This PR has been marked stale because it has been in "Changes Requested" or "submitter-action-required" state for 28 days or more. Please make the requested changes within 14 days or the PR will be closed.

- [x] update list of debian packages to installable packages for debian:bullseye debian:buster, and debian:bookworm
    libmysqlclient-dev -> libmariadb-dev-compat
    libgmime-2.6-dev is not available in debian:bulleye. Remove.
    libsrtp0-dev is no longer available on debian:bulleye. Remove.
- [x] switch from aptitude to apt (so that we error messages are more obvious when packages aren't found)
- [x] switch aptitude check for packages to dpkg since thats one less dependency needed.
- [x] verify works w/ debian:buster, debian:bullseye, debian:bookworm.

Side note, I didn't test w/ Debian:jessie since that Docker image was returning 404's when attempting an apt update out of the box.

See [Github Gist containing Dockerfiles I used to test this PR](https://gist.github.com/jackdpeterson/c75eed4ac6e842e173fde80b56af3b04)
@jackdpeterson
Copy link
Author

jackdpeterson commented Apr 25, 2024

@seanbright -- I'd appreciate your feedback on this PR. I've modified my changes to separate out the different debian releases and select the packages there. This should make this more maintainable going forward and could be used as a pattern for other distributions that change/modify/remove packages over time.

In-scope: debian based OS's.

  • test debian:buster (10)
  • test debain:bullseye (11)
  • test debian:bookworm (12)

Dockerfiles I used to test

Commands to build:

Buster

docker build -t asterisk:buster -f Dockerfile-debian-buster .

Bullseye

docker build -t asterisk:bullseye -f Dockerfile-debian-bullseye .

Bookworm

docker build -t asterisk:bookworm -f Dockerfile-debian-bookworm .

Initially I tried compiling this on a Macbook Pro w/ an M1 chip; and compilation of asterisk failed there. What did work was launching a C5.2xlarge instance on AWS EC2 running Ubuntu 22.04 w/ git and docker.io installed.

@jackdpeterson jackdpeterson changed the title install_prereq: Fix package so debian:bullseye installs correctly install_prereq: Fix package so asterisk can install on debian buster,bullseye, and bookworm. Apr 25, 2024
@asteriskteam asteriskteam requested a review from a team April 30, 2024 15:18
@jackdpeterson
Copy link
Author

Could use a little bit of guidance on the failing tests here. Not making any changes to PJSIP.

@jcolp
Copy link
Member

jcolp commented Apr 30, 2024

The install_prereq script is not used, the failing tests can be ignored for this PR.

implement seanbright's change
@jackdpeterson
Copy link
Author

Fixing one more issue; ensuring that dpkg -l section properly gets converted to a number always w/ wc -l

#24 1.203 ./contrib/scripts/install_prereq: 245: [: -eq: unexpected operator
#24 1.208 ./contrib/scripts/install_prereq: 245: [: -eq: unexpected operator
#24 1.213 ./contrib/scripts/install_prereq: 245: [: -eq: unexpected operator
#24 1.218 ./contrib/scripts/install_prereq: 245: [: Illegal number: libjansson-dev

Comment on lines +313 to +327
## Default for previous debian releases
extra_packs=`check_installed_debs $PACKAGES_DEBIAN`

## Debian Bookworm
if [ $(cat /etc/debian_version | cut -d '.' -f 1) -eq 10 ]; then
extra_packs=`check_installed_debs $PACKAGES_DEBIAN_BUSTER`
fi

if [ $(cat /etc/debian_version | cut -d '.' -f 1) -eq 11 ]; then
extra_packs=`check_installed_debs $PACKAGES_DEBIAN_BULLSEYE`
fi

if [ $(cat /etc/debian_version | cut -d '.' -f 1) -eq 12 ]; then
extra_packs=`check_installed_debs $PACKAGES_DEBIAN_BOOKWORM`
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be simplified with a case statement? Something like:

case "$(cut -f1 -d. /etc/debian_version)" in
  10) extra_packs=$(check_installed_debs $PACKAGES_DEBIAN_BUSTER) ;;
  11) extra_packs=$(check_installed_debs $PACKAGES_DEBIAN_BULLSEYE) ;;
  12) extra_packs=$(check_installed_debs $PACKAGES_DEBIAN_BOOKWORM) ;;
  *)  extra_packs=$(check_installed_debs $PACKAGES_DEBIAN) ;;
esac

Copy link
Author

Choose a reason for hiding this comment

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

That's pretty. I'll update the PR and test it to reflect that concept.

@asteriskteam
Copy link
Contributor

This PR has been marked stale because it has been in "Changes Requested" or "submitter-action-required" state for 28 days or more. Please make the requested changes within 14 days or the PR will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants