|
@@ -66,6 +66,152 @@ class ScriptGenerator:
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ def _common_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
|
|
+ """Generate a common acquire script with actual download and extraction functionality."""
|
|
|
|
|
+ url = package_info.url or ""
|
|
|
|
|
+
|
|
|
|
|
+ return f"""#!/bin/sh
|
|
|
|
|
+# Acquire script for {package_info.name}
|
|
|
|
|
+
|
|
|
|
|
+# This script downloads and extracts the source code for {package_info.name}
|
|
|
|
|
+
|
|
|
|
|
+# Configuration
|
|
|
|
|
+SOURCE_URL="{url}"
|
|
|
|
|
+TEMP_DIR=$(mktemp -d)
|
|
|
|
|
+ARCHIVE_NAME=""
|
|
|
|
|
+EXTRACT_DIR="$PWD"
|
|
|
|
|
+
|
|
|
|
|
+# Error handling
|
|
|
|
|
+set -e
|
|
|
|
|
+trap 'rm -rf "$TEMP_DIR"' EXIT
|
|
|
|
|
+
|
|
|
|
|
+# Function to detect archive type
|
|
|
|
|
+detect_archive_type() {{
|
|
|
|
|
+ local filename="$1"
|
|
|
|
|
+ case "$filename" in
|
|
|
|
|
+ *.tar.gz|*.tgz) echo "tar.gz" ;;
|
|
|
|
|
+ *.tar.bz2|*.tbz2) echo "tar.bz2" ;;
|
|
|
|
|
+ *.tar) echo "tar" ;;
|
|
|
|
|
+ *.zip) echo "zip" ;;
|
|
|
|
|
+ *) echo "unknown" ;;
|
|
|
|
|
+ esac
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Function to download using wget or curl
|
|
|
|
|
+download_file() {{
|
|
|
|
|
+ local url="$1"
|
|
|
|
|
+ local output="$2"
|
|
|
|
|
+
|
|
|
|
|
+ echo "Downloading from $url..."
|
|
|
|
|
+
|
|
|
|
|
+ if command -v wget >/dev/null 2>&1; then
|
|
|
|
|
+ wget -O "$output" "$url"
|
|
|
|
|
+ elif command -v curl >/dev/null 2>&1; then
|
|
|
|
|
+ curl -L -o "$output" "$url"
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "Error: Neither wget nor curl is available for downloading"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ fi
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Function to extract archive with strip-components to flatten directory structure
|
|
|
|
|
+extract_archive() {{
|
|
|
|
|
+ local archive="$1"
|
|
|
|
|
+ local extract_to="$2"
|
|
|
|
|
+ local archive_type="$3"
|
|
|
|
|
+
|
|
|
|
|
+ echo "Extracting $archive (type: $archive_type) to $extract_to..."
|
|
|
|
|
+
|
|
|
|
|
+ case "$archive_type" in
|
|
|
|
|
+ tar.gz|tgz)
|
|
|
|
|
+ # Use --strip-components=1 to remove the top-level directory
|
|
|
|
|
+ tar -xzf "$archive" -C "$extract_to" --strip-components=1
|
|
|
|
|
+ ;;
|
|
|
|
|
+ tar.bz2|tbz2)
|
|
|
|
|
+ # Use --strip-components=1 to remove the top-level directory
|
|
|
|
|
+ tar -xjf "$archive" -C "$extract_to" --strip-components=1
|
|
|
|
|
+ ;;
|
|
|
|
|
+ tar)
|
|
|
|
|
+ # Use --strip-components=1 to remove the top-level directory
|
|
|
|
|
+ tar -xf "$archive" -C "$extract_to" --strip-components=1
|
|
|
|
|
+ ;;
|
|
|
|
|
+ zip)
|
|
|
|
|
+ # For zip, we need to extract to temp and then move contents
|
|
|
|
|
+ local zip_temp_dir="$extract_temp_dir/zip_extract"
|
|
|
|
|
+ mkdir -p "$zip_temp_dir"
|
|
|
|
|
+ unzip -q "$archive" -d "$zip_temp_dir"
|
|
|
|
|
+
|
|
|
|
|
+ # Find the top-level directory and move its contents up
|
|
|
|
|
+ for item in "$zip_temp_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Move contents of the subdirectory to extract_to
|
|
|
|
|
+ (cd "$item" && find . -mindepth 1 -maxdepth 1 -exec cp -r {{}} "$extract_to/" \\;)
|
|
|
|
|
+ break
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+ rm -rf "$zip_temp_dir"
|
|
|
|
|
+ ;;
|
|
|
|
|
+ *)
|
|
|
|
|
+ echo "Error: Unsupported archive type: $archive_type"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ ;;
|
|
|
|
|
+ esac
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Function to find source directory (now works with flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, we should check the current directory first
|
|
|
|
|
+ if [ -f "$search_dir/configure" ] || [ -f "$search_dir/CMakeLists.txt" ] || \
|
|
|
|
|
+ [ -f "$search_dir/meson.build" ] || [ -f "$search_dir/Makefile" ] || \
|
|
|
|
|
+ [ -f "$search_dir/setup.py" ] || [ -f "$search_dir/Cargo.toml" ] || \
|
|
|
|
|
+ [ -f "$search_dir/package.json" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # If no build system files found in current directory, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Main execution
|
|
|
|
|
+if [ -z "$SOURCE_URL" ]; then
|
|
|
|
|
+ echo "Error: No source URL provided for {package_info.name}"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Extract filename from URL
|
|
|
|
|
+ARCHIVE_NAME=$(basename "$SOURCE_URL")
|
|
|
|
|
+
|
|
|
|
|
+if [ -z "$ARCHIVE_NAME" ] || [ "$ARCHIVE_NAME" = "/" ]; then
|
|
|
|
|
+ # Generate a filename if none can be extracted
|
|
|
|
|
+ ARCHIVE_NAME="{package_info.name}_source.tar.gz"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Download the archive
|
|
|
|
|
+ARCHIVE_PATH="$TEMP_DIR/$ARCHIVE_NAME"
|
|
|
|
|
+download_file "$SOURCE_URL" "$ARCHIVE_PATH"
|
|
|
|
|
+
|
|
|
|
|
+# Detect archive type
|
|
|
|
|
+ARCHIVE_TYPE=$(detect_archive_type "$ARCHIVE_NAME")
|
|
|
|
|
+
|
|
|
|
|
+if [ "$ARCHIVE_TYPE" = "unknown" ]; then
|
|
|
|
|
+ echo "Error: Cannot determine archive type from filename: $ARCHIVE_NAME"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Extract directly to current directory with strip-components to flatten structure
|
|
|
|
|
+echo "Extracting archive contents to current directory..."
|
|
|
|
|
+extract_archive "$ARCHIVE_PATH" "$EXTRACT_DIR" "$ARCHIVE_TYPE"
|
|
|
|
|
+
|
|
|
|
|
+# Verify the extraction was successful
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir "$EXTRACT_DIR")
|
|
|
|
|
+echo "Source directory verified: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+echo "Source acquired for {package_info.name}"
|
|
|
|
|
+"""
|
|
|
|
|
+
|
|
|
def generate_scripts(self, package_info: PackageInfo, build_system: BuildSystem, output_dir: Path) -> None:
|
|
def generate_scripts(self, package_info: PackageInfo, build_system: BuildSystem, output_dir: Path) -> None:
|
|
|
"""Generate USM scripts for a package.
|
|
"""Generate USM scripts for a package.
|
|
|
|
|
|
|
@@ -125,21 +271,7 @@ class ScriptGenerator:
|
|
|
|
|
|
|
|
def _autotools_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _autotools_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for autotools-based packages."""
|
|
"""Generate acquire script for autotools-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For autotools packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _autotools_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _autotools_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for autotools-based packages."""
|
|
"""Generate build script for autotools-based packages."""
|
|
@@ -161,6 +293,38 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/configure" ] || [ -f "$search_dir/configure.ac" ] || [ -f "$search_dir/Makefile.am" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of an autotools source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for autotools files
|
|
|
|
|
+ if [ -f "$item/configure" ] || [ -f "$item/configure.ac" ] || [ -f "$item/Makefile.am" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Prepare the build
|
|
# Prepare the build
|
|
|
if [ -f "autogen.sh" ]; then
|
|
if [ -f "autogen.sh" ]; then
|
|
|
echo "Running autogen.sh..."
|
|
echo "Running autogen.sh..."
|
|
@@ -201,8 +365,37 @@ fi
|
|
|
|
|
|
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/configure" ] || [ -f "$search_dir/configure.ac" ] || [ -f "$search_dir/Makefile.am" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of an autotools source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for autotools files
|
|
|
|
|
+ if [ -f "$item/configure" ] || [ -f "$item/configure.ac" ] || [ -f "$item/Makefile.am" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Change to the source directory
|
|
# Change to the source directory
|
|
|
-cd "$BUILD_DIR"
|
|
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Install the package
|
|
# Install the package
|
|
|
echo "Installing..."
|
|
echo "Installing..."
|
|
@@ -213,21 +406,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _cmake_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _cmake_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for CMake-based packages."""
|
|
"""Generate acquire script for CMake-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For CMake packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _cmake_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _cmake_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for CMake-based packages."""
|
|
"""Generate build script for CMake-based packages."""
|
|
@@ -249,13 +428,42 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/CMakeLists.txt" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a CMake source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for CMake files
|
|
|
|
|
+ if [ -f "$item/CMakeLists.txt" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Create build directory
|
|
# Create build directory
|
|
|
mkdir -p "$BUILD_DIR"
|
|
mkdir -p "$BUILD_DIR"
|
|
|
cd "$BUILD_DIR"
|
|
cd "$BUILD_DIR"
|
|
|
|
|
|
|
|
# Configure the build
|
|
# Configure the build
|
|
|
echo "Configuring with CMake..."
|
|
echo "Configuring with CMake..."
|
|
|
-cmake -DCMAKE_INSTALL_PREFIX=/usr{custom_args} "$PWD"/..
|
|
|
|
|
|
|
+cmake -DCMAKE_INSTALL_PREFIX=/usr{custom_args} "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Build the package
|
|
# Build the package
|
|
|
echo "Building..."
|
|
echo "Building..."
|
|
@@ -296,21 +504,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _meson_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _meson_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for Meson-based packages."""
|
|
"""Generate acquire script for Meson-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For Meson packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _meson_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _meson_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for Meson-based packages."""
|
|
"""Generate build script for Meson-based packages."""
|
|
@@ -332,9 +526,38 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/meson.build" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Meson source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Meson files
|
|
|
|
|
+ if [ -f "$item/meson.build" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Configure the build
|
|
# Configure the build
|
|
|
echo "Configuring with Meson..."
|
|
echo "Configuring with Meson..."
|
|
|
-meson setup "$BUILD_DIR" --prefix=/usr{custom_args}
|
|
|
|
|
|
|
+meson setup "$BUILD_DIR" --prefix=/usr{custom_args} "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Build the package
|
|
# Build the package
|
|
|
echo "Building..."
|
|
echo "Building..."
|
|
@@ -372,21 +595,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _make_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _make_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for Make-based packages."""
|
|
"""Generate acquire script for Make-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For Make packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _make_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _make_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for Make-based packages."""
|
|
"""Generate build script for Make-based packages."""
|
|
@@ -403,6 +612,38 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/Makefile" ] || [ -f "$search_dir/makefile" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Make-based source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Make files
|
|
|
|
|
+ if [ -f "$item/Makefile" ] || [ -f "$item/makefile" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Build the package
|
|
# Build the package
|
|
|
echo "Building..."
|
|
echo "Building..."
|
|
|
make -j$(nproc)
|
|
make -j$(nproc)
|
|
@@ -430,8 +671,37 @@ fi
|
|
|
|
|
|
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/Makefile" ] || [ -f "$search_dir/makefile" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Make-based source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Make files
|
|
|
|
|
+ if [ -f "$item/Makefile" ] || [ -f "$item/makefile" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Change to the source directory
|
|
# Change to the source directory
|
|
|
-cd "$BUILD_DIR"
|
|
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Install the package
|
|
# Install the package
|
|
|
echo "Installing..."
|
|
echo "Installing..."
|
|
@@ -442,21 +712,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _python_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _python_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for Python-based packages."""
|
|
"""Generate acquire script for Python-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For Python packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _python_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _python_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for Python-based packages."""
|
|
"""Generate build script for Python-based packages."""
|
|
@@ -473,6 +729,38 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/setup.py" ] || [ -f "$search_dir/pyproject.toml" ] || [ -f "$search_dir/requirements.txt" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Python source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Python files
|
|
|
|
|
+ if [ -f "$item/setup.py" ] || [ -f "$item/pyproject.toml" ] || [ -f "$item/requirements.txt" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Build the package
|
|
# Build the package
|
|
|
echo "Building..."
|
|
echo "Building..."
|
|
|
python setup.py build
|
|
python setup.py build
|
|
@@ -500,8 +788,37 @@ fi
|
|
|
|
|
|
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/setup.py" ] || [ -f "$search_dir/pyproject.toml" ] || [ -f "$search_dir/requirements.txt" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Python source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Python files
|
|
|
|
|
+ if [ -f "$item/setup.py" ] || [ -f "$item/pyproject.toml" ] || [ -f "$item/requirements.txt" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Change to the source directory
|
|
# Change to the source directory
|
|
|
-cd "$BUILD_DIR"
|
|
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Install the package
|
|
# Install the package
|
|
|
echo "Installing..."
|
|
echo "Installing..."
|
|
@@ -512,21 +829,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _cargo_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _cargo_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for Cargo-based packages."""
|
|
"""Generate acquire script for Cargo-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For Cargo packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _cargo_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _cargo_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for Cargo-based packages."""
|
|
"""Generate build script for Cargo-based packages."""
|
|
@@ -543,6 +846,38 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/Cargo.toml" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Cargo source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Cargo files
|
|
|
|
|
+ if [ -f "$item/Cargo.toml" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Build the package
|
|
# Build the package
|
|
|
echo "Building..."
|
|
echo "Building..."
|
|
|
cargo build --release
|
|
cargo build --release
|
|
@@ -570,8 +905,37 @@ fi
|
|
|
|
|
|
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/Cargo.toml" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a Cargo source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for Cargo files
|
|
|
|
|
+ if [ -f "$item/Cargo.toml" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Change to the source directory
|
|
# Change to the source directory
|
|
|
-cd "$BUILD_DIR"
|
|
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Install the package
|
|
# Install the package
|
|
|
echo "Installing..."
|
|
echo "Installing..."
|
|
@@ -582,21 +946,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _npm_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _npm_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate acquire script for NPM-based packages."""
|
|
"""Generate acquire script for NPM-based packages."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For NPM packages, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _npm_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _npm_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generate build script for NPM-based packages."""
|
|
"""Generate build script for NPM-based packages."""
|
|
@@ -613,6 +963,38 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/package.json" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of an NPM source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for NPM files
|
|
|
|
|
+ if [ -f "$item/package.json" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Install dependencies
|
|
# Install dependencies
|
|
|
echo "Installing dependencies..."
|
|
echo "Installing dependencies..."
|
|
|
npm ci
|
|
npm ci
|
|
@@ -644,8 +1026,37 @@ fi
|
|
|
|
|
|
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/package.json" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of an NPM source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for NPM files
|
|
|
|
|
+ if [ -f "$item/package.json" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If still not found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# Change to the source directory
|
|
# Change to the source directory
|
|
|
-cd "$BUILD_DIR"
|
|
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
|
|
|
# Install the package globally
|
|
# Install the package globally
|
|
|
echo "Installing..."
|
|
echo "Installing..."
|
|
@@ -656,21 +1067,7 @@ echo "Installation completed for {package_info.name}"
|
|
|
|
|
|
|
|
def _generic_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _generic_acquire_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generic acquire script for unknown build systems."""
|
|
"""Generic acquire script for unknown build systems."""
|
|
|
- return f"""#!/bin/sh
|
|
|
|
|
-# Acquire script for {package_info.name}
|
|
|
|
|
-
|
|
|
|
|
-# This script is used to download the source code
|
|
|
|
|
-# It's typically used when creating USM packages from upstream sources
|
|
|
|
|
-
|
|
|
|
|
-# For unknown build systems, the source is usually already available
|
|
|
|
|
-# If you need to download from a specific URL, uncomment and modify:
|
|
|
|
|
-# wget -O - {package_info.url or 'https://example.com/source.tar.gz'} | tar -xz
|
|
|
|
|
-
|
|
|
|
|
-# Or if using git:
|
|
|
|
|
-# git clone {package_info.url or 'https://github.com/example/repo.git'} .
|
|
|
|
|
-
|
|
|
|
|
-echo "Source acquired for {package_info.name}"
|
|
|
|
|
-"""
|
|
|
|
|
|
|
+ return self._common_acquire_template(package_info, build_system)
|
|
|
|
|
|
|
|
def _generic_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
def _generic_build_template(self, package_info: PackageInfo, build_system: BuildSystem) -> str:
|
|
|
"""Generic build script for unknown build systems."""
|
|
"""Generic build script for unknown build systems."""
|
|
@@ -687,6 +1084,44 @@ fi
|
|
|
|
|
|
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
echo "Building {package_info.name} in $BUILD_DIR"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/configure" ] || [ -f "$search_dir/CMakeLists.txt" ] || \
|
|
|
|
|
+ [ -f "$search_dir/meson.build" ] || [ -f "$search_dir/Makefile" ] || \
|
|
|
|
|
+ [ -f "$search_dir/setup.py" ] || [ -f "$search_dir/Cargo.toml" ] || \
|
|
|
|
|
+ [ -f "$search_dir/package.json" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for common build system files
|
|
|
|
|
+ if [ -f "$item/configure" ] || [ -f "$item/CMakeLists.txt" ] || \
|
|
|
|
|
+ [ -f "$item/meson.build" ] || [ -f "$item/Makefile" ] || \
|
|
|
|
|
+ [ -f "$item/setup.py" ] || [ -f "$item/Cargo.toml" ] || \
|
|
|
|
|
+ [ -f "$item/package.json" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If no clear source directory found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# This is a generic build script for unknown build systems
|
|
# This is a generic build script for unknown build systems
|
|
|
# You may need to customize this based on the actual build system
|
|
# You may need to customize this based on the actual build system
|
|
|
|
|
|
|
@@ -701,7 +1136,7 @@ elif [ -f "CMakeLists.txt" ]; then
|
|
|
echo "Found CMakeLists.txt, using CMake..."
|
|
echo "Found CMakeLists.txt, using CMake..."
|
|
|
mkdir -p "$BUILD_DIR"
|
|
mkdir -p "$BUILD_DIR"
|
|
|
cd "$BUILD_DIR"
|
|
cd "$BUILD_DIR"
|
|
|
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
|
|
|
|
|
|
|
+ cmake -DCMAKE_INSTALL_PREFIX=/usr "$SOURCE_DIR"
|
|
|
make -j$(nproc)
|
|
make -j$(nproc)
|
|
|
else
|
|
else
|
|
|
echo "No known build system found. Please customize this script."
|
|
echo "No known build system found. Please customize this script."
|
|
@@ -731,17 +1166,53 @@ fi
|
|
|
|
|
|
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
echo "Installing {package_info.name} to $INSTALL_DIR (type: $INSTALL_TYPE)"
|
|
|
|
|
|
|
|
|
|
+# Function to find the source directory (updated for flattened extraction)
|
|
|
|
|
+find_source_dir() {{
|
|
|
|
|
+ local search_dir="$1"
|
|
|
|
|
+
|
|
|
|
|
+ # With flattened extraction, check current directory first
|
|
|
|
|
+ if [ -f "$search_dir/configure" ] || [ -f "$search_dir/CMakeLists.txt" ] || \
|
|
|
|
|
+ [ -f "$search_dir/meson.build" ] || [ -f "$search_dir/Makefile" ] || \
|
|
|
|
|
+ [ -f "$search_dir/setup.py" ] || [ -f "$search_dir/Cargo.toml" ] || \
|
|
|
|
|
+ [ -f "$search_dir/package.json" ]; then
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Look for common indicators of a source directory
|
|
|
|
|
+ for item in "$search_dir"/*; do
|
|
|
|
|
+ if [ -d "$item" ]; then
|
|
|
|
|
+ # Check for common build system files
|
|
|
|
|
+ if [ -f "$item/configure" ] || [ -f "$item/CMakeLists.txt" ] || \
|
|
|
|
|
+ [ -f "$item/meson.build" ] || [ -f "$item/Makefile" ] || \
|
|
|
|
|
+ [ -f "$item/setup.py" ] || [ -f "$item/Cargo.toml" ] || \
|
|
|
|
|
+ [ -f "$item/package.json" ]; then
|
|
|
|
|
+ echo "$item"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ # If no clear source directory found, return the search directory
|
|
|
|
|
+ echo "$search_dir"
|
|
|
|
|
+}}
|
|
|
|
|
+
|
|
|
|
|
+# Find the source directory
|
|
|
|
|
+SOURCE_DIR=$(find_source_dir ".")
|
|
|
|
|
+echo "Using source directory: $SOURCE_DIR"
|
|
|
|
|
+
|
|
|
|
|
+# Change to the source directory
|
|
|
|
|
+cd "$SOURCE_DIR"
|
|
|
|
|
+
|
|
|
# This is a generic install script for unknown build systems
|
|
# This is a generic install script for unknown build systems
|
|
|
# You may need to customize this based on the actual build system
|
|
# You may need to customize this based on the actual build system
|
|
|
|
|
|
|
|
# Try common install commands
|
|
# Try common install commands
|
|
|
if [ -f "Makefile" ] || [ -f "makefile" ]; then
|
|
if [ -f "Makefile" ] || [ -f "makefile" ]; then
|
|
|
echo "Found Makefile, using make install..."
|
|
echo "Found Makefile, using make install..."
|
|
|
- cd "$BUILD_DIR"
|
|
|
|
|
make DESTDIR="$INSTALL_DIR" install
|
|
make DESTDIR="$INSTALL_DIR" install
|
|
|
elif [ -f "install.sh" ]; then
|
|
elif [ -f "install.sh" ]; then
|
|
|
echo "Found install.sh, running it..."
|
|
echo "Found install.sh, running it..."
|
|
|
- cd "$BUILD_DIR"
|
|
|
|
|
./install.sh --prefix="$INSTALL_DIR/usr"
|
|
./install.sh --prefix="$INSTALL_DIR/usr"
|
|
|
else
|
|
else
|
|
|
echo "No known install method found. Please customize this script."
|
|
echo "No known install method found. Please customize this script."
|