diff --git a/Makefile b/Makefile index 6d8c2e4..7a6791a 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/casadm/Makefile b/casadm/Makefile index d48a18f..3d44ee9 100644 --- a/casadm/Makefile +++ b/casadm/Makefile @@ -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 # diff --git a/tools/pckgen b/tools/pckgen index b8dc278..518c511 100755 --- a/tools/pckgen +++ b/tools/pckgen @@ -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 target platform architecture for packages" echo " -o, --output-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/g" "$RPM_SPECS_DIR/$CAS_NAME.spec" sed -i "s//$CAS_VERSION/g" "$RPM_SPECS_DIR/$CAS_NAME.spec" sed -i "s//$CAS_LICENSE_NAME/g" "$RPM_SPECS_DIR/$CAS_NAME.spec" + sed -i "s||$CAS_MODULES_DIR|g" "$RPM_SPECS_DIR/$CAS_NAME.spec" sed -i "s//${CAS_HOMEPAGE//\//\\/}/g" "$RPM_SPECS_DIR/$CAS_NAME.spec" sed -i "s//$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 DEBUG_PACKAGE=1/g" "$RPM_SPECS_DIR/$CAS_NAME.spec" + sed -i "//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/g" "$RPM_SPECS_DIR/$CAS_NAME.spec" + sed -i "s//%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/g" "$file" sed -i "s//$CAS_VERSION/g" "$file" sed -i "s//$CAS_LICENSE_NAME/g" "$file" + sed -i "s||$CAS_MODULES_DIR|g" "$file" sed -i "s//${CAS_HOMEPAGE//\//\\/}/g" "$file" sed -i "s//${CAS_GIT//\//\\/}/g" "$file" sed -i "s//$PACKAGE_MAINTAINER/g" "$file" sed -i "s//$PACKAGE_DATE/g" "$file" done + + if [ "$DEBUG" ]; then + echo "--- Debug info will be included and debug packages created as well" + + sed -i "s//make -C casadm DEBUG_PACKAGE=1/g" "$DEB_SOURCES_DIR/debian/rules" + sed -i "s//dh_strip --ddebs/g" "$DEB_SOURCES_DIR/debian/rules" + else + sed -i "s//make -C casadm/g" "$DEB_SOURCES_DIR/debian/rules" + sed -i "s//dh_strip --no-ddebs/g" "$DEB_SOURCES_DIR/debian/rules" + fi } generate_rpm() { diff --git a/tools/pckgen.d/deb/debian/CAS_NAME-modules.dkms b/tools/pckgen.d/deb/debian/CAS_NAME-modules.dkms index 4862cb7..efdddfd 100644 --- a/tools/pckgen.d/deb/debian/CAS_NAME-modules.dkms +++ b/tools/pckgen.d/deb/debian/CAS_NAME-modules.dkms @@ -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]="/" +DEST_MODULE_LOCATION[1]="/" PRE_BUILD="./configure" MAKE[0]="make -j -C modules/ KERNEL_VERSION=$kernelver" AUTOINSTALL=yes diff --git a/tools/pckgen.d/deb/debian/changelog b/tools/pckgen.d/deb/debian/changelog index d12584b..34c7a94 100644 --- a/tools/pckgen.d/deb/debian/changelog +++ b/tools/pckgen.d/deb/debian/changelog @@ -4,6 +4,12 @@ -- +open-cas-linux (22.03.0.0683-1) trusty; urgency=medium + + * Fix debug packages creation + + -- Rafal Stefanowski Wed, 18 May 2022 12:03:22 +0100 + open-cas-linux (20.03.3.0303-1) trusty; urgency=medium * Update dependencies diff --git a/tools/pckgen.d/deb/debian/rules b/tools/pckgen.d/deb/debian/rules index 005e82c..eec70ba 100755 --- a/tools/pckgen.d/deb/debian/rules +++ b/tools/pckgen.d/deb/debian/rules @@ -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 + -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: + -override_dh_gencontrol : +override_dh_missing: + +override_dh_gencontrol: dh_gencontrol -- -Vkver="$(shell uname -r)" diff --git a/tools/pckgen.d/rpm/CAS_NAME.spec b/tools/pckgen.d/rpm/CAS_NAME.spec index c05d03c..ea3df0d 100644 --- a/tools/pckgen.d/rpm/CAS_NAME.spec +++ b/tools/pckgen.d/rpm/CAS_NAME.spec @@ -11,7 +11,7 @@ %global __python %{__python3} -%define debug_package %{nil} + %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: URL: -Source0: https://github.com/Open-CAS/open-cas-linux/releases/download/v%{version}/%{name}-%{version}.tar.gz +Source0: https://github.com/Open-CAS//releases/download/v%{version}/%{name}-%{version}.tar.gz Packager: BuildRequires: coreutils, gawk, gcc, kernel-devel, kernel-headers, make Requires: -modules-%{version}, python3, sed, python3-PyYAML @@ -56,7 +56,7 @@ This package contains only CAS kernel modules. %build ./configure -%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 -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}/ -name "*.ko") >/var/run/rpm--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--modules) ) + rm -f /var/run/rpm--modules printf "%s\n" "${modules[@]}" | weak-modules --no-initramfs --remove-modules fi depmod