-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cannelloni/libsctp source code to archive
- Loading branch information
1 parent
4eb733a
commit e2d241f
Showing
6 changed files
with
184 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,52 @@ | ||
ARG DOCKCROSS_REGISTRY=docker.io/dockcross | ||
ARG DOCKCROSS_IMAGE=linux-arm64 | ||
ARG DOCKCROSS_VERSION=latest | ||
|
||
FROM dockcross/$DOCKCROSS_IMAGE:$DOCKCROSS_VERSION as cannelloni-builder | ||
ARG VERSION=1.1.0 | ||
ARG HASH=0dcb9277b21f916f5646574b9b2229d3b8e97d5e99b935a4d0b7509a5f0ccdcd | ||
FROM $DOCKCROSS_REGISTRY/$DOCKCROSS_IMAGE:$DOCKCROSS_VERSION as cannelloni-builder | ||
# Version arguments that may be controlled via docker build argument | ||
ARG CANNELLONI_VERSION=1.1.0 | ||
ARG CANNELLONI_HASH=0dcb9277b21f916f5646574b9b2229d3b8e97d5e99b935a4d0b7509a5f0ccdcd | ||
|
||
# Output definitions | ||
ENV TARGET_DIR=/tmp/cannelloni | ||
ENV CANNELLONI_BUILD_LOG=$TARGET_DIR/build-metadata-log.txt | ||
RUN mkdir $TARGET_DIR | ||
|
||
# Document docker build log arguments | ||
ARG DOCKCROSS_REGISTRY=docker.io/dockcross | ||
ARG DOCKCROSS_IMAGE=linux-arm64 | ||
ARG DOCKCROSS_VERSION=latest | ||
RUN echo -e "Built with $DOCKCROSS_REGISTRY/$DOCKCROSS_IMAGE:$DOCKCROSS_VERSION\n" | tee -a ${CANNELLONI_BUILD_LOG} | ||
|
||
RUN mkdir /tmp/cannelloni | ||
|
||
# Version definitions | ||
ENV CANNELLONI_VERSION=$CANNELLONI_VERSION | ||
ENV CANNELLONI_HASH=$CANNELLONI_HASH | ||
ENV LIBSCTP_VERSION=1.0.19 | ||
WORKDIR /tmp/libsctp | ||
# copy installed libraries to expected target location for cmake toolchain | ||
COPY build_libsctp.sh /build_libsctp.sh | ||
RUN /build_libsctp.sh | ||
ENV LIBSCTP_HASH=9251b1368472fb55aaeafe4787131bdde4e96758f6170620bc75b638449cef01 | ||
|
||
WORKDIR /tmp/cannelloni | ||
RUN wget https://github.com/mguentner/cannelloni/archive/refs/tags/v$VERSION.tar.gz -O cannelloni-$VERSION.tar.gz | ||
RUN echo "$HASH cannelloni-$VERSION.tar.gz" | sha256sum --check --status | ||
RUN tar --strip-components=1 -xvf cannelloni-$VERSION.tar.gz | ||
|
||
# Document build metadata | ||
RUN echo "Built with dockcross/$DOCKCROSS_IMAGE:$DOCKCROSS_VERSION\n" | tee -a /tmp/cannelloni/build-metadata.txt | ||
|
||
RUN cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DSCTP_INCLUDE_DIR=/tmp/libsctp/src/include/netinet/ -DSCTP_LIBRARY=/tmp/libsctp/src/lib/.libs/ -DSCTP_SUPPORT=ON 2>&1 | tee -a /tmp/cannelloni/build-metadata.txt | ||
RUN make 2>&1 | tee -a /tmp/cannelloni/build-metadata.txt | ||
# Build libsctp | ||
ENV CANNELLONI_BUILD_DIR=/tmp/cannelloni_build/ | ||
ENV LIBSCTP_BUILD_DIR=/tmp/libsctp_build/ | ||
WORKDIR $LIBSCTP_BUILD_DIR | ||
COPY build_libsctp.sh /build_libsctp.sh | ||
# https://github.com/docker/docs/blob/da4ccc81e6b1bbd585c9f5ac9a35b9c8684c5d57/content/build/building/best-practices.md#using-pipes | ||
# If you want the command to fail due to an error at any stage in the pipe, prepend set -o pipefail && to ensure that an unexpected error prevents the build from inadvertently succeeding. For example: | ||
RUN set -o pipefail && /build_libsctp.sh | tee -a ${CANNELLONI_BUILD_LOG} | ||
|
||
COPY checklib.sh /checklib.sh | ||
RUN /checklib.sh 2>&1 | tee -a /tmp/cannelloni/build-metadata.txt | ||
# Build cannelloni | ||
WORKDIR $CANNELLONI_BUILD_DIR | ||
COPY build_cannelloni.sh /build_cannelloni.sh | ||
RUN set -o pipefail && /build_cannelloni.sh | tee -a ${CANNELLONI_BUILD_LOG} | ||
|
||
# Bundle result files: create tar file as output | ||
WORKDIR /tmp/ | ||
RUN find $TARGET_DIR | ||
RUN tar cf /tmp/cannelloni.tar.gz cannelloni/* | ||
|
||
# rename libcannelloni in target directory | ||
RUN cp --remove-destination /tmp/cannelloni/libcannelloni-common.so.0.0.1 /tmp/cannelloni/libcannelloni-common.so.0 | ||
RUN mv cannelloni/gpl-2.0.txt cannelloni/cannelloni-license-gpl-2.0.txt | ||
# copy libsctp license to target directory | ||
RUN curl https://raw.githubusercontent.com/sctp/lksctp-tools/master/COPYING.lib --output /tmp/cannelloni/libsctp-license.txt | ||
# add note about source | ||
RUN echo "You can find a copy of the cannelloni source code here: https://github.com/mguentner/cannelloni/archive/refs/tags/v$VERSION.tar.gz " > /tmp/cannelloni/SOURCES.md | ||
RUN echo "You can find a copy of the libsctp source code here: https://github.com/sctp/lksctp-tools" >> /tmp/cannelloni/SOURCES.md | ||
|
||
# create tar file as output | ||
RUN tar cf /tmp/cannelloni.tar.gz \ | ||
cannelloni/SOURCES.md \ | ||
cannelloni/cannelloni cannelloni/libcannelloni-common.so.0 cannelloni/cannelloni-license-gpl-2.0.txt cannelloni/README.md \ | ||
cannelloni/build-metadata.txt \ | ||
cannelloni/libsctp-license.txt cannelloni/libsctp*.so* | ||
|
||
# create directory as output | ||
# RUN mkdir -p /cannelloni_${DOCKCROSS_IMAGE}_${VERSION}/ | ||
# RUN cp /tmp/cannelloni/libcannelloni-common.so.0 /tmp/cannelloni/cannelloni /tmp/cannelloni/README.md /tmp/cannelloni/gpl-2.0.txt /cannelloni_${DOCKCROSS_IMAGE}_${VERSION}/ | ||
|
||
# Separate build stage, all files in this stage are added to the final output | ||
FROM scratch AS export-stage | ||
ARG DOCKCROSS_IMAGE=linux-arm64 | ||
ARG VERSION=1.1.0 | ||
|
||
# copy tar file from builder | ||
COPY --from=cannelloni-builder /tmp/cannelloni.tar.gz /cannelloni_${DOCKCROSS_IMAGE}_${VERSION}.tar.gz | ||
|
||
# copy directory from builder | ||
# COPY --from=cannelloni-builder /cannelloni_${DOCKCROSS_IMAGE}_${VERSION}/ /cannelloni_${DOCKCROSS_IMAGE}_${VERSION}/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
set -x | ||
set -e | ||
|
||
############################################ | ||
# CONFIG | ||
############################################ | ||
# assumes to be run in a temporary directory | ||
VERSION="${CANNELLONI_VERSION:-1.1.0}" | ||
HASH="${CANNELLONI_HASH:-0dcb9277b21f916f5646574b9b2229d3b8e97d5e99b935a4d0b7509a5f0ccdcd}" | ||
TARGET_DIR="${TARGET_DIR:-/tmp/cannelloni}" | ||
DOWNLOAD_URL="https://github.com/mguentner/cannelloni/archive/refs/tags/v${VERSION}.tar.gz" | ||
|
||
# Download source code | ||
wget "$DOWNLOAD_URL" -O "cannelloni-$VERSION.tar.gz" | ||
echo "$HASH cannelloni-$VERSION.tar.gz" | sha256sum --check --status | ||
|
||
# Extract archive | ||
tar --strip-components=1 -xvf "cannelloni-$VERSION.tar.gz" | ||
|
||
# Check if libsctp is at the expected location | ||
if [ ! -e "netinet/sctp.h" ]; then | ||
echo "Could not find sctp header file! Aborting." | ||
exit 1 | ||
fi | ||
if [ ! -e "libsctp.so.1" ]; then | ||
echo "Could not find sctp library file! Aborting." | ||
exit 1 | ||
fi | ||
|
||
############################################ | ||
# Build cannelloni | ||
############################################ | ||
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DSCTP_INCLUDE_DIR=./netinet/ -DSCTP_LIBRARY=./ -DSCTP_SUPPORT=ON 2>&1 | ||
make 2>&1 | ||
|
||
echo Finished building cannelloni | ||
|
||
############################################ | ||
# COPY results to target directory | ||
############################################ | ||
mkdir -p "${TARGET_DIR}/sources/" | ||
cp --remove-destination libcannelloni-common.so.0.0.1 "${TARGET_DIR}"/libcannelloni-common.so.0 | ||
cp cannelloni "${TARGET_DIR}"/cannelloni | ||
cp cannelloni-"$VERSION".tar.gz "${TARGET_DIR}"/sources/ | ||
mv gpl-2.0.txt "${TARGET_DIR}"/cannelloni-license-gpl-2.0.txt | ||
echo "You can find a copy of the cannelloni source code attached to this archive." >> "${TARGET_DIR}/SOURCES.md" | ||
echo "The cannelloni source code was downloaded from here: $DOWNLOAD_URL." >> "${TARGET_DIR}/SOURCES.md" | ||
|
||
############################################ | ||
# CHECK result | ||
############################################ | ||
# for other architectures than x86_64, copy libraries to this location for cmake toolchain | ||
TARGET_XCC_DIR="$(ls -d /usr/xcc/*/*/sysroot/ 2>/dev/null || echo)" | ||
|
||
if [ -n "$TARGET_XCC_DIR" ]; then | ||
echo "Built with crosstool-ng" | ||
"$TARGET_XCC_DIR"/usr/bin/ldd --version | ||
echo -e "\nPrint shared object information on cannelloni library:" | ||
readelf -h "${TARGET_DIR}"/cannelloni | ||
else | ||
echo "Not a cross build." | ||
ldd --version | ||
ldd "${TARGET_DIR}"/cannelloni | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.