updated build script
This commit is contained in:
parent
9fd5554cc0
commit
a8a5afc932
2 changed files with 99 additions and 17 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/mozilla-central
|
||||
/patches
|
114
builder.sh
Normal file → Executable file
114
builder.sh
Normal file → Executable file
|
@ -1,59 +1,139 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Define source paths
|
||||
SOURCE_PATH="/home/user/mozilla-central"
|
||||
SOURCE_PATH="./mozilla-central"
|
||||
PATCHES_DIR="$SOURCE_PATH/Spitfire"
|
||||
SOURCE_REPO="https://hg.mozilla.org/mozilla-central"
|
||||
PATCHES_REPO="https://weforgecode.xyz/Spitfire/Browser.git"
|
||||
|
||||
# Function to download Firefox source if not present
|
||||
SOURCE_PATH=$(realpath "$SOURCE_PATH")
|
||||
PATCHES_DIR=$(realpath "$PATCHES_DIR")
|
||||
|
||||
# Function to download Mozilla source if not present
|
||||
download_source() {
|
||||
if [ ! -d "$SOURCE_PATH" ]; then
|
||||
echo "Firefox source not found. Cloning from repository..."
|
||||
hg clone $SOURCE_REPO $SOURCE_PATH || { echo "Failed to clone Firefox repository. Exiting."; exit 1; }
|
||||
echo "Mozilla source not found. Cloning from repository..."
|
||||
hg clone "$SOURCE_REPO" "$SOURCE_PATH" || { echo "Failed to clone Mozilla repository. Exiting."; exit 1; }
|
||||
else
|
||||
echo "Firefox source already exists."
|
||||
echo "Mozilla source already exists."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to discard uncommitted changes
|
||||
discard_changes() {
|
||||
echo "Discarding uncommitted changes..."
|
||||
hg revert --all --no-backup
|
||||
hg revert --all --no-backup -R "$SOURCE_PATH"
|
||||
}
|
||||
|
||||
# Function to clean build
|
||||
clean_build() {
|
||||
echo "Cleaning build..."
|
||||
./mach clobber
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to source directory. Exiting."; exit 1; }
|
||||
./mach clobber || { echo "Failed to clean build. Exiting."; exit 1; }
|
||||
}
|
||||
|
||||
# Function to update Mozilla repository
|
||||
update_repo() {
|
||||
echo "Updating Mozilla repository..."
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to source directory. Exiting."; exit 1; }
|
||||
hg pull -u || { echo "Failed to update Mozilla repository. Exiting."; exit 1; }
|
||||
./mach update || { echo "Failed to update Mozilla repository. Exiting."; exit 1; }
|
||||
}
|
||||
|
||||
# Function to update patches
|
||||
update_patches() {
|
||||
echo "Updating patches..."
|
||||
git clone https://weforgecode.xyz/Spitfire/Branding.git || { echo "Failed to clone patches repository. Exiting."; exit 1; }
|
||||
if [ -d "$PATCHES_DIR" ]; then
|
||||
echo "Patches directory already exists. Cleaning and pulling updates..."
|
||||
cd "$PATCHES_DIR" || { echo "Failed to navigate to patches directory. Exiting."; exit 1; }
|
||||
git clean -xdf || { echo "Failed to clean patches directory. Exiting."; exit 1; }
|
||||
git pull origin master || { echo "Failed to pull updates from patches repository. Exiting."; exit 1; }
|
||||
else
|
||||
echo "Patches directory does not exist. Cloning repository..."
|
||||
git clone "$PATCHES_REPO" "$PATCHES_DIR" || { echo "Failed to clone patches repository. Exiting."; exit 1; }
|
||||
fi
|
||||
|
||||
echo "Copying files from patches directory to Firefox source directory..."
|
||||
rsync -av --exclude='.git' "$PATCHES_DIR/" "$SOURCE_PATH/" || { echo "Failed to copy files. Exiting."; exit 1; }
|
||||
}
|
||||
|
||||
# Function to configure and build Spitfire
|
||||
configure_and_build() {
|
||||
echo "Configuring Spitfire..."
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to source directory. Exiting."; exit 1; }
|
||||
./mach configure || { echo "Configuration failed. Exiting."; exit 1; }
|
||||
|
||||
echo "Building Spitfire..."
|
||||
./mach build || { echo "Build failed. Exiting."; exit 1; }
|
||||
}
|
||||
|
||||
# Main script execution
|
||||
download_source
|
||||
discard_changes
|
||||
clean_build
|
||||
update_repo
|
||||
update_patches
|
||||
configure_and_build
|
||||
# Function to print usage instructions
|
||||
print_help() {
|
||||
echo "Usage: ./builder.sh [options]"
|
||||
echo "Options:"
|
||||
echo " -a, --all : Perform all steps (build, clean, update)"
|
||||
echo " -b, --build : Build Spitfire"
|
||||
echo " -c, --clean : Clean build"
|
||||
echo " -u, --update : Update Mozilla repository"
|
||||
echo " -p, --patches : Update patches"
|
||||
echo " -h, --help : Display this help message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Spitfire build completed successfully."
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
-a|--all)
|
||||
all=true
|
||||
;;
|
||||
-b|--build)
|
||||
build=true
|
||||
;;
|
||||
-c|--clean)
|
||||
clean=true
|
||||
;;
|
||||
-u|--update)
|
||||
update=true
|
||||
;;
|
||||
-p|--patches)
|
||||
patches=true
|
||||
;;
|
||||
-h|--help)
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option: $key"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Main script execution based on flags
|
||||
if [ "$all" = true ]; then
|
||||
download_source
|
||||
discard_changes
|
||||
clean_build
|
||||
update_repo
|
||||
update_patches
|
||||
configure_and_build
|
||||
echo "Spitfire build completed successfully."
|
||||
if [ "$build" = true ]; then
|
||||
configure_and_build
|
||||
echo "Spitfire build completed successfully."
|
||||
elif [ "$clean" = true ]; then
|
||||
clean_build
|
||||
echo "Cleaned Firefox build."
|
||||
elif [ "$update" = true ]; then
|
||||
download_source
|
||||
update_repo
|
||||
echo "Mozilla repository updated."
|
||||
elif [ "$patches" = true ]; then
|
||||
download_source
|
||||
update_patches
|
||||
echo "Patches updated."
|
||||
else
|
||||
print_help
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue