Skip to content

Commit

Permalink
Ipmitool bookworm: Fix and patch enterprise-numbers URL (sonic-net#17878
Browse files Browse the repository at this point in the history
)

### Why I did it

ipmitool utility is used to access various HW sensors. Some platforms use "ipmitool raw " to read specific addresses. 

ipmitool_1.8.19-4_amd64.deb, that is part of bookworm has a defect. The package is missing file enterprise.txt that is expected by the "raw read" code path. 
It is so because the file the .deb tries to download at the build time does not have the necessary extension as it is available on remote server: https://www.iana.org/assignments/enterprise-numbers.txt

### How I did it

The defect had been fixed using coding changes in next unstable version of Linux. It is expected to be available in future stable version of the OS. Hence to keep the changes to minimal, the .dsc file is downloaded and only the Makefile is modified to download the correct file. To make is work as patch necessary changes are made.

#### How to verify it
Build log is attached and installation of the file is noted line sonic-net#2274
When using vanilla bookworm on platforms like 5212 or 5224:
-------------------------------------------------------------------
root@sonic:~# ipmitool raw 0x04 0x2d 0x31
IANA PEN registry open failed: No such file or directory
00 c0 01 80

When fixed we should not see the above error:
--------------------------------------------------
root@sonic:/home/admin# ipmitool raw 0x04 0x2d 0x31
 00 c0 00 80

### Description for the changelog

This change is to address ipmitool raw read issue. This patch must be removed once it is available in next stable Linux release that contains the fix. 

ipmitool/ipmitool@1edb0e2
  • Loading branch information
rajib-dutta1 authored and vivekrnv committed Mar 8, 2024
1 parent 4b8f172 commit a747fac
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 1 deletion.
1 change: 0 additions & 1 deletion build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
mtr-tiny \
locales \
cgroup-tools \
ipmitool \
ndisc6 \
makedumpfile \
conntrack \
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ sudo mkdir -p $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/ifupdown2_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f

# Install a patched version of ipmitool (and its dependencies via 'apt-get -y install -f')
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/ipmitool_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f

# Install a patched version of ntp (and its dependencies via 'apt-get -y install -f')
sudo dpkg --root=$FILESYSTEM_ROOT --force-confdef --force-confold -i $debs_path/ntp_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y \
Expand Down
11 changes: 11 additions & 0 deletions rules/ipmitool.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

SPATH := $($(IPMITOOL)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/ipmitool.mk rules/ipmitool.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(SPATH))

$(IPMITOOL)_CACHE_MODE := GIT_CONTENT_SHA
$(IPMITOOL)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(IPMITOOL)_DEP_FILES := $(DEP_FILES)


17 changes: 17 additions & 0 deletions rules/ipmitool.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ipmitool packages
IPMITOOL_VERSION = 1.8.19
IPMITOOL_VERSION_SUFFIX = 4
IPMITOOL_VERSION_FULL = $(IPMITOOL_VERSION)-$(IPMITOOL_VERSION_SUFFIX)
IPMITOOL = ipmitool_$(IPMITOOL_VERSION_FULL)_$(CONFIGURED_ARCH).deb
$(IPMITOOL)_SRC_PATH = $(SRC_PATH)/ipmitool
SONIC_MAKE_DEBS += $(IPMITOOL)
IPMITOOL_DBG = ipmitool-dbgsym_$(IPMITOOL_VERSION_FULL)_$(CONFIGURED_ARCH).deb
$(eval $(call add_derived_package,$(IPMITOOL),$(IPMITOOL_DBG)))
DBG_SRC_ARCHIVE += ipmitool
# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list}
# are archived into debug one image to facilitate debugging.
# Export these variables so they can be used in a sub-make
export IPMITOOL_VERSION
export IPMITOOL_VERSION_FULL
export IPMITOOL
export IPMITOOL_DBG
1 change: 1 addition & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
$(LINUX_KERNEL) \
$(SONIC_DEVICE_DATA) \
$(IFUPDOWN2) \
$(IPMITOOL) \
$(KDUMP_TOOLS) \
$(LIBPAM_RADIUS) \
$(LIBNSS_RADIUS) \
Expand Down
28 changes: 28 additions & 0 deletions src/ipmitool/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

MAIN_TARGET = $(IPMITOOL)
DERIVED_TARGETS = $(IPMITOOL_DBG)

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Remove any stale files
rm -rf ./ipmitool-$(IPMITOOL_VERSION) ./ipmitool*.{deb,udeb,dsc,gz,xz}
# Obtain ipmitool
dget https://deb.debian.org/debian/pool/main/i/ipmitool/ipmitool_$(IPMITOOL_VERSION_FULL).dsc
# Build source and Debian packages
pushd ipmitool-$(IPMITOOL_VERSION)

git init
git add -f *
git commit -m "unmodified ipmitool source"

# Apply patches
stg init
stg import -s ../patch/series
dpkg-buildpackage -rfakeroot -d -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)
popd
mv $* $(DERIVED_TARGETS) $(DEST)/

$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET)

113 changes: 113 additions & 0 deletions src/ipmitool/patch/0001-Changes-needed-to-install-enterprise.txt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
From 719292c4800054ead278affc2972d8f77babd227 Mon Sep 17 00:00:00 2001
From: rajib-dutta1 <rajib.dutta@dell.com>
Date: Wed, 10 Jan 2024 20:51:03 -0800
Subject: [PATCH] Changes needed to install enterprise.txt

---
Makefile.am | 40 ++++++++++++++++++++--------------------
configure.ac | 30 +++++++++++++++---------------
2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 355d3f0..ec9605c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,25 +49,25 @@ dist-hook:
.PHONY: install-pen-database uninstall-pen-database
.INTERMEDIATE: %.o %.la enterprise-numbers

-#if DOWNLOAD
-
-#enterprise-numbers:
-# @echo Downloading IANA PEN database...
-# @$(DOWNLOAD) "$(IANA_PEN)" > tmpfile.$$PPID || {\
-# echo "FAILED to download the IANA PEN database"; \
-# rm tmpfile.$$PPID; \
-# false; \
-# }
-# @mv tmpfile.$$PPID $@
-#
-#install-pen-database: enterprise-numbers
-# mkdir -m 755 -p $(DESTDIR)$(IANADIR)
-# $(INSTALL_DATA) $< $(DESTDIR)$(IANADIR)/
-#
-#uninstall-pen-database:
-# -rm -rf $(DESTDIR)$(IANADIR)/enterprise-numbers
-#
-#else
+if DOWNLOAD
+
+enterprise-numbers.txt:
+ @echo Downloading IANA PEN database...
+ @$(DOWNLOAD) "$(IANA_PEN)" > tmpfile.$$PPID || {\
+ echo "FAILED to download the IANA PEN database"; \
+ rm tmpfile.$$PPID; \
+ false; \
+ }
+ @mv tmpfile.$$PPID $@
+
+install-pen-database: enterprise-numbers.txt
+ mkdir -m 755 -p $(DESTDIR)$(IANADIR)
+ $(INSTALL_DATA) $< $(DESTDIR)$(IANADIR)/
+
+uninstall-pen-database:
+ -rm -rf $(DESTDIR)$(IANADIR)/enterprise-numbers.txt
+
+else

install-pen-database:
@echo "*** NOT installing the IANA PEN database."
@@ -77,7 +77,7 @@ uninstall-pen-database:
@echo "*** NOT uninstalling the IANA PEN database."
@echo "*** It was installed manually (if ever)."

-#endif
+endif

install-data-local: install-pen-database
mkdir -p $(DESTDIR)$(DOCDIR)
diff --git a/configure.ac b/configure.ac
index b4321c6..d6ba62b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,22 +56,22 @@ if test "x$exec_prefix" = "xNONE"; then
exec_prefix="$prefix"
fi

-#if test "x$WGET" = "x"; then
-# if test "x$CURL" = "x"; then
-# AC_MSG_WARN([** Neither wget nor curl could be found.])
-# AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !])
-# else
-# DOWNLOAD="$CURL --location --progress-bar"
-# AM_CONDITIONAL([DOWNLOAD], [true])
-# fi
-#else
-# DOWNLOAD="$WGET -c -nd -O -"
-# AM_CONDITIONAL([DOWNLOAD], [true])
-#fi
+if test "x$WGET" = "x"; then
+ if test "x$CURL" = "x"; then
+ AC_MSG_WARN([** Neither wget nor curl could be found.])
+ AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !])
+ else
+ DOWNLOAD="$CURL --location --progress-bar"
+ AM_CONDITIONAL([DOWNLOAD], [true])
+ fi
+else
+ DOWNLOAD="$WGET -c -nd -O -"
+ AM_CONDITIONAL([DOWNLOAD], [true])
+fi

-#AC_MSG_WARN([** Download is:])
-#AC_MSG_WARN($DOWNLOAD)
-#AC_SUBST(DOWNLOAD, $DOWNLOAD)
+AC_MSG_WARN([** Download is:])
+AC_MSG_WARN($DOWNLOAD)
+AC_SUBST(DOWNLOAD, $DOWNLOAD)

dnl
dnl set default option values
--
2.25.1

1 change: 1 addition & 0 deletions src/ipmitool/patch/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0001-Changes-needed-to-install-enterprise.txt.patch

0 comments on commit a747fac

Please sign in to comment.