package script added
This commit is contained in:
parent
5fd9a5f45f
commit
f904f731f3
5 changed files with 179 additions and 38 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/mozilla-central
|
||||
/patches
|
||||
/packages.json
|
||||
/packages_temp.json
|
18
APKINDEX-example
Normal file
18
APKINDEX-example
Normal file
|
@ -0,0 +1,18 @@
|
|||
C:c87e614f4e4716fa4c68a7dfc62bf77f10dfc4bd
|
||||
P:=mypackage
|
||||
V:=1.0.0
|
||||
A:=x86_64
|
||||
S:=123456
|
||||
I:=123456
|
||||
T:=My package description
|
||||
U:=https://example.com
|
||||
L:=GPL-2.0-only
|
||||
o:=mypackag5e
|
||||
m:=Maintain <maintainer@example.com>
|
||||
t:1722785057
|
||||
c:c87e614f4e4716fa4c68a7dfc62bf77f10dfc4bd
|
||||
D:=dependency1>=1.3.0
|
||||
p:=mypackage-=1.0.0.apk
|
||||
q:
|
||||
Z:c87e614f4e4716fa4c68a7dfc62bf77f10dfc4bd
|
||||
|
69
builder.sh
69
builder.sh
|
@ -9,11 +9,14 @@ PATCHES_REPO="https://weforgecode.xyz/Spitfire/Browser.git"
|
|||
SOURCE_PATH=$(realpath "$SOURCE_PATH") || { echo "Failed to resolve SOURCE_PATH. Exiting."; exit 1; }
|
||||
PATCHES_DIR=$(realpath "$PATCHES_DIR") || { echo "Failed to resolve PATCHES_DIR. Exiting."; exit 1; }
|
||||
|
||||
# Array to store errors
|
||||
errors=()
|
||||
|
||||
# Function to download Mozilla source if not present
|
||||
download_source() {
|
||||
if [ ! -d "$SOURCE_PATH" ]; then
|
||||
echo "Mozilla source not found. Cloning from repository..."
|
||||
hg clone "$SOURCE_REPO" "$SOURCE_PATH" || { echo "Failed to clone Mozilla repository. Exiting."; exit 1; }
|
||||
hg clone "$SOURCE_REPO" "$SOURCE_PATH" || errors+=("Failed to clone Mozilla repository.")
|
||||
else
|
||||
echo "Mozilla source already exists."
|
||||
fi
|
||||
|
@ -22,22 +25,22 @@ download_source() {
|
|||
# Function to discard uncommitted changes
|
||||
discard_changes() {
|
||||
echo "Discarding uncommitted changes..."
|
||||
hg revert --all --no-backup -R "$SOURCE_PATH" || { echo "Failed to revert changes in Mozilla repository. Exiting."; exit 1; }
|
||||
hg revert --all --no-backup -R "$SOURCE_PATH" || errors+=("Failed to revert changes in Mozilla repository.")
|
||||
}
|
||||
|
||||
# Function to clean build
|
||||
clean_build() {
|
||||
echo "Cleaning build..."
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to source directory. Exiting."; exit 1; }
|
||||
hg revert --all --no-backup || { echo "Failed to revert changes in Mozilla repository. Exiting."; exit 1; }
|
||||
./mach clobber || { echo "Failed to clean build. Exiting."; exit 1; }
|
||||
cd "$SOURCE_PATH" || { errors+=("Failed to navigate to source directory."); return; }
|
||||
hg revert --all --no-backup || errors+=("Failed to revert changes in Mozilla repository.")
|
||||
./mach clobber || errors+=("Failed to clean build.")
|
||||
}
|
||||
|
||||
# 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; }
|
||||
cd "$SOURCE_PATH" || { errors+=("Failed to navigate to source directory."); return; }
|
||||
hg pull -u || errors+=("Failed to update Mozilla repository.")
|
||||
}
|
||||
|
||||
# Function to update patches
|
||||
|
@ -45,56 +48,56 @@ update_patches() {
|
|||
echo "Updating patches..."
|
||||
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; }
|
||||
cd "$PATCHES_DIR" || { errors+=("Failed to navigate to patches directory."); return; }
|
||||
git clean -xdf || errors+=("Failed to clean patches directory.")
|
||||
|
||||
# Stash any local changes to ensure a clean rebase
|
||||
git stash push --include-untracked || { echo "Failed to stash local changes. Exiting."; exit 1; }
|
||||
git stash push --include-untracked || echo "No local changes to save."
|
||||
|
||||
# Fetching all branches
|
||||
git fetch || { echo "Failed to fetch updates from patches repository. Exiting."; exit 1; }
|
||||
git fetch || errors+=("Failed to fetch updates from patches repository.")
|
||||
|
||||
# Trying to rebase onto 'main' branch
|
||||
if git show-ref --verify --quiet refs/heads/main; then
|
||||
git rebase origin/main || { echo "Failed to rebase updates from main branch. Exiting."; exit 1; }
|
||||
git rebase origin/main || errors+=("Failed to rebase updates from main branch.")
|
||||
elif git show-ref --verify --quiet refs/heads/master; then
|
||||
# Fallback to 'master' branch if 'main' does not exist
|
||||
git rebase origin/master || { echo "Failed to rebase updates from master branch. Exiting."; exit 1; }
|
||||
git rebase origin/master || errors+=("Failed to rebase updates from master branch.")
|
||||
else
|
||||
echo "No valid branch (main or master) found in patches repository. Exiting."
|
||||
exit 1
|
||||
errors+=("No valid branch (main or master) found in patches repository.")
|
||||
return
|
||||
fi
|
||||
|
||||
# Drop stashed changes to discard local modifications
|
||||
git stash drop || { echo "Failed to drop stashed changes. Exiting."; exit 1; }
|
||||
# Check if there are any stashes before popping
|
||||
if git stash list | grep -q 'stash@{0}'; then
|
||||
git stash pop || errors+=("Failed to apply and drop stashed changes.")
|
||||
else
|
||||
echo "No stash entries found, skipping pop."
|
||||
fi
|
||||
else
|
||||
echo "Patches directory does not exist. Cloning repository..."
|
||||
git clone "$PATCHES_REPO" "$PATCHES_DIR" || { echo "Failed to clone patches repository. Exiting."; exit 1; }
|
||||
git clone "$PATCHES_REPO" "$PATCHES_DIR" || errors+=("Failed to clone patches repository.")
|
||||
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; }
|
||||
rsync -av --exclude='.git' "$PATCHES_DIR/" "$SOURCE_PATH/" || errors+=("Failed to copy files.")
|
||||
}
|
||||
|
||||
# Function to configure Spitfire
|
||||
configure() {
|
||||
echo "Configuring Spitfire..."
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to source directory. Exiting."; exit 1; }
|
||||
./mach configure || { echo "Configuration failed. Exiting."; exit 1; }
|
||||
cd "$SOURCE_PATH" || { errors+=("Failed to navigate to source directory."); return; }
|
||||
./mach configure || errors+=("Configuration failed.")
|
||||
}
|
||||
|
||||
# Function to build Spitfire
|
||||
build() {
|
||||
echo "Building Spitfire..."
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to source directory. Exiting."; exit 1; }
|
||||
./mach build || { echo "Build failed. Exiting."; exit 1; }
|
||||
cd "$SOURCE_PATH" || { errors+=("Failed to navigate to source directory."); return; }
|
||||
./mach build || errors+=("Build failed.")
|
||||
}
|
||||
|
||||
# Function to run the project after build
|
||||
run_project() {
|
||||
echo "Running the project..."
|
||||
cd "$SOURCE_PATH" || { echo "Failed to navigate to browser directory. Exiting."; exit 1; }
|
||||
./mach run || { echo "Failed to run the project. Exiting."; exit 1; }
|
||||
cd "$SOURCE_PATH" || { errors+=("Failed to navigate to browser directory."); return; }
|
||||
./mach run || errors+=("Failed to run the project.")
|
||||
}
|
||||
|
||||
# Function to print usage instructions
|
||||
|
@ -181,4 +184,12 @@ else
|
|||
print_help
|
||||
fi
|
||||
|
||||
# Print all collected errors at the end
|
||||
if [ ${#errors[@]} -ne 0 ]; then
|
||||
echo "The following errors occurred during execution:"
|
||||
for error in "${errors[@]}"; do
|
||||
echo "- $error"
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
100
package.sh
Executable file
100
package.sh
Executable file
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Output APKINDEX file
|
||||
OUTPUT_FILE="./APKINDEX"
|
||||
|
||||
# Function to calculate a mock checksum
|
||||
calc_checksum() {
|
||||
echo -n "$1" | sha1sum | awk '{ print $1 }'
|
||||
}
|
||||
|
||||
# Parse command-line arguments
|
||||
while getopts "P:V:A:S:I:T:U:L:o:m:D:" opt; do
|
||||
case ${opt} in
|
||||
P) name="$OPTARG" ;;
|
||||
V) version="$OPTARG" ;;
|
||||
A) arch="$OPTARG" ;;
|
||||
S) size="$OPTARG" ;;
|
||||
I) installed_size="$OPTARG" ;;
|
||||
T) description="$OPTARG" ;;
|
||||
U) url="$OPTARG" ;;
|
||||
L) license="$OPTARG" ;;
|
||||
o) origin="$OPTARG" ;;
|
||||
m) maintainer="$OPTARG" ;;
|
||||
D) dependencies="$OPTARG" ;;
|
||||
\?) echo "Invalid option: $OPTARG" 1>&2; exit 1 ;;
|
||||
:) echo "Invalid option: $OPTARG requires an argument" 1>&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If no parameters are provided, prompt for input
|
||||
if [ -z "$name" ]; then
|
||||
read -p "Enter package name: " name
|
||||
fi
|
||||
if [ -z "$version" ]; then
|
||||
read -p "Enter package version: " version
|
||||
fi
|
||||
if [ -z "$arch" ]; then
|
||||
arch="x86_64"
|
||||
fi
|
||||
if [ -z "$size" ]; then
|
||||
read -p "Enter package size: " size
|
||||
fi
|
||||
if [ -z "$installed_size" ]; then
|
||||
read -p "Enter installed size: " installed_size
|
||||
fi
|
||||
if [ -z "$description" ]; then
|
||||
read -p "Enter package description: " description
|
||||
fi
|
||||
if [ -z "$url" ]; then
|
||||
read -p "Enter package URL: " url
|
||||
fi
|
||||
if [ -z "$license" ]; then
|
||||
read -p "Enter license: " license
|
||||
fi
|
||||
if [ -z "$origin" ]; then
|
||||
read -p "Enter origin: " origin
|
||||
fi
|
||||
if [ -z "$maintainer" ]; then
|
||||
read -p "Enter maintainer: " maintainer
|
||||
fi
|
||||
if [ -z "$dependencies" ]; then
|
||||
read -p "Enter dependencies: " dependencies
|
||||
fi
|
||||
|
||||
# Mock package file name
|
||||
pkg_file="$name-$version.apk"
|
||||
|
||||
# Calculate checksums based on package details
|
||||
checksum=$(calc_checksum "$pkg_file")
|
||||
content_checksum=$(calc_checksum "$pkg_file")
|
||||
|
||||
timestamp=$(date +%s)
|
||||
|
||||
# Remove existing entry if present
|
||||
sed -i "/^P:$name$/,/^$/d" "$OUTPUT_FILE" # Ensures the removal from 'P:$name' to the first empty line.
|
||||
sed -i "/^C:$checksum/d" "$OUTPUT_FILE" # Additionally, ensures all occurrences of 'C:$checksum' are removed.
|
||||
|
||||
# Append new entry
|
||||
cat >> "$OUTPUT_FILE" << EOF
|
||||
C:$checksum
|
||||
P:$name
|
||||
V:$version
|
||||
A:$arch
|
||||
S:$size
|
||||
I:$installed_size
|
||||
T:$description
|
||||
U:$url
|
||||
L:$license
|
||||
o:$origin
|
||||
m:$maintainer
|
||||
t:$timestamp
|
||||
c:$content_checksum
|
||||
D:$dependencies
|
||||
p:$pkg_file
|
||||
q:
|
||||
Z:$checksum
|
||||
|
||||
EOF
|
||||
|
||||
echo "APKINDEX has been created/updated successfully."
|
27
upload.sh
27
upload.sh
|
@ -68,12 +68,22 @@ fi
|
|||
# Split the target into its components
|
||||
IFS='-' read -r COMPONENT ARCH RELEASE PLATFORM <<< "$TARGET"
|
||||
|
||||
# Download the existing packages.json
|
||||
echo "Downloading existing packages.json from SourceForge..."
|
||||
scp -i "$SF_KEY_PATH" "$SF_USER@$SF_HOST:/home/frs/project/$SF_PROJECT/packages.json" packages.json 2>/dev/null || { echo "Failed to download packages.json. Creating a new one."; echo "{}" > packages.json; }
|
||||
|
||||
# Check if packages.json is a valid JSON object
|
||||
if ! jq empty packages.json >/dev/null 2>&1; then
|
||||
echo "Invalid packages.json format. Resetting to an empty JSON object."
|
||||
echo "{}" > packages.json
|
||||
fi
|
||||
|
||||
# Handle versioning
|
||||
if [ -z "$VERSION" ]; then
|
||||
if [[ "$RELEASE" == "nightly" ]]; then
|
||||
VERSION=$(date +"%Y-%m-%d")
|
||||
elif [[ "$RELEASE" == "stable" ]]; then
|
||||
CURRENT_VERSION=$(grep -oP '(?<="'"$COMPONENT"'": ")([^"]*)' packages.json)
|
||||
CURRENT_VERSION=$(jq -r --arg comp "$COMPONENT" --arg arch "$ARCH" --arg rel "$RELEASE" --arg plat "$PLATFORM" '.[$comp][$arch][$rel][$plat] | keys | map(select(test("^[0-9]+\\.[0-9]+$"))) | max' packages.json)
|
||||
if [ -n "$CURRENT_VERSION" ]; then
|
||||
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f1)
|
||||
MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f2)
|
||||
|
@ -85,13 +95,6 @@ if [ -z "$VERSION" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Update packages.json
|
||||
if [ ! -f packages.json ]; then
|
||||
echo "{}" > packages.json
|
||||
fi
|
||||
|
||||
jq --arg comp "$COMPONENT" --arg ver "$VERSION" '.[$comp] = $ver' packages.json > packages_temp.json && mv packages_temp.json packages.json
|
||||
|
||||
# Determine the upload directory based on the target and version
|
||||
if [[ "$RELEASE" == "nightly" ]]; then
|
||||
if [[ "$VERSION" == $(date +"%Y-%m-%d") ]]; then
|
||||
|
@ -140,6 +143,14 @@ if [ $UPLOAD_STATUS -ne 0 ]; then
|
|||
scp -i "$SF_KEY_PATH" "$BUILD_PATH" "$SF_USER@$SF_HOST:$REMOTE_DIR/" || { echo "Failed to upload files after creating directory structure. Exiting."; exit 1; }
|
||||
fi
|
||||
|
||||
# Update packages.json with the new information
|
||||
jq --arg comp "$COMPONENT" --arg arch "$ARCH" --arg rel "$RELEASE" --arg plat "$PLATFORM" --arg ver "$VERSION" \
|
||||
'if .[$comp] == null then .[$comp] = {} else .[$comp] end |
|
||||
if .[$comp][$arch] == null then .[$comp][$arch] = {} else .[$comp][$arch] end |
|
||||
if .[$comp][$arch][$rel] == null then .[$comp][$arch][$rel] = {} else .[$comp][$arch][$rel] end |
|
||||
if .[$comp][$arch][$rel][$plat] == null then .[$comp][$arch][$rel][$plat] = {} else .[$comp][$arch][$rel][$plat] end |
|
||||
.[$comp][$arch][$rel][$plat][$ver] = $ver' packages.json > packages_temp.json && mv packages_temp.json packages.json
|
||||
|
||||
# Upload the updated packages.json to the root directory
|
||||
echo "Uploading packages.json to the root directory on SourceForge..."
|
||||
scp -i "$SF_KEY_PATH" packages.json "$SF_USER@$SF_HOST:/home/frs/project/$SF_PROJECT/" || { echo "Failed to upload packages.json. Exiting."; exit 1; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue