msquic/scripts/make-packages.sh

217 строки
5.8 KiB
Bash
Исходник Обычный вид История

2021-06-10 00:26:07 +03:00
#!/bin/bash
usage()
{
echo "Usage: $0 [-output <directory>] [-config Debug]"
exit 1
}
2021-06-10 00:26:07 +03:00
OS=$(uname)
ARCH=$(uname -m)
PKGARCH=${ARCH}
2021-06-10 00:26:07 +03:00
FPM=`which fpm` 2>/dev/null
CONFIG=Release
NAME=libmsquic
2023-02-16 23:55:38 +03:00
TLS=openssl
TLSVERSION=1.1
CONFLICTS=
DESCRIPTION="Microsoft implementation of the IETF QUIC protocol"
2022-04-10 18:05:28 +03:00
VENDOR="Microsoft"
MAINTAINER="Microsoft QUIC Team <quicdev@microsoft.com>"
2021-06-10 00:26:07 +03:00
VER_MAJOR=$(cat ./src/inc/msquic.ver | grep 'define VER_MAJOR'| cut -d ' ' -f 3)
VER_MINOR=$(cat ./src/inc/msquic.ver | grep 'define VER_MINOR'| cut -d ' ' -f 3)
VER_PATCH=$(cat ./src/inc/msquic.ver | grep 'define VER_PATCH'| cut -d ' ' -f 3)
if [ -z "$FPM" ]; then
echo Install 'fpm'
exit 1
fi
if [ "$OS" == 'Linux' ]; then
OS=linux
2021-07-25 19:14:07 +03:00
LIBEXT=so
2021-06-10 00:26:07 +03:00
if [ "$ARCH" == 'x86_64' ]; then
ARCH='x64'
LIBDIR="lib64"
else
LIBDIR="lib"
2022-08-05 15:20:31 +03:00
if [ "$ARCH" == "aarch64" ]; then
ARCH=arm64
else
if [ "$ARCH" == "armv7l" ]; then
ARCH=arm
else
ARCH=x86
fi
fi
2021-06-10 00:26:07 +03:00
fi
else
2021-07-25 19:14:07 +03:00
if [ "$OS" == 'Darwin' ]; then
OS=macos
ARCH=x64
LIBEXT=dylib
else
echo Only Linux and macOS packaging is supported at the moment.
2021-06-10 00:26:07 +03:00
exit 1
2021-07-25 19:14:07 +03:00
fi
2021-06-10 00:26:07 +03:00
fi
# process arguments and allow to override default values
while :; do
if [ $# -le 0 ]; then
break
fi
lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
case $lowerI in
2022-08-05 15:20:31 +03:00
-a|-arch|--arch)
shift
2022-08-05 15:20:31 +03:00
ARCH=$1
if [ "$ARCH" == 'arm64' ]; then
PKGARCH=aarch64
fi
if [ "$ARCH" == 'arm' ]; then
PKGARCH=armhf
fi
2022-08-05 15:20:31 +03:00
;;
-d|-debug|--debug)
CONFIG=Debug
;;
2023-02-16 23:55:38 +03:00
-c|-config|--config)
shift
CONFIG=$1
;;
-o|-output|--output)
shift
OUTPUT=$1
;;
2023-02-16 23:55:38 +03:00
-t|-tls|--tls)
shift
TLS=$1
case $TLS in
'openssl')
;;
'openssl3')
TLSVERSION=3
;;
*)
echo "Unknown TLS version '$TLS'."
exit 1
esac
;;
2021-07-25 19:14:07 +03:00
-\?|-h|--help)
usage
exit 1
;;
*)
echo unknown argument
;;
esac
shift
done
if [ ${CONFIG} != 'Release' ]; then
NAME=libmsquic-debug
2022-04-10 18:05:28 +03:00
CONFLICTS='libmsquic'
else
2022-04-10 18:05:28 +03:00
CONFLICTS='libmsquic-debug'
fi
2023-02-16 23:55:38 +03:00
ARTIFACTS="artifacts/bin/${OS}/${ARCH}_${CONFIG}_${TLS}"
if [ -z ${OUTPUT} ]; then
2023-02-16 23:55:38 +03:00
OUTPUT="artifacts/packages/${OS}/${ARCH}_${CONFIG}_${TLS}"
fi
echo "ARCH=$ARCH PKGARCH=$PKGARCH ARTIFACTS=$ARTIFACTS"
2021-06-10 00:26:07 +03:00
mkdir -p ${OUTPUT}
2021-07-25 19:14:07 +03:00
if [ "$OS" == "linux" ]; then
# RedHat/CentOS
FILES="${ARTIFACTS}/libmsquic.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}=/usr/${LIBDIR}/libmsquic.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
FILES="${FILES} ${ARTIFACTS}/libmsquic.${LIBEXT}.${VER_MAJOR}=/usr/${LIBDIR}/libmsquic.${LIBEXT}.${VER_MAJOR}"
if [ -e "$ARTIFACTS/libmsquic.lttng.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}" ]; then
FILES="${FILES} ${ARTIFACTS}/libmsquic.lttng.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}=/usr/${LIBDIR}/libmsquic.lttng.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
2021-07-25 19:14:07 +03:00
fi
if [ "$PKGARCH" == 'aarch64' ] || [ "$PKGARCH" == 'x86_64' ]; then
BITS='64bit'
fi
2022-04-10 18:05:28 +03:00
fpm \
--force \
--input-type dir \
--output-type rpm \
--architecture ${PKGARCH} \
2022-04-10 18:05:28 +03:00
--name ${NAME} \
--provides ${NAME} \
2023-02-16 23:55:38 +03:00
--depends "libcrypto.so.${TLSVERSION}()(${BITS})" \
--depends "libnuma.so.1()(${BITS})" \
2022-04-10 18:05:28 +03:00
--conflicts ${CONFLICTS} \
--version ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH} \
--description "${DESCRIPTION}" \
2022-04-10 18:05:28 +03:00
--vendor "${VENDOR}" \
--maintainer "${MAINTAINER}" \
--package "${OUTPUT}" \
--license MIT \
--url https://github.com/microsoft/msquic \
--log error \
2021-07-25 19:14:07 +03:00
${FILES}
2021-06-10 00:26:07 +03:00
2021-07-25 19:14:07 +03:00
# Debian/Ubuntu
2022-08-05 15:20:31 +03:00
if [ "$ARCH" == 'x64' ]; then
2021-07-25 19:14:07 +03:00
LIBDIR="lib/x86_64-linux-gnu"
fi
2022-08-05 15:20:31 +03:00
if [ "$ARCH" == 'arm64' ];then
LIBDIR="lib/aarch64-linux-gnu"
fi
if [ "$ARCH" == 'arm' ];then
LIBDIR="lib/arm-linux-gnueabihf"
fi
FILES="${ARTIFACTS}/libmsquic.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}=/usr/${LIBDIR}/libmsquic.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
FILES="${FILES} ${ARTIFACTS}/libmsquic.${LIBEXT}.${VER_MAJOR}=/usr/${LIBDIR}/libmsquic.${LIBEXT}.${VER_MAJOR}"
if [ -e "$ARTIFACTS/libmsquic.lttng.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}" ]; then
FILES="${FILES} ${ARTIFACTS}/libmsquic.lttng.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}=/usr/${LIBDIR}/libmsquic.lttng.${LIBEXT}.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
2021-07-25 19:14:07 +03:00
fi
2022-04-10 18:05:28 +03:00
fpm \
--force \
--input-type dir \
--output-type deb \
--architecture ${PKGARCH} \
2022-04-10 18:05:28 +03:00
--name ${NAME} \
--provides ${NAME} \
--conflicts ${CONFLICTS} \
2023-02-16 23:55:38 +03:00
--depends "libssl${TLSVERSION}" \
--depends "libnuma1" \
2022-04-10 18:05:28 +03:00
--version ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH} \
--description "${DESCRIPTION}" \
2022-04-10 18:05:28 +03:00
--vendor "${VENDOR}" \
--maintainer "${MAINTAINER}" \
--package "${OUTPUT}" \
--license MIT \
--url https://github.com/microsoft/msquic \
--log error \
2021-07-25 19:14:07 +03:00
${FILES}
fi
2022-04-10 18:05:28 +03:00
# macOS
2021-07-25 19:14:07 +03:00
if [ "$OS" == "macos" ]; then
2022-04-10 18:05:28 +03:00
fpm \
--force \
--input-type dir \
--output-type osxpkg \
--name ${NAME} \
--provides ${NAME} \
--conflicts ${CONFLICTS} \
--version ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH} \
2021-07-25 19:14:07 +03:00
--description "${DESCRIPTION}" \
2022-04-10 18:05:28 +03:00
--vendor "${VENDOR}" \
--maintainer "${MAINTAINER}" \
--package "${OUTPUT}" \
--license MIT \
--url https://github.com/microsoft/msquic \
--log error \
"$ARTIFACTS/libmsquic.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}.dylib"=/usr/local/lib/libmsquic.${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}.dylib
2021-07-25 19:14:07 +03:00
fi