-
Notifications
You must be signed in to change notification settings - Fork 23
Improve the README and rework the installation script. #120
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
Open
Dscano
wants to merge
6
commits into
p4lang:main
Choose a base branch
from
Dscano:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dde4d1c
Improve the README and rework the installation script.
Dscano e14fdb7
Update README.md
Dscano 16a9fff
Address dependency installation
Dscano e06d649
Rework dependencies
Dscano aeade81
Rework the script. Compilation successful.
Dscano f9c3827
Add wireshark isntallation in dependencies step
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
|
|
||
| # Colors | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| BLUE='\033[0;34m' | ||
| YELLOW='\033[1;33m' | ||
| BOLD='\033[1m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| print_step() { | ||
| echo -e "\n${BOLD}${BLUE}==>${NC} ${BOLD}$1${NC}" | ||
| } | ||
|
|
||
| echo -e "${BOLD}${BLUE}=== P4 DPDK Target Installation Script ===${NC}" | ||
|
|
||
| check_and_install() { | ||
| local cmd=$1 | ||
| local pkgs=$2 | ||
|
|
||
| # Check if command exists (for executables) | ||
| if ! command -v "$cmd" >/dev/null 2>&1; then | ||
| echo -e "${YELLOW}$cmd not found.${NC}" | ||
| sudo apt update | ||
| sudo apt install -y $pkgs | ||
| fi | ||
| } | ||
|
|
||
| check_and_install_pkgs() { | ||
| local pkgs=$1 | ||
| if dpkg-query -l "$pkgs" >/dev/null 2>&1; then | ||
| echo -e "${GREEN}$pkgs is already installed.${NC}" | ||
| else | ||
| echo -e "${YELLOW}$pkgs not found. Installing...${NC}" | ||
| sudo apt update | ||
| sudo apt install -y "$pkgs" | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| # ------------------------------------------------------------ | ||
| # 1. Base directories | ||
| # ------------------------------------------------------------ | ||
| export SDE=$(pwd)/sde | ||
| export SDE_INSTALL=$SDE/install | ||
|
|
||
| mkdir -p "$SDE" | ||
| mkdir -p "$SDE_INSTALL" | ||
|
|
||
| # ------------------------------------------------------------ | ||
| # 0. Check Dependencies (install if missing) | ||
| # ------------------------------------------------------------ | ||
| print_step "0/5 Checking dependencies..." | ||
| # Install Wireshark and tshark on Ubuntu system without having to | ||
| # answer _any_ questions interactively, except perhaps providing your | ||
| # password when prompted by 'sudo'. | ||
| # https://askubuntu.com/questions/1275842/install-wireshark-without-confirm | ||
| echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections | ||
| sudo DEBIAN_FRONTEND=noninteractive apt-get -y install wireshark tshark | ||
| check_and_install "pip3" "python3-pip" | ||
| check_and_install "pip3" "python3-pip" | ||
| check_and_install "autoreconf" "autoconf automake libtool pkg-config autoconf-archive automake" | ||
| check_and_install "cmake" "cmake" | ||
| check_and_install "doxygen" "doxygen" | ||
| check_and_install "dpdk-testpmd" "dpdk dpdk-dev libdpdk-dev" | ||
| check_and_install_pkgs "libcjson-dev" | ||
| check_and_install_pkgs "libedit-dev" | ||
| check_and_install_pkgs "libffi-dev" | ||
|
|
||
| # ------------------------------------------------------------ | ||
| # 1. Cloning p4-dpdk-target | ||
| # ------------------------------------------------------------ | ||
| print_step "1/5 Cloning p4-dpdk-target..." | ||
| cd $SDE | ||
| git clone https://github.com/p4lang/p4-dpdk-target.git | ||
|
|
||
| # ------------------------------------------------------------ | ||
| # 2. System dependencies | ||
| # ------------------------------------------------------------ | ||
| print_step "2/5 Installing system dependencies..." | ||
|
|
||
| sudo apt update && sudo apt upgrade && sudo apt install -y python3-venv python3-full | ||
| python3 -m venv "$SDE/.venv" | ||
| source "$SDE/.venv/bin/activate" | ||
|
|
||
| cd "$SDE/p4-dpdk-target/tools/setup" | ||
| source ./p4sde_env_setup.sh "$SDE" | ||
| pip3 install distro | ||
| python3 install_dep.py | ||
|
|
||
| # ------------------------------------------------------------ | ||
| # 3. Build p4-dpdk-target | ||
| # ------------------------------------------------------------ | ||
| print_step "3/5 Building p4-dpdk-target..." | ||
|
|
||
| cd $SDE/p4-dpdk-target | ||
| git submodule update --init --recursive --force | ||
| ./autogen.sh | ||
| read -p "Build for TDI only? [y/N] " -n 1 -r | ||
| echo | ||
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| ./configure --prefix=$SDE_INSTALL --with-generic-flags=yes #For TDI build | ||
| else | ||
| ./configure --prefix=$SDE_INSTALL #For both bfrt and TDI build | ||
| fi | ||
| make -j | ||
| make install | ||
|
|
||
| # ------------------------------------------------------------ | ||
| # 4. Hugepages (required for DPDK) | ||
| # ------------------------------------------------------------ | ||
| print_step "4/5 Configuring hugepages..." | ||
| read -p "Configure hugepages? [y/N] " -n 1 -r | ||
| echo | ||
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| sudo sysctl -w vm.nr_hugepages=1024 || true | ||
| sudo mkdir -p /mnt/huge || true | ||
| mount | grep hugetlbfs || sudo mount -t hugetlbfs nodev /mnt/huge || true | ||
| else | ||
| echo "Skipping hugepages configuration." | ||
| fi | ||
|
|
||
| # ------------------------------------------------------------ | ||
| # 5. Hugepages permissions | ||
| # ------------------------------------------------------------ | ||
| print_step "5/5 Configuring hugepages permissions..." | ||
| read -p "Configure hugepages permissions? [y/N] " -n 1 -r | ||
| echo | ||
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| sudo chown $(id -u):$(id -g) /dev/hugepages | ||
| sudo chmod 700 /dev/hugepages | ||
| else | ||
| echo "Skipping hugepages permissions configuration." | ||
| fi | ||
|
|
||
| echo -e "${BOLD}${GREEN}DONE ✔${NC}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the version of install_p4_dpdk.sh as of commit 2 on 2026-Feb-01 from this PR's diff to a freshly installed Ubuntu 24.04 system running on an x86_64 processor.
The first problem encountered was that no Python module
distutilswas found:The second problem occurred during this step: "==> 3/5 Building p4-dpdk-target...". It could not find the command
autoreconf:The README.md changes proposed in this PR do not mention any prerequisites or other commands that should be run before
.install_p4_dpdk.sh, so it seems best ifinstall_p4_dpdk.shinstalls any packages that it requires. If these installation steps require a particular distribution of Linux, it seems reasonable to document what distributions the script has been tested on in the README.md file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll run it on
Ubuntu 24.04and I'll fix itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect the issues I found are not a difference between Ubuntu 22.04 and Ubuntu 24.04, but between a fresh minimal install of Ubuntu vs. many packages already installed. If you have an easy way to create a fresh minimal install of Ubuntu 22.04 (or 24.04), I suspect you should experience the same issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have address your comment, but I have to test it on Ubuntu 24.04 and 22.04