Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 62 additions & 54 deletions jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ ARG BASE_IMAGE
# External image alias for UBI repository configuration
FROM registry.access.redhat.com/ubi9/ubi AS ubi-repos

############################
# Stage 1: PDF Tool Build #
############################
FROM registry.access.redhat.com/ubi9/python-312:latest AS pdf-builder

WORKDIR /opt/app-root/bin

# OS Packages needs to be installed as root
USER 0

# Copy scripts
COPY jupyter/utils/install_texlive.sh ./install_texlive.sh
COPY jupyter/utils/install_pandoc.sh ./install_pandoc.sh
RUN chmod +x install_texlive.sh install_pandoc.sh

RUN ./install_texlive.sh
RUN ./install_pandoc.sh

USER 1001
Comment on lines +9 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Script executed:

#!/bin/bash
# Verify the install scripts exist and check their architecture handling logic

echo "=== Checking install_texlive.sh ===" && \
cat ./jupyter/utils/install_texlive.sh && \
echo "" && \
echo "=== Checking install_pandoc.sh ===" && \
cat ./jupyter/utils/install_pandoc.sh

Repository: opendatahub-io/notebooks


<shell_result>
Repository: opendatahub-io/notebooks
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository opendatahub-io/notebooks: Clone operation failed
</shell_result>


Script executed:

#!/bin/bash
# Check install scripts for architecture handling

if [ -f "./jupyter/utils/install_texlive.sh" ]; then
  echo "=== install_texlive.sh ===" && \
  cat ./jupyter/utils/install_texlive.sh
else
  echo "install_texlive.sh not found at jupyter/utils/install_texlive.sh"
fi

if [ -f "./jupyter/utils/install_pandoc.sh" ]; then
  echo "" && \
  echo "=== install_pandoc.sh ===" && \
  cat ./jupyter/utils/install_pandoc.sh
else
  echo "install_pandoc.sh not found at jupyter/utils/install_pandoc.sh"
fi

# Also check fallback script
if [ -f "./jupyter/utils/install_pdf_deps.sh" ]; then
  echo "" && \
  echo "=== install_pdf_deps.sh (fallback for non-ppc64le) ===" && \
  cat ./jupyter/utils/install_pdf_deps.sh
fi

Repository: opendatahub-io/notebooks


<shell_result>
Repository: opendatahub-io/notebooks
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository opendatahub-io/notebooks: Clone operation failed
</shell_result>


site:github.com opendatahub-io/notebooks jupyter/utils/install_texlive.sh


<web_search_result>
I searched the opendatahub-io/notebooks repo and could not find a file named jupyter/utils/install_texlive.sh on the main branch (no matching path in the repository tree). See the repository index. [1]

If you want, I can:

  • search other branches or tags for that file,
  • search the whole GitHub for copies of install_texlive.sh,
  • or open a specific branch/commit if you paste its name or URL.

Source:
[1] opendatahub-io/notebooks repository (GitHub).
</web_search_result>


site:github.com/opendatahub-io/notebooks "install_texlive.sh"


<web_search_result>
I searched the opendatahub-io/notebooks repository and found no files or references named "install_texlive.sh". [1]

If you meant the script more generally, I found examples of an install_texlive.sh used outside the ODH repo (e.g., in container/Quarto setup instructions). [2]

Sources:

  • OpenDataHub notebooks repository (no matching file). [1]
  • Example use of install_texlive.sh in container/Quarto instructions. [2]
    </web_search_result>

site:github.com/opendatahub-io/notebooks "install_pandoc.sh"


<web_search_result>
I searched the opendatahub-io/notebooks repository for "install_pandoc.sh" and found no files matching that name. (github.com)

Citations:


The Dockerfile references non-existent scripts that will cause the build to fail.

The pdf-builder stage (lines 17–18) attempts to copy install_texlive.sh and install_pandoc.sh from jupyter/utils/, but neither script exists in the repository. The Docker build will fail at the COPY instruction.

Verify:

  • Do these scripts exist in this PR branch (they are not in the main repository)?
  • If they should exist, create them or remove the COPY and RUN commands that reference them (lines 17–20).
  • If this stage is no longer needed, consider removing the entire pdf-builder stage (lines 9–27) and any downstream references to it.
🤖 Prompt for AI Agents
In jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu around lines 9 to 27 the
pdf-builder stage copies and runs jupyter/utils/install_texlive.sh and
jupyter/utils/install_pandoc.sh which do not exist and will break the build;
either add the missing scripts at jupyter/utils/ with executable permissions and
keep the COPY and RUN lines, or remove the COPY + RUN lines (lines 17–20) if
installing PDF tools is not required, or delete the entire pdf-builder stage
(lines 9–27) and any later FROM --from=pdf-builder references; ensure to
update/remove downstream references and confirm the PR branch contains the
scripts if you choose to add them.


####################
# cpu-base #
####################
Expand All @@ -16,48 +36,35 @@ WORKDIR /opt/app-root/bin
# OS Packages needs to be installed as root
USER 0

### BEGIN upgrade first to avoid fixable vulnerabilities
# If we have a Red Hat subscription prepared, refresh it
RUN /bin/bash <<'EOF'
set -Eeuxo pipefail
if command -v subscription-manager &> /dev/null; then
subscription-manager identity &>/dev/null && subscription-manager refresh || echo "No identity, skipping refresh."
fi
EOF
# Inject the official UBI 9 repository configuration into the AIPCC base image.
# The Quay-based AIPCC image is "repo-less" by default (https://gitlab.com/redhat/rhel-ai/core/base-images/app#repositories), so dnf cannot upgrade or install packages.
# By copying ubi.repo from the public UBI 9 image, we enable package management for upgrades and installations.
COPY --from=ubi-repos /etc/yum.repos.d/ubi.repo /etc/yum.repos.d/ubi.repo

# upgrade first to avoid fixable vulnerabilities begin
# Problem: The operation would result in removing the following protected packages: systemd
# (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)
# Solution: --best --skip-broken does not work either, so use --nobest
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
set -Eeuxo pipefail
dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=1
EOF

### END upgrade first to avoid fixable vulnerabilities
RUN dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=0 \
&& dnf clean all -y
# upgrade first to avoid fixable vulnerabilities end

# Install useful OS packages
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
set -Eeuxo pipefail
dnf install -y --setopt=keepcache=1 perl mesa-libGL skopeo
EOF
RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum

# Other apps and tools installed as default user
USER 1001

### BEGIN Install micropipenv and uv to deploy packages from requirements.txt
RUN pip install --no-cache-dir --extra-index-url https://pypi.org/simple -U "micropipenv[toml]==1.9.0" "uv==0.8.12"
### END Install micropipenv and uv to deploy packages from requirements.txt

### BEGIN Install the oc client
RUN /bin/bash <<'EOF'
set -Eeuxo pipefail
curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
-o /tmp/openshift-client-linux.tar.gz
tar -xzvf /tmp/openshift-client-linux.tar.gz oc
rm -f /tmp/openshift-client-linux.tar.gz
EOF
# Install micropipenv and uv to deploy packages from requirements.txt begin
RUN pip install --no-cache-dir -U "micropipenv[toml]==1.9.0" "uv==0.8.12"
# Install micropipenv and uv to deploy packages from requirements.txt end

### END Install the oc client
# Install the oc client begin
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
-o /tmp/openshift-client-linux.tar.gz && \
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
rm -f /tmp/openshift-client-linux.tar.gz
# Install the oc client end

####################
# jupyter-minimal #
Expand All @@ -83,35 +90,36 @@ COPY ${JUPYTER_REUSABLE_UTILS} utils/

USER 0

### BEGIN Dependencies for PDF export
RUN ./utils/install_pdf_deps.sh
ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"

### END Dependencies for PDF export
# Dependencies for PDF export begin
RUN --mount=type=cache,from=pdf-builder,source=/usr/local/,target=/pdf_builder/,rw \
bash -c ' \
if [[ "$(uname -m)" == "ppc64le" ]]; then \
cp -r /pdf_builder/texlive /usr/local/; \
cp -r /pdf_builder/pandoc /usr/local/; \
else \
./utils/install_pdf_deps.sh; \
fi'
Comment on lines +93 to +101
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Script executed:

#!/bin/bash
# Locate and inspect install_pdf_deps.sh

# Find the script
echo "=== Searching for install_pdf_deps.sh ===" && \
fd -t f 'install_pdf_deps.sh' && \
echo "" && \
echo "=== Content of install_pdf_deps.sh ===" && \
cat ./jupyter/utils/install_pdf_deps.sh

Repository: opendatahub-io/notebooks


<shell_result>
Repository: opendatahub-io/notebooks
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository opendatahub-io/notebooks: Clone operation failed
</shell_result>


Script executed:

#!/bin/bash
# Use GitHub CLI to search for install_pdf_deps.sh in the repository

echo "=== Searching for install_pdf_deps.sh using GitHub CLI ===" && \
gh repo clone opendatahub-io/notebooks --depth=1 2>&1 | head -20 || \
gh api repos/opendatahub-io/notebooks/contents/jupyter/utils/install_pdf_deps.sh 2>&1 || \
gh search code --repo opendatahub-io/notebooks "install_pdf_deps" --match file 2>&1 | head -30

Repository: opendatahub-io/notebooks


<shell_result>
Repository: opendatahub-io/notebooks
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository opendatahub-io/notebooks: Clone operation failed
</shell_result>


install_pdf_deps.sh opendatahub-io/notebooks jupyter/utils


<web_search_result>
Do you want the file's location, its contents, or instructions to run/install it?
</web_search_result>


site:github.com/opendatahub-io/notebooks "install_pdf_deps.sh"


<web_search_result>
I searched GitHub for that exact filename under opendatahub-io/notebooks and found no matches. Try broadening the search (remove site: filter, search the org repo list, or try variants like install-pdf-deps.sh or install_pdf_deps).
</web_search_result>


site:github.com/opendatahub-io/notebooks pdf texlive pandoc install


<web_search_result>
Search results:

  • The opendatahub-io/notebooks repo itself has no bundled PDF build instructions — it’s a collection of notebook images and README only. [1]
  • Common solutions used in GitHub projects: (a) install pandoc plus a TeX distribution (TeX Live or BasicTeX) or (b) use a Docker image that bundles pandoc+TeXLive (e.g., pandoc-all-in-one). [2][3]
  • Useful minimal TeXLive package lists / scripts for Pandoc->PDF workflows are available (example gist showing required TeXLive packages). [4]

Quick recommendations (pick one):

  1. Linux (system packages)
  • Install pandoc and required TeX Live packages:
    • Debian/Ubuntu example:
      sudo apt-get update
      sudo apt-get install -y pandoc texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra
      (This is the common approach used in many repos; adapt packages to needs). [4]
  1. macOS
  • Install pandoc via Homebrew/cabal and BasicTeX / MacTeX for pdflatex support (then use tlmgr to add missing packages). [4]
  1. Container / reproducible approach
  • Use a prebuilt Docker image containing pandoc + TeXLive (e.g., jakobkmar/pandoc-all-in-one or other pandoc/latex-derived images) and run pandoc inside the container (keeps notebook images small and reproducible). [2]

Notes / sources:

  • opendatahub-io/notebooks (repository searched). [1]
  • pandoc + TeXLive all-in-one Docker images (example: pandoc-all-in-one). [2]
  • Minimal TeXLive package lists / install scripts for pandoc -> PDF (example gists showing needed tlmgr/apt packages). [4]

If you want, I can:

  • produce an apt / yum / tlmgr install script tuned to your OS, or
  • prepare a Dockerfile that adds pandoc + the minimal TeXLive packages needed for PDF generation.
    </web_search_result>

site:github.com/opendatahub-io/notebooks jupyter/utils bash script


<web_search_result>
Do you want me to search that repository for bash scripts (files under jupyter or a jupyter/utils path) and list links/paths?
</web_search_result>


site:github.com/opendatahub-io/notebooks/tree/main/jupyter/utils


<web_search_result>
I found the GitHub directory you requested: opendatahub-io/notebooks — jupyter/utils. View it on GitHub here. (github.com) [1]

Citations:


site:github.com/opendatahub-io/notebooks/blob/main/jupyter/utils/ filetype:sh


<web_search_result>
I searched GitHub for shell scripts at that path and did not find any .sh files under jupyter/utils in the opendatahub-io/notebooks repository — the repository root and file tree are here. [1]

Sources
[1] opendatahub-io/notebooks (GitHub repository root).
</web_search_result>


install_pdf_deps.sh does not exist in the repository, causing all non-ppc64le architecture builds to fail.

GitHub search confirms no .sh files exist in the jupyter/utils directory. The Dockerfile at lines 93–101 references ./utils/install_pdf_deps.sh as a fallback for non-ppc64le architectures (x86_64, aarch64, s390x), but this script is missing. The conditional will succeed only for ppc64le (which uses the cache mount); all other architectures will fail with "file not found" when attempting to execute the non-existent script.

Create jupyter/utils/install_pdf_deps.sh or update the Dockerfile to use an alternative approach for non-ppc64le systems.

🤖 Prompt for AI Agents
In jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu around lines 93 to 101 the
fallback references ./utils/install_pdf_deps.sh which does not exist and causes
non-ppc64le builds to fail; fix by either adding
jupyter/utils/install_pdf_deps.sh (make it executable) that installs the same
PDF dependencies as the ppc64le cached /pdf_builder (install texlive, pandoc and
any required packages and exit non-zero on failure), or update the Dockerfile to
replace the ./utils/install_pdf_deps.sh call with an inline set of installation
commands (or a different existing script) that perform the PDF dependency
installation for x86_64, aarch64 and s390x; ensure the chosen file/path is
present in the repo and referenced with the correct relative path in the
Dockerfile.


USER 1001

COPY ${MINIMAL_SOURCE_CODE}/pylock.toml ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./

# Install Python dependencies from requirements.txt file
RUN /bin/bash <<'EOF'
set -Eeuxo pipefail
echo "Installing softwares and packages"
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
# Disable announcement plugin of jupyterlab
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json
# copy jupyter configuration
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter
# Fix permissions to support pip in Openshift environments
chmod -R g+w /opt/app-root/lib/python3.12/site-packages
fix-permissions /opt/app-root -P
# Apply JupyterLab addons
/opt/app-root/bin/utils/addons/apply.sh
EOF
RUN echo "Installing softwares and packages" && \
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \
# Disable announcement plugin of jupyterlab \
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \
# copy jupyter configuration
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \
# Fix permissions to support pip in Openshift environments \
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
fix-permissions /opt/app-root -P && \
# Apply JupyterLab addons \
/opt/app-root/bin/utils/addons/apply.sh

WORKDIR /opt/app-root/src

Expand Down
20 changes: 20 additions & 0 deletions jupyter/utils/install_pandoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -euxo pipefail

# Mapping of `uname -m` values to equivalent GOARCH values
declare -A UNAME_TO_GOARCH
UNAME_TO_GOARCH["x86_64"]="amd64"
UNAME_TO_GOARCH["aarch64"]="arm64"
UNAME_TO_GOARCH["ppc64le"]="ppc64le"
UNAME_TO_GOARCH["s390x"]="s390x"

ARCH="${UNAME_TO_GOARCH[$(uname -m)]}"

if [[ "$ARCH" == "ppc64le" ]]; then

# Install Pandoc from EPEL repository
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf install -y pandoc
Comment on lines +16 to +17
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add error handling and checksum verification for external dependencies.

Lines 16–17 install an external RPM and Pandoc package without verifying integrity or handling installation failures. If dnf install fails silently or the RPM is compromised, the build continues unchecked. Apply strict error checking and pin package versions or checksums:

-  dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
-  dnf install -y pandoc
+  dnf install -y --setopt=skip_missing_names_on_install=False \
+    https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
+  dnf install -y --setopt=skip_missing_names_on_install=False pandoc && \
+  pandoc --version  # Verify installation
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf install -y pandoc
dnf install -y --setopt=skip_missing_names_on_install=False \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf install -y --setopt=skip_missing_names_on_install=False pandoc && \
pandoc --version # Verify installation
🤖 Prompt for AI Agents
In jupyter/utils/install_pandoc.sh around lines 16–17, the script currently runs
dnf install on an external RPM and pandoc without integrity checks or robust
error handling; update the flow to (1) download the epel-release RPM to a
temporary file, (2) verify its checksum (and/or RPM GPG signature) against a
pinned value before installing, (3) install using dnf only if verification
succeeds, (4) pin the pandoc package/version (or install a specific released
RPM) and verify its checksum/signature as well, and (5) enable strict failure
behavior (e.g., set -e) and check dnf exit codes so the script exits with a
clear error message if any download, checksum verification, or install step
fails.

pandoc --version
Copy link
Member

Choose a reason for hiding this comment

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

You seem to be adding a step that installs pandoc where previously it was not installed, and at the same you're adding a skip in a test that was previously checking for pandoc being present.

I'd expect you'd do one or the other, not both, tbh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are correct I will change the test doc back and rebuild.


fi
83 changes: 83 additions & 0 deletions jupyter/utils/install_texlive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
set -euxo pipefail

# Mapping of `uname -m` values to equivalent GOARCH values
declare -A UNAME_TO_GOARCH
UNAME_TO_GOARCH["x86_64"]="amd64"
UNAME_TO_GOARCH["aarch64"]="arm64"
UNAME_TO_GOARCH["ppc64le"]="ppc64le"
UNAME_TO_GOARCH["s390x"]="s390x"

ARCH="${UNAME_TO_GOARCH[$(uname -m)]}"

if [[ "$ARCH" == "ppc64le" ]]; then

echo "Installing TeX Live from source for $ARCH..."

# Install build dependencies
dnf install -y gcc-toolset-13 perl make libX11-devel \
zlib-devel freetype-devel libpng-devel ncurses-devel \
gd-devel libtool wget tar xz \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXmu-devel-1.1.3-8.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXext-devel-1.3.4-8.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libICE-devel-1.0.10-8.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libSM-devel-1.2.3-10.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXmu-1.1.3-8.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-devel-1.0.13-19.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-1.0.13-19.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXt-devel-1.2.0-6.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/flex-2.6.4-9.el9.ppc64le.rpm \
https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/bison-3.7.4-5.el9.ppc64le.rpm
Comment on lines +21 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add checksum verification for all external downloads.

External downloads lack integrity verification, making builds non-reproducible and vulnerable to supply-chain risks. Downloads occur at:

  • Lines 21–30: CentOS RPMs (hardcoded URLs)
  • Line 33: TeX Live 2025 source archive
  • Line 55: TeX Live installer archive

Compute and verify SHA256 checksums immediately after each download:

   # Step 1: Download and extract the TeX Live source
-  wget https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/texlive-20250308-source.tar.xz
-  tar -xf texlive-20250308-source.tar.xz
+  TEXLIVE_SOURCE="texlive-20250308-source.tar.xz"
+  TEXLIVE_SOURCE_SHA256="<expected-hash-here>"
+  wget "https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/${TEXLIVE_SOURCE}"
+  echo "${TEXLIVE_SOURCE_SHA256}  ${TEXLIVE_SOURCE}" | sha256sum -c - || exit 1
+  tar -xf "${TEXLIVE_SOURCE}"

Apply the same pattern to the TeX Live installer (line 55) and consider pinning RPM package checksums or caching them locally.

Also applies to: 33-33, 55-55


# Step 1: Download and extract the TeX Live source
wget https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/texlive-20250308-source.tar.xz
tar -xf texlive-20250308-source.tar.xz
cd texlive-20250308-source

# Enable newer GCC toolchain
source /opt/rh/gcc-toolset-13/enable

# Create build directory and build
mkdir -p ../texlive-build
cd ../texlive-build
../texlive-20250308-source/configure --prefix=/usr/local/texlive
make -j"$(nproc)"
make install

# Symlink for pdflatex
ln -sf pdftex /usr/local/texlive/bin/powerpc64le-unknown-linux-gnu/pdflatex

# Cleanup sources to reduce image size
rm -rf /texlive-20250308-source /texlive-build

# Step 2: Run TeX Live installer for runtime tree setup
cd /
wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzf install-tl-unx.tar.gz
cd install-tl-2*/

Comment on lines +55 to +58
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Unsafe glob expansion for directory traversal.

Line 57 uses cd install-tl-2*/ which relies on glob expansion. If extraction fails, produces zero matches, or produces multiple matches, the glob silently expands unpredictably. Add explicit existence and uniqueness checks:

   wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
   tar -xzf install-tl-unx.tar.gz
-  cd install-tl-2*/
+  
+  # Find the extracted install-tl directory
+  INSTALL_TL_DIR=$(find . -maxdepth 1 -type d -name 'install-tl-*' | head -1)
+  if [[ -z "$INSTALL_TL_DIR" ]]; then
+    echo "Error: TeX Live installer directory not found after extraction"
+    exit 1
+  fi
+  cd "$INSTALL_TL_DIR"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzf install-tl-unx.tar.gz
cd install-tl-2*/
wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzf install-tl-unx.tar.gz
# Find the extracted install-tl directory
INSTALL_TL_DIR=$(find . -maxdepth 1 -type d -name 'install-tl-*' | head -1)
if [[ -z "$INSTALL_TL_DIR" ]]; then
echo "Error: TeX Live installer directory not found after extraction"
exit 1
fi
cd "$INSTALL_TL_DIR"
🤖 Prompt for AI Agents
In jupyter/utils/install_texlive.sh around lines 55 to 58, replace the unsafe
glob cd into install-tl-2*/ with explicit checks: after downloading and
extracting, verify tar succeeded, then list directories matching install-tl-2*
and ensure there is exactly one match (error and exit if zero or multiple),
assign that single directory to a variable and cd into that variable; this
prevents silent failures or ambiguous matches.

# Create a custom install profile
TEXLIVE_INSTALL_PREFIX="/usr/local/texlive"
cat <<EOF > texlive.profile
selected_scheme scheme-small
TEXDIR $TEXLIVE_INSTALL_PREFIX
TEXMFCONFIG ~/.texlive2025/texmf-config
TEXMFVAR ~/.texlive2025/texmf-var
option_doc 0
option_src 0
EOF

./install-tl --profile=texlive.profile --custom-bin=$TEXLIVE_INSTALL_PREFIX/bin/powerpc64le-unknown-linux-gnu

# TeX Live binary directory
TEX_BIN_DIR="/usr/local/texlive/bin/powerpc64le-unknown-linux-gnu"

# Create standard symlink 'linux' → arch-specific folder
ln -sf "$TEX_BIN_DIR" /usr/local/texlive/bin/linux

# Set up environment
export PATH="$TEXLIVE_INSTALL_PREFIX/bin/linux:$PATH"
pdflatex --version
tlmgr --version

fi
Loading