Skip to content
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

Combined packaging and Travis CI build enhancements #365

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0844a84
Combined extensions pull request:
dreibh Sep 12, 2019
65c03ea
Added missing file.
dreibh Sep 12, 2019
a2c5a72
Updated build scripts
dreibh Sep 13, 2019
30e3026
Updated build scripts
dreibh Oct 16, 2019
03949b6
Updated build scripts
dreibh Oct 18, 2019
dcad20e
Updated build scripts
dreibh Dec 5, 2019
c6252eb
Updated build scripts
dreibh Dec 5, 2019
badf2d6
Header updates.
dreibh Dec 5, 2019
2bc6d62
Updated Travis CI configuration: removed Fedora 29, added Fedora 31.
dreibh Dec 5, 2019
b3f3b97
Updated Travis CI configuration: added Ubuntu 20.04.
dreibh Dec 5, 2019
4bcf939
Updated Travis CI configuration: updated FreeBSD releases.
dreibh Dec 5, 2019
de88bca
Updated build scripts
dreibh Feb 7, 2020
53e98b4
Merge remote-tracking branch 'upstream-sctplab/master' into dreibh/pa…
dreibh Feb 7, 2020
29dc37e
Version bump.
dreibh Feb 7, 2020
f78edcf
Updated build scripts
dreibh Feb 7, 2020
f779bf2
Updated build scripts
dreibh Feb 7, 2020
3dd0c81
A fix.
dreibh Feb 7, 2020
5f1e875
Merge remote-tracking branch 'upstream-sctplab/master' into dreibh/pa…
dreibh Apr 14, 2020
431d963
Updated build scripts
dreibh Apr 14, 2020
a4f4873
Updated build scripts
dreibh Apr 14, 2020
bfbb526
Merge branch 'master' into dreibh/packaging
dreibh Apr 14, 2020
77459aa
Updated Travis CI configuration: Ubuntu 19.04 (Disco Dingo) is now ob…
dreibh Apr 16, 2020
776293d
Updated Travis CI configuration for Ubuntu builds.
dreibh Apr 17, 2020
b2e7c67
Merge remote-tracking branch 'upstream-sctplab/master' into dreibh/pa…
dreibh Apr 23, 2020
930fd56
Updated build scripts
dreibh May 6, 2020
4784081
Updated build scripts
dreibh May 6, 2020
3e65c8e
Merge remote-tracking branch 'upstream-sctplab/master' into dreibh/pa…
dreibh Feb 16, 2022
0467ac8
Merge remote-tracking branch 'upstream-sctplab/master' into dreibh/pa…
dreibh Feb 16, 2022
b55a247
Merged upstream changes.
dreibh Feb 16, 2022
29da8b9
Packaging improvements.
dreibh Feb 16, 2022
6fc4b60
RPM spec update.
dreibh Feb 16, 2022
ddb577a
RPM spec improvements.
dreibh Feb 16, 2022
fc0b392
RPM spec update.
dreibh Feb 16, 2022
25b359f
Fix for 'error: 'cause_code' may be used uninitialized in this functi…
dreibh Feb 17, 2022
9846f9f
Dependency fix.
dreibh Feb 17, 2022
2d51cad
Version bump.
dreibh Feb 17, 2022
61d968a
Updated build scripts
dreibh Aug 31, 2022
839c38d
Updated CI scripts
dreibh Aug 31, 2022
b1e9842
Removed Vcs-* fields from debian/control.
dreibh Aug 31, 2022
44bde9d
Updated build scripts
dreibh Nov 15, 2023
8a26943
Updated CI scripts
dreibh Nov 15, 2023
dd58d5f
Updated build scripts
dreibh Nov 15, 2023
cf37bc4
Packaging clean-ups.
dreibh Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,34 @@
# SUCH DAMAGE.
#

project(usrsctplib C)
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.0.2)
project(libusrsctp C)

SET(BUILD_MAJOR "1")
SET(BUILD_MINOR "0")
SET(BUILD_PATCH "0~rc1")
set(BUILD_VERSION ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_PATCH})


# INSTALLATION_DIRECTORIES
#################################################

# See: https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html
INCLUDE(GNUInstallDirs)


# TARBALL
#################################################

set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_PATCH}")
set(CPACK_SOURCE_IGNORE_FILES
"${PROJECT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}-*;${PROJECT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}_*;/build/;/.git/;/CMakeFiles/;CMakeCache.txt$;.cmake$;.tar.gz$;/_CPack_Packages;/Makefile$;~$;/build-deb;/clean-deb;/filter-empty-entries;/make-symbols;/make-ppa;/make-deb;/debian.conf;/make-rpm;/rpm.conf;${CPACK_SOURCE_IGNORE_FILES}")
message("CPACK_SOURCE_IGNORE_FILES = ${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)

add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} clean package_source)

# Debug build type as default
if (NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -202,6 +228,18 @@ if (C_COMPILER_IS_MSVC_LIKE)
elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic -Wall -Wextra")

# Necessary for Fedora >= 30 and Ubuntu >= 19.10 builds:
check_c_compiler_flag(-Waddress-of-packed-member has_address_of_packed_member)
if (has_address_of_packed_member)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member")
endif()
check_c_compiler_flag(-Wsign-compare has_no_sign_compare)
if (has_no_sign_compare)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
endif()

check_c_compiler_flag(-Wfloat-equal has_wfloat_equal)
if (has_wfloat_equal)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal")
Expand Down
69 changes: 69 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
#
# Build Scripts
# Copyright (C) 2002-2020 by Thomas Dreibholz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact: [email protected]

# Bash options:
set -e


CMAKE_OPTIONS=""
while [ $# -gt 0 ] ; do
if [[ "$1" =~ ^(-|--)use-clang$ ]] ; then
# Use these settings for CLang:
export CXX=clang++
export CC=clang
elif [[ "$1" =~ ^(-|--)use-gcc$ ]] ; then
# Use these settings for GCC:
export CXX=g++
export CC=gcc
elif [[ "$1" =~ ^(-|--)debug$ ]] ; then
# Enable debugging build:
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_BUILD_TYPE=DEBUG"
elif [[ "$1" =~ ^(-|--)verbose$ ]] ; then
# Enable verbose Makefile:
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_VERBOSE_MAKEFILE=ON"
elif [ "$1" == "--" ] ; then
break
else
echo >&2 "Usage: autogen.sh [--use-clang|--use-gcc] [--debug] [--verbose]"
exit 1
fi
shift
done


# ====== Configure with CMake ===============================================
rm -f CMakeCache.txt
echo "CMake options:${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr $@ ."
cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr $@ .

# ------ Obtain number of cores ---------------------------------------------
# Try Linux
cores=`getconf _NPROCESSORS_ONLN 2>/dev/null || true`
if [ "${cores}" == "" ] ; then
# Try FreeBSD
cores=`sysctl -a | grep 'hw.ncpu' | cut -d ':' -f2 | tr -d ' ' || true`
fi
if [ "${cores}" == "" ] ; then
cores="1"
fi
echo "This system has ${cores} cores!"

# ====== Build ==============================================================
make -j${cores}
128 changes: 128 additions & 0 deletions build-deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env bash
#
# Debian/Ubuntu Packaging Scripts
# Copyright (C) 2002-2024 by Thomas Dreibholz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact: [email protected]

# Bash options:
set -e


# ====== Obtain package and version information =============================
OVERRIDE_PACKAGE_DISTRIBUTION="$1"

CHANGELOG_HEADER="`head -n1 debian/changelog`"

# The package name, e.g. MyApplication
PACKAGE=`echo ${CHANGELOG_HEADER} | sed -e "s/(.*//" -e "s/ //g"`
# The package distribution, e.g. precise, raring, ...
PACKAGE_DISTRIBUTION=`echo ${CHANGELOG_HEADER} | sed -e "s/[^)]*)//" -e "s/;.*//g" -e "s/ //g"`
# The package's version, e.g. 1.2.3-1ubuntu1
PACKAGE_VERSION=`echo ${CHANGELOG_HEADER} | sed -e "s/.*(//" -e "s/).*//" -e "s/ //g" -e "s/ //g" -e "s/^[0-9]://g"`
# The package's output version, e.g. 1.2.3-1ubuntu
OUTPUT_VERSION=`echo ${PACKAGE_VERSION} | sed -e "s/\(ubuntu\|ppa\)[0-9]*$/\1/"`
# The package's Debian version, e.g. 1.2.3-1
DEBIAN_VERSION=`echo ${OUTPUT_VERSION} | sed -e "s/\(ubuntu\|ppa\)$//1"`
# The package's upstream version, e.g. 1.2.3
UPSTREAM_VERSION=`echo ${DEBIAN_VERSION} | sed -e "s/-[0-9]*$//"`
# The package's plain upstream version, e.g. 1.2.3 (without e.g. ~svn<xxxx>)
PLAIN_VERSION=`echo ${UPSTREAM_VERSION} | sed -e "s/\([0-9\.]*\)[-+~].*$/\1/"`


echo -e "\x1b[34m######################################################################\x1b[0m"
echo -e "\x1b[34mCHANGELOG_HEADER: ${CHANGELOG_HEADER}\x1b[0m"
echo -e "\x1b[34mPACKAGE: ${PACKAGE}\x1b[0m"
echo -e "\x1b[34mPACKAGE_DISTRIBUTION: ${PACKAGE_DISTRIBUTION}\x1b[0m"
echo -e "\x1b[34mPACKAGE_VERSION ${PACKAGE_VERSION}\x1b[0m"
echo -e "\x1b[34mOUTPUT_VERSION: ${OUTPUT_VERSION}\x1b[0m"
echo -e "\x1b[34mDEBIAN_VERSION: ${DEBIAN_VERSION}\x1b[0m"
echo -e "\x1b[34mUPSTREAM_VERSION: ${UPSTREAM_VERSION}\x1b[0m"
echo -e "\x1b[34mPLAIN_VERSION: ${PLAIN_VERSION}\x1b[0m"
echo -e "\x1b[34m######################################################################\x1b[0m"

if [ ! -e ./packaging.conf ] ; then
echo >&2 "ERROR: packaging.conf does not exist -> no configuration for the new package!"
exit 1
fi
. ./packaging.conf

if [ "${OVERRIDE_PACKAGE_DISTRIBUTION}" != "" ] ; then
PACKAGE_DISTRIBUTION="${OVERRIDE_PACKAGE_DISTRIBUTION}"
echo ""
echo -e "\x1b[34m**** Overriding PACKAGE_DISTRIBUTION: PACKAGE_DISTRIBUTION=${PACKAGE_DISTRIBUTION}! ****\x1b[0m"
echo ""
fi


# ====== Create source package ==============================================
sudo echo ""
./clean-deb
./make-deb ${PACKAGE_DISTRIBUTION}

if [ "${ARCH}" == "" ] ; then
ARCH=`dpkg --print-architecture`
fi
if [ "${PACKAGE_DISTRIBUTION}" == "unstable" -o \
"${PACKAGE_DISTRIBUTION}" == "testing" -o \
"${PACKAGE_DISTRIBUTION}" == "stable" -o \
"${PACKAGE_DISTRIBUTION}" == "oldstable" -o \
"${PACKAGE_DISTRIBUTION}" == "default" ] ; then
if [ "${PACKAGE_DISTRIBUTION}" == "default" ] ; then
version=${PACKAGE_VERSION}
else
version=${DEBIAN_VERSION}
fi
changesFilesPattern="${PACKAGE}_${version}_${ARCH}*.changes"
dscFile=`ls ${PACKAGE}_${version}.dsc | tail -n1`
else
changesFilesPattern="${PACKAGE}_${OUTPUT_VERSION}~${PACKAGE_DISTRIBUTION}[0-9]_${ARCH}*.changes"
dscFile=`ls ${PACKAGE}_${OUTPUT_VERSION}~${PACKAGE_DISTRIBUTION}[0-9].dsc | tail -n1`
fi


# ====== Build binary package ===============================================
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Building binary package ========================================\x1b[0m"
echo -e ""

if [ ! -e "${dscFile}" ] ; then
echo >&2 "ERROR: Unable to find description file ${dscFile}!"
exit 1
fi
sudo OS=${OS} DIST=${DIST} ARCH=${ARCH} pbuilder build ${dscFile}


# ====== Run lintian ========================================================
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Running lintian ================================================\x1b[0m"
echo -e ""

changesFile=`find /var/cache/pbuilder/result/ -name "${changesFilesPattern}"`
if [ ! -e "${changesFile}" ] ; then
echo >&2 "ERROR: Unable to find changes file ${changesFile}!"
exit 1
fi

profile="ubuntu"
if [ "${PACKAGE_DISTRIBUTION}" == "unstable" -o \
"${PACKAGE_DISTRIBUTION}" == "testing" -o \
"${PACKAGE_DISTRIBUTION}" == "stable" -o \
"${PACKAGE_DISTRIBUTION}" == "oldstable" ] ; then
profile="debian"
fi
echo "Calling: lintian -iIEv --pedantic --suppress-tags file-references-package-build-path --profile ${profile} ${changesFile}"
lintian -iIEv --pedantic --suppress-tags file-references-package-build-path --profile ${profile} ${changesFile} || true
96 changes: 96 additions & 0 deletions build-rpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# Packaging Scripts
# Copyright (C) 2017-2024 by Thomas Dreibholz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact: [email protected]

# Bash options:
set -e


# ---------------------------------------------------------------------------
# USAGE:
# ./make-rpm => Use current distribution and architecture
# ./make-rpm fedora-30-x86_64 => F30, amd64
# ./make-rpm fedora-rawhide-i386 => F30, i386
# ...
# ---------------------------------------------------------------------------


DISTRIBUTIONS=`\
( \
while [ x$1 != "x" ] ; do \
echo $1
shift
done \
) | sort -u`
if [ "${DISTRIBUTIONS}" == "" ] ; then
release=`cat /etc/fedora-release | sed -e "s/^\(.*\) release \([0-9]*\) (\(.*\))$/\2/g"`
arch=`uname -m`

DISTRIBUTIONS="fedora-${release}-${arch}"
fi

PACKAGE=`grep "^Name:" rpm/*.spec | head -n1 | sed -e "s/Name://g" -e "s/[ \t]*//g"`
PACKAGE_VERSION=`grep "^Version:" rpm/*.spec | head -n1 | sed -e "s/Version://g" -e "s/[ \t]*//g"`

echo -e "\x1b[34m###########################################\x1b[0m"
echo -e "\x1b[34mPACKAGE: ${PACKAGE}\x1b[0m"
echo -e "\x1b[34mPACKAGE_VERSION: ${PACKAGE_VERSION}\x1b[0m"
echo -e "\x1b[34m###########################################\x1b[0m"


# ====== Create source RPM ==================================================
./make-srpm

PACKAGE_SRPM=`find $HOME/rpmbuild/SRPMS/ -name "${PACKAGE}-*-*.src.rpm"`
if [ ! -e "${PACKAGE_SRPM}" ] ; then
echo >&2 "ERROR: Cannot find SRPM ${PACKAGE}-*-*.src.rpm in $HOME/rpmbuild/SRPMS!"
exit 1
fi


# ====== Build binary RPMs ==================================================
# Create binary RPMs
for DISTRIBUTION in ${DISTRIBUTIONS} ; do
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Creating binary RPM for ${DISTRIBUTION} ==========\x1b[0m"
echo -e ""

# NOTE: DISTRIBUTION may point to another directory (e.g. "rawhide" instead of "30")!
if [ ! -e "/etc/mock/${DISTRIBUTION}.cfg" ] ; then
echo >&2 "ERROR: Cannot find /etc/mock/${DISTRIBUTION}.cfg!"
exit 1
fi

# Remove old files
find /var/lib/mock/${DISTRIBUTION}/result -name "${PACKAGE}-*.rpm" | xargs --no-run-if-empty rm -f

# Build the binary RPM
# NOTE: using old chroot instead of container, to allow running it inside a container!
mock -r ${DISTRIBUTION} --isolation=simple --init
mock -r ${DISTRIBUTION} --isolation=simple --installdeps ${PACKAGE_SRPM}
mock -r ${DISTRIBUTION} --isolation=simple --install openssl pesign
mock -r ${DISTRIBUTION} --isolation=simple --no-clean --rebuild ${PACKAGE_SRPM}

# Check whether files are at the right location
PACKAGE_RPMS=`find /var/lib/mock/${DISTRIBUTION}/result -name "${PACKAGE}-*-*.rpm" | grep -v "${PACKAGE}-*-*.src.rpm" || true`
if [ "${PACKAGE_RPMS}" == "" ] ; then
echo >&2 "ERROR: Cannot find RPMs!"
exit 1
fi
done
Loading
Loading