mirror of
https://github.com/RetroDECK/AppImages.git
synced 2025-04-11 02:55:09 +00:00
Refactor appimage_maker.sh to run directly
This commit is contained in:
parent
750b468d3a
commit
57b0902591
|
|
@ -9,91 +9,90 @@ set -e
|
||||||
# $4: (Optional) Additional CMake arguments
|
# $4: (Optional) Additional CMake arguments
|
||||||
# $5...: (Optional) One or more patch file paths to be applied before building
|
# $5...: (Optional) One or more patch file paths to be applied before building
|
||||||
|
|
||||||
build_appimage() {
|
|
||||||
local REPO_URL="$1"
|
|
||||||
local APP_NAME="$2"
|
|
||||||
local APPIMAGE_OUTPUT="$3"
|
|
||||||
local CMAKE_ARGS="${4:-}"
|
|
||||||
shift 4
|
|
||||||
local PATCH_FILES=("$@") # Remaining arguments are patch files
|
|
||||||
|
|
||||||
# Static/temporary names based on the app name:
|
local REPO_URL="$1"
|
||||||
local CLONE_DIR="$APP_NAME"
|
local APP_NAME="$2"
|
||||||
local BUILD_DIR="build"
|
local APPIMAGE_OUTPUT="$3"
|
||||||
local APPDIR="${APP_NAME}.AppDir"
|
local CMAKE_ARGS="${4:-}"
|
||||||
|
shift 4
|
||||||
|
local PATCH_FILES=("$@") # Remaining arguments are patch files
|
||||||
|
|
||||||
# Save current directory
|
# Static/temporary names based on the app name:
|
||||||
local CURRENT_DIR
|
local CLONE_DIR="$APP_NAME"
|
||||||
CURRENT_DIR="$(pwd)"
|
local BUILD_DIR="build"
|
||||||
|
local APPDIR="${APP_NAME}.AppDir"
|
||||||
|
|
||||||
echo "--- AppImage Maker initiated ---"
|
# Save current directory
|
||||||
echo "Building AppImage for $APP_NAME"
|
local CURRENT_DIR
|
||||||
echo "Repository: $REPO_URL"
|
CURRENT_DIR="$(pwd)"
|
||||||
echo "AppImage output: $APPIMAGE_OUTPUT"
|
|
||||||
echo "CMake arguments: $CMAKE_ARGS"
|
|
||||||
if [ ${#PATCH_FILES[@]} -gt 0 ]; then
|
|
||||||
echo "Patch files: ${PATCH_FILES[*]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clone the repository if not already cloned
|
echo "--- AppImage Maker initiated ---"
|
||||||
if [ ! -d "$CLONE_DIR" ]; then
|
echo "Building AppImage for $APP_NAME"
|
||||||
echo "Cloning repository: $REPO_URL in $CLONE_DIR"
|
echo "Repository: $REPO_URL"
|
||||||
git clone "$REPO_URL" "$CLONE_DIR"
|
echo "AppImage output: $APPIMAGE_OUTPUT"
|
||||||
fi
|
echo "CMake arguments: $CMAKE_ARGS"
|
||||||
|
if [ ${#PATCH_FILES[@]} -gt 0 ]; then
|
||||||
|
echo "Patch files: ${PATCH_FILES[*]}"
|
||||||
|
fi
|
||||||
|
|
||||||
pushd "$CLONE_DIR" > /dev/null
|
# Clone the repository if not already cloned
|
||||||
|
if [ ! -d "$CLONE_DIR" ]; then
|
||||||
|
echo "Cloning repository: $REPO_URL in $CLONE_DIR"
|
||||||
|
git clone "$REPO_URL" "$CLONE_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
# Optionally checkout a specific branch or commit if desired
|
pushd "$CLONE_DIR" > /dev/null
|
||||||
# git checkout <branch-or-commit>
|
|
||||||
|
|
||||||
# Apply patch files, if provided
|
# Optionally checkout a specific branch or commit if desired
|
||||||
if [ ${#PATCH_FILES[@]} -gt 0 ]; then
|
# git checkout <branch-or-commit>
|
||||||
for patch in "${PATCH_FILES[@]}"; do
|
|
||||||
if [ -f "$patch" ]; then
|
|
||||||
echo "Applying patch: $patch"
|
|
||||||
patch -p1 < "$patch"
|
|
||||||
else
|
|
||||||
echo "Warning: Patch file $patch does not exist. Skipping."
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create build directory and build the project
|
# Apply patch files, if provided
|
||||||
mkdir -p "$BUILD_DIR"
|
if [ ${#PATCH_FILES[@]} -gt 0 ]; then
|
||||||
pushd "$BUILD_DIR" > /dev/null
|
for patch in "${PATCH_FILES[@]}"; do
|
||||||
echo "Building $APP_NAME in $BUILD_DIR"
|
if [ -f "$patch" ]; then
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=Release $CMAKE_ARGS
|
echo "Applying patch: $patch"
|
||||||
make -j"$(nproc)"
|
patch -p1 < "$patch"
|
||||||
popd > /dev/null
|
else
|
||||||
|
echo "Warning: Patch file $patch does not exist. Skipping."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Prepare the AppDir structure
|
# Create build directory and build the project
|
||||||
rm -rf "$APPDIR"
|
mkdir -p "$BUILD_DIR"
|
||||||
mkdir -p "$APPDIR/usr/bin"
|
pushd "$BUILD_DIR" > /dev/null
|
||||||
# Assumes the built executable is named as the app name and is located in the build directory
|
echo "Building $APP_NAME in $BUILD_DIR"
|
||||||
cp "$BUILD_DIR/$APP_NAME" "$APPDIR/usr/bin/"
|
cmake .. -DCMAKE_BUILD_TYPE=Release $CMAKE_ARGS
|
||||||
|
make -j"$(nproc)"
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
# Copy the desktop file and icon (assumed to be in the repository root with matching names)
|
# Prepare the AppDir structure
|
||||||
cp "${APP_NAME}.desktop" "$APPDIR/"
|
rm -rf "$APPDIR"
|
||||||
cp "${APP_NAME}.png" "$APPDIR/"
|
mkdir -p "$APPDIR/usr/bin"
|
||||||
|
# Assumes the built executable is named as the app name and is located in the build directory
|
||||||
|
cp "$BUILD_DIR/$APP_NAME" "$APPDIR/usr/bin/"
|
||||||
|
|
||||||
# Download appimagetool if not already present (placed one level above the clone directory)
|
# Copy the desktop file and icon (assumed to be in the repository root with matching names)
|
||||||
if [ ! -f "../appimagetool" ]; then
|
cp "${APP_NAME}.desktop" "$APPDIR/"
|
||||||
echo "Downloading appimagetool..."
|
cp "${APP_NAME}.png" "$APPDIR/"
|
||||||
wget -O ../appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
|
||||||
chmod +x ../appimagetool
|
|
||||||
else
|
|
||||||
echo "appimagetool already exists. Skipping download."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the AppImage using appimagetool
|
# Download appimagetool if not already present (placed one level above the clone directory)
|
||||||
echo "Creating AppImage..."
|
if [ ! -f "../appimagetool" ]; then
|
||||||
../appimagetool "$APPDIR" "$APPIMAGE_OUTPUT"
|
echo "Downloading appimagetool..."
|
||||||
|
wget -O ../appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||||
|
chmod +x ../appimagetool
|
||||||
|
else
|
||||||
|
echo "appimagetool already exists. Skipping download."
|
||||||
|
fi
|
||||||
|
|
||||||
echo "AppImage created: $APPIMAGE_OUTPUT"
|
# Create the AppImage using appimagetool
|
||||||
|
echo "Creating AppImage..."
|
||||||
|
../appimagetool "$APPDIR" "$APPIMAGE_OUTPUT"
|
||||||
|
|
||||||
popd > /dev/null
|
echo "AppImage created: $APPIMAGE_OUTPUT"
|
||||||
cd "$CURRENT_DIR"
|
|
||||||
}
|
popd > /dev/null
|
||||||
|
cd "$CURRENT_DIR"
|
||||||
|
|
||||||
# Example usage:
|
# Example usage:
|
||||||
# This will clone the repository into a folder named "dolphin-emu",
|
# This will clone the repository into a folder named "dolphin-emu",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue