Skip to content

Commit

Permalink
feat: update dependencies script
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime1907 committed Oct 11, 2023
1 parent 3a573b0 commit aaa6e6f
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions update_dep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

set -e
set -x

# Change to whatever you want
JANSSON_VERSION="2.14"
CURL_VERSION="8.4.0"

LIB="all"
if [ -n "$1" ]; then
LIB="$1"
fi

PROJECT_PATH="$PWD"

if [[ "$LIB" == "jansson" || "$LIB" == "all" ]]; then
# JANSSON
TMP_DIR="/tmp"
TMP_DIR_JANSSON="$TMP_DIR/jansson"
rm -rf $TMP_DIR_JANSSON*
curl -Lo $TMP_DIR_JANSSON.tar.gz https://github.com/akheron/jansson/releases/download/v$JANSSON_VERSION/jansson-$JANSSON_VERSION.tar.gz
tar -xvf $TMP_DIR_JANSSON.tar.gz -C $TMP_DIR && mv $TMP_DIR/jansson-$JANSSON_VERSION $TMP_DIR_JANSSON
cd $TMP_DIR_JANSSON
mkdir -p build && cd build
cmake ../ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_CXX_STANDARD=14 -DCMAKE_INSTALL_PREFIX="$PWD/package"
make -j 8
make install
rm "$PWD/package/include/jansson_config.h"
cp -R "$PWD/package/include" ../
cd $PROJECT_PATH
cp -R "$TMP_DIR_JANSSON"/* ./jansson
fi

if [[ "$LIB" == "curl" || "$LIB" == "all" ]]; then
# CURL
CURL_VERSION_UNDERSCORE="${CURL_VERSION//./_}"

TMP_DIR="/tmp"
TMP_DIR_CURL="$TMP_DIR/curl"
rm -rf $TMP_DIR_CURL*
curl -Lo $TMP_DIR_CURL.tar.gz https://github.com/curl/curl/releases/download/curl-$CURL_VERSION_UNDERSCORE/curl-$CURL_VERSION.tar.gz
tar -xvf $TMP_DIR_CURL.tar.gz -C $TMP_DIR && mv $TMP_DIR/curl-$CURL_VERSION $TMP_DIR_CURL
cd $TMP_DIR_CURL
mkdir -p build && cd build
cmake ../ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_CXX_STANDARD=14 -DCMAKE_INSTALL_PREFIX="$PWD/package"
make -j 8
make install
cp -R "$PWD/package/include" ../
cd ..
cd $PROJECT_PATH
cp -R "$TMP_DIR_CURL"/* ./curl

CURL_AMBUILDER_SOURCES_PATH="$TMP_DIR_CURL/AMBuilder.sources"
echo "# LIB_CFILES" > $CURL_AMBUILDER_SOURCES_PATH
cat curl/lib/Makefile.in | grep -o ' [a-zA-Z0-9_]*\.c' | awk '!seen[$0]++' | sed 's/^[[:space:]]*//' | sort | sed "s/.*/'&',/" >> $CURL_AMBUILDER_SOURCES_PATH
echo "" >> $CURL_AMBUILDER_SOURCES_PATH

echo "# LIB_VAUTH_CFILES"
cat curl/lib/Makefile.in | grep -o 'vauth/[a-zA-Z0-9_]*\.c' | awk '!seen[$0]++' | sort | sed "s/.*/'&',/" >> $CURL_AMBUILDER_SOURCES_PATH
echo "" >> $CURL_AMBUILDER_SOURCES_PATH

echo "# LIB_VQUIC_CFILES"
cat curl/lib/Makefile.in | grep -o 'vquic/[a-zA-Z0-9_]*\.c' | awk '!seen[$0]++' | sort | sed "s/.*/'&',/" >> $CURL_AMBUILDER_SOURCES_PATH
echo "" >> $CURL_AMBUILDER_SOURCES_PATH

echo "# LIB_VSSH_CFILES"
cat curl/lib/Makefile.in | grep -o 'vssh/[a-zA-Z0-9_]*\.c' | awk '!seen[$0]++' | sort | sed "s/.*/'&',/" >> $CURL_AMBUILDER_SOURCES_PATH
echo "" >> $CURL_AMBUILDER_SOURCES_PATH

echo "# LIB_VTLS_CFILES"
cat curl/lib/Makefile.in | grep -o 'vtls/[a-zA-Z0-9_]*\.c' | awk '!seen[$0]++' | sort | sed "s/.*/'&',/" >> $CURL_AMBUILDER_SOURCES_PATH
echo "" >> $CURL_AMBUILDER_SOURCES_PATH
fi

0 comments on commit aaa6e6f

Please sign in to comment.