Compare commits
3 Commits
2025.0526.
...
2025.0526.
Author | SHA1 | Date | |
---|---|---|---|
940c2a12a1 | |||
6ac651d4f0 | |||
84fd96e74e |
@ -1,86 +1,49 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
OUTPUT_DIR=${SCRIPT_DIR}/output
|
||||||
|
INSTALL_DIR=${HOME}/.local/bin
|
||||||
|
mkdir -p ${OUTPUT_DIR}
|
||||||
|
|
||||||
# Exit on error
|
# Exit on error
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Colors for output
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
JOBS=4
|
|
||||||
# Determine number of CPU cores for parallel build
|
|
||||||
if command -v nproc >/dev/null 2>&1; then
|
|
||||||
JOBS=$(nproc)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Function to print status messages
|
|
||||||
print_status() {
|
|
||||||
echo -e "${GREEN}[*] $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_error() {
|
|
||||||
echo -e "${RED}[!] $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_warning() {
|
|
||||||
echo -e "${YELLOW}[!] $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ensure we have latest dehydrate.
|
# ensure we have latest dehydrate.
|
||||||
dehydrate -u
|
dehydrate -u
|
||||||
|
|
||||||
# Check if build directory exists, if not create it
|
|
||||||
if [ ! -d "build" ]; then
|
|
||||||
print_status "Creating build directory..."
|
|
||||||
mkdir build
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enter build directory
|
function build_native() {
|
||||||
cd build
|
local BUILDDIR=${SCRIPT_DIR}/build/native
|
||||||
|
local PREVDIR=$PWD
|
||||||
|
local JOBS=$(nproc) # Set JOBS to the number of available CPU cores
|
||||||
|
mkdir -p ${BUILDDIR}
|
||||||
|
cd ${SCRIPT_DIR}
|
||||||
|
|
||||||
# Check if CMake is installed
|
CC="${HOME}/.musl-cross/x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc"
|
||||||
if ! command -v cmake &> /dev/null; then
|
CXX="${HOME}/.musl-cross/x86_64-linux-musl-native/bin/x86_64-linux-musl-g++"
|
||||||
print_error "CMake is not installed. Please install CMake first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if Ninja is installed
|
|
||||||
if ! command -v ninja &> /dev/null; then
|
|
||||||
print_error "Ninja is not installed. Please install Ninja first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if ccache is installed
|
cmake -B ${BUILDDIR} -G Ninja \
|
||||||
if ! command -v ccache &> /dev/null; then
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
print_warning "ccache is not installed. Builds will be slower without it."
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
print_warning "Consider installing ccache for faster builds."
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
fi
|
-DCMAKE_LINKER=mold \
|
||||||
|
-DCMAKE_C_COMPILER=${CC} \
|
||||||
|
-DCMAKE_CXX_COMPILER=${CXX}
|
||||||
|
|
||||||
# Configure with CMake
|
cd ${BUILDDIR}
|
||||||
print_status "Configuring with CMake..."
|
ninja -j"$JOBS"
|
||||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
|
||||||
|
|
||||||
# Build the project
|
#upx ${BUILDDIR}/dropshell
|
||||||
print_status "Building project..."
|
cp ${BUILDDIR}/dropshell ${OUTPUT_DIR}/dropshell.native
|
||||||
ninja -j"$JOBS"
|
|
||||||
|
|
||||||
# Check if build was successful
|
cd ${PREVDIR}
|
||||||
if [ $? -eq 0 ]; then
|
}
|
||||||
print_status "Build successful!"
|
|
||||||
else
|
|
||||||
print_error "Build failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_status "Auto-installing dropshell locally..."
|
build_native
|
||||||
mkdir -p "${HOME}/.local/bin"
|
|
||||||
cp "$SCRIPT_DIR/build/dropshell" "${HOME}/.local/bin/dropshell"
|
|
||||||
|
|
||||||
# Return to original directory
|
echo "Auto-installing dropshell locally..."
|
||||||
cd ..
|
mkdir -p "${INSTALL_DIR}"
|
||||||
|
cp "${OUTPUT_DIR}/dropshell.native" "${INSTALL_DIR}/dropshell"
|
||||||
print_status "Build process completed!"
|
ds version
|
||||||
|
echo "Build process completed!"
|
||||||
|
@ -107,6 +107,13 @@ if [ ! -d "$INSTALL_DIR/x86_64-linux-musl-cross" ]; then
|
|||||||
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/x86_64-linux-musl-cross.tgz"
|
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/x86_64-linux-musl-cross.tgz"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# x86_64 native
|
||||||
|
if [ ! -d "$INSTALL_DIR/x86_64-linux-musl-native" ]; then
|
||||||
|
echo "Downloading x86_64 musl native toolchain..."
|
||||||
|
wget -nc -O "$TMPDIR/x86_64-linux-musl-native.tgz" $MUSL_CC_URL/x86_64-linux-musl-native.tgz
|
||||||
|
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/x86_64-linux-musl-native.tgz"
|
||||||
|
fi
|
||||||
|
|
||||||
# aarch64
|
# aarch64
|
||||||
if [ ! -d "$INSTALL_DIR/aarch64-linux-musl-cross" ]; then
|
if [ ! -d "$INSTALL_DIR/aarch64-linux-musl-cross" ]; then
|
||||||
echo "Downloading aarch64 musl cross toolchain..."
|
echo "Downloading aarch64 musl cross toolchain..."
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
# Create output directory
|
# Create output directory
|
||||||
mkdir -p output
|
mkdir -p ${SCRIPT_DIR}/output
|
||||||
|
|
||||||
|
|
||||||
function build_arch() {
|
function build_arch() {
|
||||||
local arch=$1
|
local arch=$1
|
||||||
|
local PREVDIR=$PWD
|
||||||
|
cd ${SCRIPT_DIR}
|
||||||
|
|
||||||
if [ ! -f "${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-c++" ]; then
|
if [ ! -f "${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-c++" ]; then
|
||||||
echo "Musl cross compiler for ${arch} not found. Please run install_build_prerequisites.sh first."
|
echo "Musl cross compiler for ${arch} not found. Please run install_build_prerequisites.sh first."
|
||||||
@ -16,14 +20,16 @@ function build_arch() {
|
|||||||
CC="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-gcc"
|
CC="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-gcc"
|
||||||
CXX="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-g++"
|
CXX="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-g++"
|
||||||
|
|
||||||
BUILDDIR=build/${arch}
|
BUILDDIR=${SCRIPT_DIR}/build/${arch}
|
||||||
mkdir -p ${BUILDDIR}
|
mkdir -p ${BUILDDIR}
|
||||||
|
|
||||||
cmake -B ${BUILDDIR} -G Ninja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX}
|
cmake -B ${BUILDDIR} -G Ninja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX}
|
||||||
cmake --build ${BUILDDIR}
|
cmake --build ${BUILDDIR}
|
||||||
|
|
||||||
upx ${BUILDDIR}/dropshell
|
upx ${BUILDDIR}/dropshell
|
||||||
cp ${BUILDDIR}/dropshell output/dropshell.${arch}
|
cp ${BUILDDIR}/dropshell ${SCRIPT_DIR}/output/dropshell.${arch}
|
||||||
|
|
||||||
|
cd ${PREVDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
build_arch x86_64
|
build_arch x86_64
|
||||||
|
@ -6,16 +6,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
echo "Script directory: $SCRIPT_DIR"
|
echo "Script directory: $SCRIPT_DIR"
|
||||||
|
|
||||||
# Check for GITEA_TOKEN_DEPLOY or GITEA_TOKEN
|
# Check for GITEA_TOKEN_DEPLOY or GITEA_TOKEN
|
||||||
if [ -n "$GITEA_TOKEN_DEPLOY" ]; then
|
TOKEN="${GITEA_TOKEN_DEPLOY:-${GITEA_TOKEN}}"
|
||||||
TOKEN="$GITEA_TOKEN_DEPLOY"
|
[ -z "$TOKEN" ] && { echo "Neither GITEA_TOKEN_DEPLOY nor GITEA_TOKEN environment variable set!" >&2; exit 1; }
|
||||||
echo "Using GITEA_TOKEN_DEPLOY"
|
|
||||||
elif [ -n "$GITEA_TOKEN" ]; then
|
|
||||||
TOKEN="$GITEA_TOKEN"
|
|
||||||
echo "Using GITEA_TOKEN"
|
|
||||||
else
|
|
||||||
echo "Neither GITEA_TOKEN_DEPLOY nor GITEA_TOKEN environment variable set!" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
$SCRIPT_DIR/multibuild.sh
|
$SCRIPT_DIR/multibuild.sh
|
||||||
BUILD_DIR=$SCRIPT_DIR/build
|
BUILD_DIR=$SCRIPT_DIR/build
|
||||||
@ -23,18 +15,15 @@ BUILD_DIR=$SCRIPT_DIR/build
|
|||||||
OLD_PWD=$PWD
|
OLD_PWD=$PWD
|
||||||
cd $SCRIPT_DIR
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
|
# Check for required binaries
|
||||||
if [ ! -f "output/dropshell.x86_64" ]; then
|
REQUIRED_BINARIES=("dropshell.x86_64" "dropshell.aarch64")
|
||||||
echo "output/dropshell.x86_64 not found!" >&2
|
for binary in "${REQUIRED_BINARIES[@]}"; do
|
||||||
|
if [ ! -f "output/$binary" ]; then
|
||||||
|
echo "output/$binary not found!" >&2
|
||||||
echo "Please run multibuild.sh first." >&2
|
echo "Please run multibuild.sh first." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
if [ ! -f "output/dropshell.aarch64" ]; then
|
|
||||||
echo "output/dropshell.aarch64 not found!" >&2
|
|
||||||
echo "Please run multibuild.sh first." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
TAG=$("$SCRIPT_DIR/output/dropshell.x86_64" --version)
|
TAG=$("$SCRIPT_DIR/output/dropshell.x86_64" --version)
|
||||||
[ -z "$TAG" ] && echo "Failed to get version from dropshell.x86_64" >&2 && exit 1
|
[ -z "$TAG" ] && echo "Failed to get version from dropshell.x86_64" >&2 && exit 1
|
||||||
@ -89,23 +78,35 @@ if [ -z "$RELEASE_ID" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Function to find file in specified locations
|
||||||
|
find_file() {
|
||||||
|
local filename="$1"
|
||||||
|
shift # remove filename from args
|
||||||
|
local locations=("$@") # grab the rest of the args as locations
|
||||||
|
|
||||||
|
for loc in "${locations[@]}"; do
|
||||||
|
if [ -f "$loc/$filename" ]; then
|
||||||
|
echo "$loc/$filename"
|
||||||
|
return 0 # Found the file, return success
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "" # Return empty string if not found
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Upload binaries and install.sh
|
# Upload binaries and install.sh
|
||||||
for FILE in dropshell.x86_64 dropshell.aarch64 install.sh server_autosetup.sh; do
|
for FILE in dropshell.x86_64 dropshell.aarch64 install.sh server_autosetup.sh; do
|
||||||
if [ -f "output/$FILE" ]; then
|
# Pass the locations directly to the find_file function
|
||||||
filetoupload="output/$FILE"
|
filetoupload=$(find_file "$FILE" "output" "../" ".")
|
||||||
elif [ -f "../$FILE" ]; then
|
if [ -z "$filetoupload" ]; then
|
||||||
filetoupload="../$FILE"
|
echo "File $FILE not found in expected locations!" >&2
|
||||||
elif [ -f "$FILE" ]; then
|
|
||||||
filetoupload="$FILE"
|
|
||||||
else
|
|
||||||
echo "File $FILE not found!" >&2
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Auto-detect content type
|
# Auto-detect content type
|
||||||
ctype=$(file --mime-type -b "$filetoupload")
|
ctype=$(file --mime-type -b "$filetoupload")
|
||||||
|
|
||||||
curl -s -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$FILE" \
|
curl -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$FILE" \
|
||||||
-H "Content-Type: $ctype" \
|
-H "Content-Type: $ctype" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
--data-binary @"$filetoupload"
|
--data-binary @"$filetoupload"
|
||||||
|
Reference in New Issue
Block a user