packaging: Fix debug package build

For debug symbols packages to build properly, we need to
instruct the compiler to produce debugging information
during the compilation process by adding a proper flag.
Additionally there is no point to create packages with
debug info in normal build, because it may crash the
package creation process if no debug info is found.

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
This commit is contained in:
Rafal Stefanowski 2022-05-18 15:15:53 +02:00
parent 8938310b61
commit 63f1c162b6
6 changed files with 45 additions and 17 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -30,13 +30,13 @@ archives:
@tools/pckgen $(PWD) tar zip
rpm:
@tools/pckgen $(PWD) rpm
@tools/pckgen $(PWD) rpm --debug
srpm:
@tools/pckgen $(PWD) srpm
deb:
@tools/pckgen $(PWD) deb
@tools/pckgen $(PWD) deb --debug
dsc:
@tools/pckgen $(PWD) dsc

View File

@ -78,6 +78,9 @@ CFLAGS += -O0 -g
else
CFLAGS += -O2 -D_FORTIFY_SOURCE=2
endif
ifdef DEBUG_PACKAGE
CFLAGS += -g3
endif
CFLAGS += -Wall -Werror -z relro -z now -fstack-protector -fPIC -Wformat -Wformat-security -fno-strict-aliasing
#

View File

@ -72,7 +72,7 @@ print_help() {
echo " -a, --arch <ARCH> target platform architecture for packages"
echo " -o, --output-dir <DIR> put all created files in the given directory;"
echo " default: 'SOURCES_PATH/packages/'"
echo " -d, --debug create all debug files and packages as well"
echo " -d, --debug include debug information and create debug packages"
echo " -c, --clean clean all temporary files and folders that"
echo " may have been left around if $THIS ended"
echo " unexpectedly in the previous run"
@ -302,12 +302,18 @@ rpm_spec_prepare() {
sed -i "s|<CAS_MODULES_DIR>|$CAS_MODULES_DIR|g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "s/<CAS_HOMEPAGE>/${CAS_HOMEPAGE//\//\\/}/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "s/<PACKAGE_MAINTAINER>/$PACKAGE_MAINTAINER/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
if [ "$DEBUG" ]; then
echo "--- Debug RPMs will be built as well"
sed -i "s/%define debug_package %{nil}//g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
echo "--- Debug info will be included and debug packages created as well"
sed -i "s/<MAKE_BUILD>/%make_build DEBUG_PACKAGE=1/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "/<DEBUG_PACKAGE>/d" "$RPM_SPECS_DIR/$CAS_NAME.spec"
if [[ $(check_os) =~ suse|sles ]]; then
sed -i "s/%prep/%debug_package\n\n\n%prep/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "/%prep/i %debug_package\n\n" "$RPM_SPECS_DIR/$CAS_NAME.spec"
fi
else
sed -i "s/<MAKE_BUILD>/%make_build/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "s/<DEBUG_PACKAGE>/%define debug_package %{nil}/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
fi
if [ ! -f "$RPM_SPECS_DIR/$CAS_NAME.spec" ]; then
@ -349,6 +355,16 @@ deb_control_files_prepare() {
sed -i "s/<PACKAGE_MAINTAINER>/$PACKAGE_MAINTAINER/g" "$file"
sed -i "s/<PACKAGE_DATE>/$PACKAGE_DATE/g" "$file"
done
if [ "$DEBUG" ]; then
echo "--- Debug info will be included and debug packages created as well"
sed -i "s/<MAKE_BUILD>/make -C casadm DEBUG_PACKAGE=1/g" "$DEB_SOURCES_DIR/debian/rules"
sed -i "s/<DEBUG_PACKAGE>/dh_strip --ddebs/g" "$DEB_SOURCES_DIR/debian/rules"
else
sed -i "s/<MAKE_BUILD>/make -C casadm/g" "$DEB_SOURCES_DIR/debian/rules"
sed -i "s/<DEBUG_PACKAGE>/dh_strip --no-ddebs/g" "$DEB_SOURCES_DIR/debian/rules"
fi
}
generate_rpm() {

View File

@ -4,6 +4,12 @@
-- <PACKAGE_MAINTAINER> <PACKAGE_DATE>
open-cas-linux (22.03.0.0683-1) trusty; urgency=medium
* Fix debug packages creation
-- Rafal Stefanowski <rafal.stefanowski@intel.com> Wed, 18 May 2022 12:03:22 +0100
open-cas-linux (20.03.3.0303-1) trusty; urgency=medium
* Update dependencies

View File

@ -10,26 +10,29 @@
%:
dh $@ --with dkms
override_dh_auto_configure :
override_dh_auto_configure:
override_dh_auto_build :
override_dh_auto_build:
(cd tools/; ./cas_version_gen build)
make -C casadm
<MAKE_BUILD>
override_dh_auto_install :
override_dh_auto_install:
(cd casadm; make install_files DESTDIR="$(shell pwd)/debian/tmp")
(cd utils; make install_files DESTDIR="$(shell pwd)/debian/tmp")
# clean and generate version again before installing sources for DKMS
make distclean
(cd tools/; ./cas_version_gen)
override_dh_dkms :
override_dh_dkms:
dh_dkms -V $(DEB_VERSION_UPSTREAM)
override_dh_installsystemd :
override_dh_installsystemd:
dh_installsystemd --no-start
override_dh_missing :
override_dh_strip:
<DEBUG_PACKAGE>
override_dh_gencontrol :
override_dh_missing:
override_dh_gencontrol:
dh_gencontrol -- -Vkver="$(shell uname -r)"

View File

@ -11,7 +11,7 @@
%global __python %{__python3}
%define debug_package %{nil}
<DEBUG_PACKAGE>
%define kver %(uname -r)
%define kver_filename k%{expand:%(kname="%{kver}"; echo "${kname%.*}" | sed -r "y/-/_/;")}
@ -56,7 +56,7 @@ This package contains only CAS kernel modules.
%build
./configure
%make_build
<MAKE_BUILD>
%install