Merge pull request #1208 from rafalste/debug_packages

packaging: Fix debug package build
This commit is contained in:
Robert Baldyga 2022-09-06 11:45:23 +02:00 committed by GitHub
commit 8be913462f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 25 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

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2020-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -16,6 +16,7 @@ CAS_NAME="open-cas-linux"
CAS_HOMEPAGE="https://open-cas.github.io"
CAS_GIT="https://github.com/Open-CAS/open-cas-linux.git"
CAS_LICENSE_NAME="BSD-3-Clause"
CAS_MODULES_DIR="extra/block/opencas"
SUPPORTED_FROM_VERSION="20.03"
THIS=$(basename "$0")
ARCH="$(uname -i)"
@ -71,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"
@ -298,14 +299,21 @@ rpm_spec_prepare() {
sed -i "s/<CAS_NAME>/$CAS_NAME/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "s/<CAS_VERSION>/$CAS_VERSION/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
sed -i "s/<CAS_LICENSE_NAME>/$CAS_LICENSE_NAME/g" "$RPM_SPECS_DIR/$CAS_NAME.spec"
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
@ -341,11 +349,22 @@ deb_control_files_prepare() {
sed -i "s/<CAS_NAME>/$CAS_NAME/g" "$file"
sed -i "s/<CAS_VERSION>/$CAS_VERSION/g" "$file"
sed -i "s/<CAS_LICENSE_NAME>/$CAS_LICENSE_NAME/g" "$file"
sed -i "s|<CAS_MODULES_DIR>|$CAS_MODULES_DIR|g" "$file"
sed -i "s/<CAS_HOMEPAGE>/${CAS_HOMEPAGE//\//\\/}/g" "$file"
sed -i "s/<CAS_GIT>/${CAS_GIT//\//\\/}/g" "$file"
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,8 +4,8 @@ BUILT_MODULE_NAME[0]="cas_disk"
BUILT_MODULE_NAME[1]="cas_cache"
BUILT_MODULE_LOCATION[0]="modules/cas_disk/"
BUILT_MODULE_LOCATION[1]="modules/cas_cache/"
DEST_MODULE_LOCATION[0]="/extra/block/opencas"
DEST_MODULE_LOCATION[1]="/extra/block/opencas"
DEST_MODULE_LOCATION[0]="/<CAS_MODULES_DIR>"
DEST_MODULE_LOCATION[1]="/<CAS_MODULES_DIR>"
PRE_BUILD="./configure"
MAKE[0]="make -j -C modules/ KERNEL_VERSION=$kernelver"
AUTOINSTALL=yes

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/-/_/;")}
@ -24,7 +24,7 @@ Group: System
Vendor: Intel Corporation
License: <CAS_LICENSE_NAME>
URL: <CAS_HOMEPAGE>
Source0: https://github.com/Open-CAS/open-cas-linux/releases/download/v%{version}/%{name}-%{version}.tar.gz
Source0: https://github.com/Open-CAS/<CAS_NAME>/releases/download/v%{version}/%{name}-%{version}.tar.gz
Packager: <PACKAGE_MAINTAINER>
BuildRequires: coreutils, gawk, gcc, kernel-devel, kernel-headers, make
Requires: <CAS_NAME>-modules-%{version}, python3, sed, python3-PyYAML
@ -56,7 +56,7 @@ This package contains only CAS kernel modules.
%build
./configure
%make_build
<MAKE_BUILD>
%install
@ -88,7 +88,7 @@ depmod
. /etc/os-release
# Determine the exact location of installed modules to add them to weak-modules
for file in $(rpm -ql $(rpm -qa | grep <CAS_NAME>-modules)); do
if [[ "$file" =~ cas_.*\.ko$ ]]; then
if [[ "$file" =~ .*\.ko$ ]]; then
# realpath to resolve any possible symlinks (needed for weak-modules)
modules+=( $(realpath "$file") )
fi
@ -109,7 +109,7 @@ if [ $1 -eq 0 ]; then
if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
# Search for all CAS modules to remove them from weak-modules
# Use realpath to resolve any possible symlinks (needed for weak-modules)
realpath $(find /lib/modules/*/extra/block/opencas/ -name "cas_*.ko") >/var/run/rpm-open-cas-linux-modules
realpath $(find /lib/modules/%{kver}/<CAS_MODULES_DIR> -name "*.ko") >/var/run/rpm-<CAS_NAME>-modules
fi
fi
@ -117,8 +117,8 @@ fi
if [ $1 -eq 0 ]; then
. /etc/os-release
if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
modules=( $(cat /var/run/rpm-open-cas-linux-modules) )
rm -f /var/run/rpm-open-cas-linux-modules
modules=( $(cat /var/run/rpm-<CAS_NAME>-modules) )
rm -f /var/run/rpm-<CAS_NAME>-modules
printf "%s\n" "${modules[@]}" | weak-modules --no-initramfs --remove-modules
fi
depmod