Skip to content

Commit

Permalink
[FIX] packaging: adapt lxml and install script
Browse files Browse the repository at this point in the history
lxml.hml.clean was moved to a separate package starting in lxml 5.2
The requirements and debian control needs to be adapted to install the
new package in ubuntu noble (and after ubuntu noble only)

The solution was to use fallback to try to install lxml_html_clean if it
exists (noble) and fallback on lxml if not.

The script use in the documentation and available in more recent version
will take all first packge of the debian conrtol, meaning that after
this change it won't work in distribution not having lxml_html_clean.

The script is adapted to use fallback in apt-install command

Debian control:
font1 | font2,
package_1,
package_noble | package_fallback,

Before:
apt install font1 package package_noble

After:
apt install font1|font2 package package_noble|package_fallback

closes odoo#167350

X-original-commit: a611070
Related: odoo/documentation#9544
Signed-off-by: Christophe Monniez (moc) <[email protected]>
Signed-off-by: Xavier Dollé (xdo) <[email protected]>
  • Loading branch information
Xavier-Do committed May 30, 2024
1 parent 7cc0fd4 commit 318df32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Depends:
python3-pil,
python3-jinja2,
python3-libsass,
python3-lxml,
# After lxml 5.2, lxml-html-clean is in a separate package
python3-lxml-html-clean | python3-lxml,
python3-num2words,
python3-ofxparse,
python3-passlib,
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Jinja2==3.0.3 ; python_version <= '3.10'
Jinja2==3.1.2 ; python_version > '3.10'
libsass==0.20.1
lxml==4.8.0 ; python_version <= '3.10'
lxml==4.9.2 ; python_version > '3.10'
lxml==4.9.2 ; python_version > '3.10' and python_version < '3.12'
lxml==5.2.1; python_version >= '3.12' # (Noble - removed html clean)
lxml-html-clean; python_version >= '3.12' # (Noble - removed from lxml, unpinned for futur security patches)
MarkupSafe==2.0.1 ; python_version <= '3.10'
MarkupSafe==2.1.2 ; python_version > '3.10'
num2words==0.5.10
Expand Down
22 changes: 16 additions & 6 deletions setup/debinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
#
# Install Debian packages needed to run Odoo.

if [ "$(id -u)" -ne "0" ]; then
echo "This script must be run as root" >&2
exit 1

if [ "$1" = "-l" -o "$1" = "--list" ]; then
cmd="echo"
else
cmd="apt-get install -y --no-install-recommends"
if [ "$(id -u)" -ne "0" ]; then
echo "\033[0;31mThis script must be run as root to install dependencies, starting a dry run.\033[0m" >&2
cmd="$cmd -s"
else
apt-get update
fi
if [ "$1" = "-q" -o "$1" = "--quiet" ]; then
cmd="$cmd -qq"
fi
fi

script_path=$(realpath "$0")
script_dir=$(dirname "$script_path")
control_path=$(realpath "$script_dir/../debian/control")

apt-get update
sed -n '/^Depends:/,/^[A-Z]/p' "$control_path" \
| awk '/^ [a-z]/ { gsub(/,/,"") ; print $1 }' | sort -u \
| DEBIAN_FRONTEND=noninteractive xargs apt-get install -y -qq
| awk '/^ [a-z]/ { gsub(/,/,"") ; gsub(" ", "") ; print $NF }' | sort -u \
| DEBIAN_FRONTEND=noninteractive xargs $cmd

0 comments on commit 318df32

Please sign in to comment.