mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-17 09:34:16 -05:00
rename dev_scripts to dev-scripts, move homebrew template into its own folder
This commit is contained in:
parent
708453b648
commit
27f3a80741
10 changed files with 37 additions and 40 deletions
10
dev-scripts/brew_dependencies_install.sh
Executable file
10
dev-scripts/brew_dependencies_install.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
brew update
|
||||
|
||||
# See action.yml
|
||||
brew install cmake boost openssl zmq libpgm miniupnpc expat libunwind-headers git
|
||||
|
||||
# We need to build from source to be able to statically link the dependencies
|
||||
brew reinstall --build-from-source unbound expat
|
||||
|
||||
# We need an older version of protobuf to be able to statically link it
|
||||
brew install protobuf@21
|
||||
26
dev-scripts/bump-version.sh
Executable file
26
dev-scripts/bump-version.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION=$1
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
echo "Bumping version to $VERSION"
|
||||
|
||||
# Using sed and assuming GNU sed syntax as this is for the github workflow.
|
||||
|
||||
# Update version in tauri.conf.json
|
||||
sed -i 's/"version": "[^"]*"/"version": "'"$VERSION"'"/' src-tauri/tauri.conf.json
|
||||
|
||||
# Update version in Cargo.toml files
|
||||
sed -i -E 's/^version = "[0-9]+\.[0-9]+\.[0-9]+"/version = "'"$VERSION"'"/' swap/Cargo.toml src-tauri/Cargo.toml
|
||||
|
||||
# Update changelog
|
||||
sed -i "s/^## \\[Unreleased\\]/## [$VERSION] - $TODAY/" CHANGELOG.md
|
||||
# Add a new [Unreleased] section at the top
|
||||
sed -i '3i## [Unreleased]\n' CHANGELOG.md
|
||||
|
||||
echo "Updated all files to version $VERSION."
|
||||
4
dev-scripts/code2prompt_as_file_mac_os.sh
Executable file
4
dev-scripts/code2prompt_as_file_mac_os.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
# Install using:
|
||||
# 1. cargo install code2prompt
|
||||
# 2. brew install code2prompt
|
||||
code2prompt . --exclude "*.lock" --exclude ".sqlx/*" --exclude "target" --output-file "$TMPDIR/code.txt" && osascript -e 'set the clipboard to POSIX file "'"$TMPDIR"'/code.txt"'
|
||||
4
dev-scripts/code2prompt_to_clipboard.sh
Executable file
4
dev-scripts/code2prompt_to_clipboard.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
# Install using:
|
||||
# 1. cargo install code2prompt
|
||||
# 2. brew install code2prompt
|
||||
code2prompt . --exclude "*.lock" --exclude ".sqlx/*" --exclude "target"
|
||||
26
dev-scripts/homebrew/eigenwallet.rb.template
Normal file
26
dev-scripts/homebrew/eigenwallet.rb.template
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
cask "eigenwallet" do
|
||||
version "VERSION_PLACEHOLDER"
|
||||
|
||||
on_arm do
|
||||
sha256 "AARCH64_SHA256_PLACEHOLDER"
|
||||
url "https://github.com/eigenwallet/core/releases/download/#{version}/eigenwallet_#{version}_aarch64.dmg"
|
||||
end
|
||||
|
||||
on_intel do
|
||||
sha256 "X64_SHA256_PLACEHOLDER"
|
||||
url "https://github.com/eigenwallet/core/releases/download/#{version}/eigenwallet_#{version}_x64.dmg"
|
||||
end
|
||||
|
||||
name "Eigenwallet"
|
||||
desc "GUI for XMR<>BTC Atomic Swaps"
|
||||
homepage "https://github.com/eigenwallet/core"
|
||||
|
||||
livecheck do
|
||||
url :url
|
||||
strategy :github_latest
|
||||
end
|
||||
|
||||
auto_updates true
|
||||
|
||||
app "eigenwallet.app"
|
||||
end
|
||||
449
dev-scripts/publish_flatpak.sh
Executable file
449
dev-scripts/publish_flatpak.sh
Executable file
|
|
@ -0,0 +1,449 @@
|
|||
#!/bin/bash
|
||||
|
||||
# eigenwallet Flatpak Build and Deploy Script
|
||||
# Usage: ./flatpak-build.sh [--push] [--branch BRANCH] [--no-gpg]
|
||||
# Example: ./flatpak-build.sh --push --branch gh-pages
|
||||
|
||||
set -e
|
||||
|
||||
PUSH_FLAG=""
|
||||
BRANCH="gh-pages"
|
||||
GPG_SIGN=""
|
||||
NO_GPG_FLAG=""
|
||||
REPO_DIR="flatpak-repo"
|
||||
TEMP_DIR="$(mktemp -d)"
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--push)
|
||||
PUSH_FLAG="--push"
|
||||
shift
|
||||
;;
|
||||
--branch)
|
||||
BRANCH="$2"
|
||||
shift 2
|
||||
;;
|
||||
--no-gpg)
|
||||
NO_GPG_FLAG="--no-gpg"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--push] [--branch BRANCH] [--no-gpg]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Function to list available GPG keys
|
||||
list_gpg_keys() {
|
||||
echo "📋 Available GPG keys:"
|
||||
gpg --list-secret-keys --keyid-format=long 2>/dev/null | grep -E "^(sec|uid)" | while IFS= read -r line; do
|
||||
if [[ $line =~ ^sec ]]; then
|
||||
key_info=$(echo "$line" | awk '{print $2}')
|
||||
echo " 🔑 Key: $key_info"
|
||||
elif [[ $line =~ ^uid ]]; then
|
||||
uid=$(echo "$line" | sed 's/uid[[:space:]]*\[[^]]*\][[:space:]]*//')
|
||||
echo " 👤 $uid"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to get GPG key selection
|
||||
select_gpg_key() {
|
||||
if ! command -v gpg &> /dev/null; then
|
||||
echo "❌ GPG is not installed. Install with: sudo apt install gnupg"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local keys=($(gpg --list-secret-keys --keyid-format=long 2>/dev/null | grep "^sec" | awk '{print $2}' | cut -d'/' -f2))
|
||||
|
||||
if [ ${#keys[@]} -eq 0 ]; then
|
||||
echo "🔑 No GPG keys found."
|
||||
echo ""
|
||||
read -p "Would you like to import a GPG key? [y/N]: " import_key
|
||||
|
||||
if [[ $import_key =~ ^[Yy]$ ]]; then
|
||||
import_gpg_key
|
||||
select_gpg_key
|
||||
else
|
||||
echo "⚠️ Proceeding without GPG signing (not recommended for production)"
|
||||
GPG_SIGN=""
|
||||
return
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
list_gpg_keys
|
||||
|
||||
echo "Please select a GPG key for signing:"
|
||||
for i in "${!keys[@]}"; do
|
||||
local key_id="${keys[i]}"
|
||||
local user_info=$(gpg --list-secret-keys --keyid-format=long "$key_id" 2>/dev/null | grep "^uid" | head -1 | sed 's/uid[[:space:]]*\[[^]]*\][[:space:]]*//')
|
||||
echo " $((i+1))) ${key_id} - ${user_info}"
|
||||
done
|
||||
echo " $((${#keys[@]}+1))) Skip GPG signing"
|
||||
echo " $((${#keys[@]}+2))) Import a new key"
|
||||
echo ""
|
||||
|
||||
while true; do
|
||||
read -p "Enter your choice [1-$((${#keys[@]}+2))]: " choice
|
||||
|
||||
if [[ $choice =~ ^[0-9]+$ ]] && [ $choice -ge 1 ] && [ $choice -le $((${#keys[@]}+2)) ]; then
|
||||
if [ $choice -eq $((${#keys[@]}+1)) ]; then
|
||||
echo "⚠️ Proceeding without GPG signing"
|
||||
GPG_SIGN=""
|
||||
break
|
||||
elif [ $choice -eq $((${#keys[@]}+2)) ]; then
|
||||
import_gpg_key
|
||||
select_gpg_key
|
||||
break
|
||||
else
|
||||
GPG_SIGN="${keys[$((choice-1))]}"
|
||||
local selected_user=$(gpg --list-secret-keys --keyid-format=long "$GPG_SIGN" 2>/dev/null | grep "^uid" | head -1 | sed 's/uid[[:space:]]*\[[^]]*\][[:space:]]*//')
|
||||
echo "✅ Selected key: $GPG_SIGN - $selected_user"
|
||||
break
|
||||
fi
|
||||
else
|
||||
echo "❌ Invalid choice. Please enter a number between 1 and $((${#keys[@]}+2))"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to import GPG key
|
||||
import_gpg_key() {
|
||||
echo ""
|
||||
echo "🔑 GPG Key Import"
|
||||
echo "=================="
|
||||
echo "📝 Please paste your GPG private key below."
|
||||
echo " (Start with -----BEGIN PGP PRIVATE KEY BLOCK----- and end with -----END PGP PRIVATE KEY BLOCK-----)"
|
||||
echo " Press Ctrl+D when finished:"
|
||||
echo ""
|
||||
|
||||
local temp_key_file=$(mktemp)
|
||||
cat > "$temp_key_file"
|
||||
|
||||
echo ""
|
||||
echo "🔄 Importing key..."
|
||||
|
||||
if gpg --import "$temp_key_file" 2>/dev/null; then
|
||||
echo "✅ GPG key imported successfully!"
|
||||
else
|
||||
echo "❌ Failed to import GPG key. Please check the format and try again."
|
||||
rm -f "$temp_key_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f "$temp_key_file"
|
||||
}
|
||||
|
||||
# Check requirements
|
||||
if ! command -v flatpak-builder &> /dev/null; then
|
||||
echo "❌ flatpak-builder is required but not installed"
|
||||
echo "Install with: sudo apt install flatpak-builder (Ubuntu/Debian)"
|
||||
echo " sudo dnf install flatpak-builder (Fedora)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v git &> /dev/null; then
|
||||
echo "❌ git is required but not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "❌ jq is required but not installed"
|
||||
echo "Install with: sudo apt install jq (Ubuntu/Debian)"
|
||||
echo " sudo dnf install jq (Fedora)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get repository info
|
||||
REPO_URL=$(git remote get-url origin 2>/dev/null || echo "")
|
||||
if [[ $REPO_URL =~ github\.com[:/]([^/]+)/([^/.]+) ]]; then
|
||||
GITHUB_USER="${BASH_REMATCH[1]}"
|
||||
REPO_NAME="${BASH_REMATCH[2]}"
|
||||
else
|
||||
echo "❌ Could not determine GitHub repository info"
|
||||
echo "Make sure you're in a Git repository with a GitHub origin"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PAGES_URL="https://${GITHUB_USER}.github.io/${REPO_NAME}"
|
||||
|
||||
echo "🏗️ Building Flatpak for eigenwallet..."
|
||||
echo "📁 Repository: ${GITHUB_USER}/${REPO_NAME}"
|
||||
echo "🌐 Pages URL: ${PAGES_URL}"
|
||||
echo ""
|
||||
|
||||
# Handle GPG key selection
|
||||
if [ "$NO_GPG_FLAG" != "--no-gpg" ]; then
|
||||
echo "🔐 GPG Signing Setup"
|
||||
echo "==================="
|
||||
echo "For security, it's highly recommended to sign your Flatpak repository with GPG."
|
||||
echo "This ensures users can verify the authenticity of your packages."
|
||||
echo ""
|
||||
|
||||
read -p "Do you want to use GPG signing? [Y/n]: " use_gpg
|
||||
|
||||
if [[ $use_gpg =~ ^[Nn]$ ]]; then
|
||||
echo "⚠️ Proceeding without GPG signing"
|
||||
GPG_SIGN=""
|
||||
else
|
||||
select_gpg_key
|
||||
fi
|
||||
else
|
||||
echo "⚠️ GPG signing disabled by --no-gpg flag"
|
||||
GPG_SIGN=""
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Always use local .deb file - build if needed
|
||||
echo "🔍 Ensuring local .deb file exists..."
|
||||
MANIFEST_FILE="flatpak/org.eigenwallet.app.json"
|
||||
TEMP_MANIFEST=""
|
||||
|
||||
# Look for the .deb file in the expected location
|
||||
DEB_FILE=$(find ./target/release/bundle/deb/ -name "*.deb" -not -name "*.deb.sig" 2>/dev/null | head -1)
|
||||
|
||||
if [ -n "$DEB_FILE" ] && [ -f "$DEB_FILE" ]; then
|
||||
echo "✅ Found local .deb file: $DEB_FILE"
|
||||
else
|
||||
echo "🏗️ No local .deb file found, building locally..."
|
||||
|
||||
if [ ! -f "./release-build.sh" ]; then
|
||||
echo "❌ release-build.sh not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract version from Cargo.toml
|
||||
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*= "//' | sed 's/".*//')
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "❌ Could not determine version from Cargo.toml"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Building version $VERSION..."
|
||||
./release-build.sh "$VERSION"
|
||||
|
||||
# Look for the .deb file again
|
||||
DEB_FILE=$(find ./target/release/bundle/deb/ -name "*.deb" -not -name "*.deb.sig" 2>/dev/null | head -1)
|
||||
if [ -z "$DEB_FILE" ] || [ ! -f "$DEB_FILE" ]; then
|
||||
echo "❌ Failed to build .deb file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Local build completed: $DEB_FILE"
|
||||
fi
|
||||
|
||||
# Get the absolute path
|
||||
DEB_ABSOLUTE_PATH=$(realpath "$DEB_FILE")
|
||||
|
||||
# Calculate SHA256 hash of the .deb file
|
||||
echo "🔢 Calculating SHA256 hash..."
|
||||
DEB_SHA256=$(sha256sum "$DEB_ABSOLUTE_PATH" | cut -d' ' -f1)
|
||||
echo " Hash: $DEB_SHA256"
|
||||
|
||||
# Create a temporary manifest with the local file
|
||||
TEMP_MANIFEST=$(mktemp --suffix=.json)
|
||||
|
||||
echo "📝 Creating manifest with local .deb..."
|
||||
|
||||
# Modify the manifest to use the local file
|
||||
jq --arg deb_path "file://$DEB_ABSOLUTE_PATH" --arg deb_hash "$DEB_SHA256" '
|
||||
.modules[0].sources = [
|
||||
{
|
||||
"type": "file",
|
||||
"url": $deb_path,
|
||||
"sha256": $deb_hash,
|
||||
"dest": ".",
|
||||
"dest-filename": "eigenwallet.deb"
|
||||
}
|
||||
] |
|
||||
.modules[0]."build-commands" = [
|
||||
"ar -x eigenwallet.deb",
|
||||
"tar -xf data.tar.gz",
|
||||
"install -Dm755 usr/bin/unstoppableswap-gui-rs /app/bin/unstoppableswap-gui-rs"
|
||||
]
|
||||
' "$MANIFEST_FILE" > "$TEMP_MANIFEST"
|
||||
|
||||
MANIFEST_FILE="$TEMP_MANIFEST"
|
||||
echo "📦 Using local build: $(basename "$DEB_FILE")"
|
||||
|
||||
echo ""
|
||||
|
||||
# Create build directory
|
||||
rm -rf "$REPO_DIR"
|
||||
mkdir -p "$REPO_DIR"
|
||||
|
||||
# Build arguments
|
||||
BUILD_ARGS=(
|
||||
"build-dir"
|
||||
"--user"
|
||||
"--install-deps-from=flathub"
|
||||
"--disable-rofiles-fuse"
|
||||
"--disable-updates"
|
||||
"--force-clean"
|
||||
"--repo=$REPO_DIR"
|
||||
)
|
||||
|
||||
if [ -n "$GPG_SIGN" ]; then
|
||||
BUILD_ARGS+=("--gpg-sign=$GPG_SIGN")
|
||||
echo "🔐 GPG signing enabled with key: $GPG_SIGN"
|
||||
fi
|
||||
|
||||
# Add Flathub repository for dependencies
|
||||
echo "📦 Setting up Flathub repository..."
|
||||
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
# Build the Flatpak
|
||||
echo "🔨 Building Flatpak..."
|
||||
flatpak-builder "${BUILD_ARGS[@]}" "$MANIFEST_FILE"
|
||||
|
||||
# Generate static deltas for faster downloads
|
||||
echo "⚡ Generating static deltas..."
|
||||
DELTA_ARGS=("--generate-static-deltas" "--prune")
|
||||
if [ -n "$GPG_SIGN" ]; then
|
||||
DELTA_ARGS+=("--gpg-sign=$GPG_SIGN")
|
||||
fi
|
||||
flatpak build-update-repo "${DELTA_ARGS[@]}" "$REPO_DIR"
|
||||
|
||||
# Create bundle for direct download
|
||||
echo "📦 Creating Flatpak bundle..."
|
||||
BUNDLE_ARGS=("$REPO_DIR" "org.eigenwallet.app.flatpak")
|
||||
if [ -n "$GPG_SIGN" ]; then
|
||||
BUNDLE_ARGS+=("--gpg-sign=$GPG_SIGN")
|
||||
fi
|
||||
flatpak build-bundle "${BUNDLE_ARGS[@]}" org.eigenwallet.app
|
||||
|
||||
# Generate .flatpakrepo file
|
||||
echo "📝 Generating .flatpakrepo file..."
|
||||
cat > "$REPO_DIR/eigenwallet.flatpakrepo" << EOF
|
||||
[Flatpak Repo]
|
||||
Title=eigenwallet
|
||||
Name=eigenwallet
|
||||
Url=${PAGES_URL}/
|
||||
Homepage=https://github.com/${GITHUB_USER}/${REPO_NAME}
|
||||
Comment=Unstoppable cross-chain atomic swaps
|
||||
Description=Repository for eigenwallet applications - providing secure and decentralized XMR-BTC atomic swaps
|
||||
Icon=${PAGES_URL}/icon.png
|
||||
SuggestRemoteName=eigenwallet
|
||||
EOF
|
||||
|
||||
# Add GPG key if signing
|
||||
if [ -n "$GPG_SIGN" ]; then
|
||||
echo "🔑 Adding GPG key to .flatpakrepo..."
|
||||
GPG_KEY_B64=$(gpg --export "$GPG_SIGN" | base64 -w 0)
|
||||
echo "GPGKey=$GPG_KEY_B64" >> "$REPO_DIR/eigenwallet.flatpakrepo"
|
||||
fi
|
||||
|
||||
# Generate .flatpakref file
|
||||
echo "📝 Generating .flatpakref file..."
|
||||
cat > "$REPO_DIR/org.eigenwallet.app.flatpakref" << EOF
|
||||
[Flatpak Ref]
|
||||
Title=eigenwallet GUI
|
||||
Name=org.eigenwallet.app
|
||||
Branch=stable
|
||||
Url=${PAGES_URL}/
|
||||
SuggestRemoteName=eigenwallet
|
||||
Homepage=https://github.com/${GITHUB_USER}/${REPO_NAME}
|
||||
Icon=${PAGES_URL}/icon.png
|
||||
RuntimeRepo=https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
IsRuntime=false
|
||||
EOF
|
||||
|
||||
# Add GPG key if signing
|
||||
if [ -n "$GPG_SIGN" ]; then
|
||||
GPG_KEY_B64=$(gpg --export "$GPG_SIGN" | base64 -w 0)
|
||||
echo "GPGKey=$GPG_KEY_B64" >> "$REPO_DIR/org.eigenwallet.app.flatpakref"
|
||||
fi
|
||||
|
||||
# Copy bundle to repo directory
|
||||
cp org.eigenwallet.app.flatpak "$REPO_DIR/"
|
||||
|
||||
# Use index.html from flatpak directory
|
||||
if [ -f "flatpak/index.html" ]; then
|
||||
echo "Copying index.html from flatpak directory..."
|
||||
cp flatpak/index.html "$REPO_DIR/index.html"
|
||||
else
|
||||
echo "Error: flatpak/index.html not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy any additional files
|
||||
if [ -f "icon.png" ]; then
|
||||
cp icon.png "$REPO_DIR/"
|
||||
fi
|
||||
|
||||
if [ -f "README.md" ]; then
|
||||
cp README.md "$REPO_DIR/"
|
||||
fi
|
||||
|
||||
# Add .nojekyll file to skip Jekyll processing
|
||||
touch "$REPO_DIR/.nojekyll"
|
||||
|
||||
echo "✅ Flatpak repository built successfully!"
|
||||
echo "📊 Repository size: $(du -sh $REPO_DIR | cut -f1)"
|
||||
echo "📁 Repository files are in: $REPO_DIR/"
|
||||
|
||||
if [ "$PUSH_FLAG" = "--push" ]; then
|
||||
echo ""
|
||||
echo "🚀 Deploying to GitHub Pages..."
|
||||
|
||||
# Store current branch
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
|
||||
# Create a temporary directory for deployment
|
||||
DEPLOY_DIR=$(mktemp -d)
|
||||
|
||||
# Copy flatpak repo to deploy directory (including hidden files)
|
||||
echo "📁 Preparing deployment files..."
|
||||
cp -r "$REPO_DIR"/. "$DEPLOY_DIR/"
|
||||
|
||||
# Initialize fresh git repo in deploy directory
|
||||
cd "$DEPLOY_DIR"
|
||||
git init
|
||||
git add .
|
||||
git commit -m "Update Flatpak repository $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
|
||||
|
||||
# Go back to original directory
|
||||
cd - > /dev/null
|
||||
|
||||
# Push to GitHub Pages branch
|
||||
echo "🚀 Force pushing to $BRANCH..."
|
||||
cd "$DEPLOY_DIR"
|
||||
git remote add origin "$(cd - > /dev/null && git remote get-url origin)"
|
||||
git push --force origin HEAD:"$BRANCH"
|
||||
|
||||
# Return to original directory and clean up
|
||||
cd - > /dev/null
|
||||
rm -rf "$DEPLOY_DIR"
|
||||
|
||||
echo "🎉 Deployed successfully!"
|
||||
echo "🌐 Your Flatpak repository is available at: $PAGES_URL"
|
||||
echo ""
|
||||
echo "📋 Users can install with:"
|
||||
echo " flatpak remote-add --user eigenwallet $PAGES_URL/eigenwallet.flatpakrepo"
|
||||
echo " flatpak install eigenwallet org.eigenwallet.app"
|
||||
echo ""
|
||||
if [ -n "$GPG_SIGN" ]; then
|
||||
echo "🔐 Repository is signed with GPG key: $GPG_SIGN"
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
echo "📋 To deploy to GitHub Pages, run:"
|
||||
echo " $0 --push"
|
||||
echo ""
|
||||
echo "📋 Or manually copy the contents of $REPO_DIR/ to your gh-pages branch"
|
||||
fi
|
||||
|
||||
# Cleanup temporary manifest if created
|
||||
if [ -n "$TEMP_MANIFEST" ] && [ -f "$TEMP_MANIFEST" ]; then
|
||||
rm -f "$TEMP_MANIFEST"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
rm -rf "$TEMP_DIR"
|
||||
echo "🧹 Cleanup completed"
|
||||
420
dev-scripts/ubuntu_build_x86_86-w64-mingw32-gcc.sh
Executable file
420
dev-scripts/ubuntu_build_x86_86-w64-mingw32-gcc.sh
Executable file
|
|
@ -0,0 +1,420 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script to build gcc cross compiler for windows from source on ubuntu.
|
||||
# Installed into ~/opt/gcc-mingw-14.3
|
||||
|
||||
|
||||
# Versions
|
||||
BINUTILS_VER=2.42
|
||||
MINGW_VER=v12.0.0
|
||||
GCC_VER=14.3.0
|
||||
|
||||
# Some flags for running only certain parts of the script.
|
||||
# Set these to 1 before running the script to make use of them.
|
||||
ONLY_WINPTHREADS="${ONLY_WINPTHREADS:-}"
|
||||
ONLY_COPY_DLLS="${ONLY_COPY_DLLS:-}"
|
||||
ONLY_VERIFY="${ONLY_VERIFY:-}"
|
||||
|
||||
# OS Detection and validation
|
||||
detected=$(uname -s)-$(uname -m)
|
||||
case "$detected" in
|
||||
Linux-x86_64)
|
||||
# Check if it's Ubuntu
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
if [ "$ID" != "ubuntu" ]; then
|
||||
echo "This script is designed for ubuntu (x86-64) and doesn't support: ${detected} (${PRETTY_NAME})"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "This script is designed for ubuntu (x86-64) and doesn't support: ${detected}"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "This script is designed for ubuntu (x86-64) and doesn't support: ${detected}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Get the current project root (this file is in <root>/dev-scripts/ and gets called via just (just file is at <root>/justfile))
|
||||
SRC_TAURI_DIR="$(pwd)/../src-tauri"
|
||||
|
||||
# Check if src-tauri directory exists
|
||||
if [ ! -d "$SRC_TAURI_DIR" ]; then
|
||||
echo "Error: must be called from project root -> src-tauri must be subdir"
|
||||
echo "Current directory: $(pwd)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_deps() {
|
||||
# Package installation (idempotent)
|
||||
echo "Ensuring required packages are installed"
|
||||
to_install=()
|
||||
for pkg in gpg build-essential wget flex bison texinfo libgmp-dev libmpfr-dev libmpc-dev libisl-dev zlib1g-dev libbz2-dev libffi-dev python3 gnupg dirmngr ca-certificates jq; do
|
||||
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
|
||||
echo "missing package: $pkg"
|
||||
to_install+=("$pkg")
|
||||
fi
|
||||
done
|
||||
if [ ${#to_install[@]} -gt 0 ]; then
|
||||
sudo apt update
|
||||
sudo apt install -y "${to_install[@]}"
|
||||
else
|
||||
echo "All required packages already installed"
|
||||
fi
|
||||
}
|
||||
|
||||
export PREFIX=~/opt/gcc-mingw-14.3
|
||||
export BUILD=$HOME/mingw-build
|
||||
export SRC=$BUILD/src
|
||||
mkdir -p $SRC \
|
||||
$BUILD/build-binutils \
|
||||
$BUILD/build-headers \
|
||||
$BUILD/build-gcc \
|
||||
$BUILD/build-crt \
|
||||
$BUILD/build-winpthreads \
|
||||
$PREFIX
|
||||
|
||||
cd $SRC
|
||||
|
||||
download_if_missing() {
|
||||
local url="$1"
|
||||
local out="${2:-}"
|
||||
local dest
|
||||
if [ -n "$out" ]; then
|
||||
dest="$out"
|
||||
else
|
||||
dest="$(basename "$url")"
|
||||
fi
|
||||
if [ -f "$dest" ]; then
|
||||
echo "Already present: $dest"
|
||||
else
|
||||
echo "Downloading: $url"
|
||||
wget -q "$url" -O "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_gpg_key() {
|
||||
# Usage: fetch_gpg_key <keyid_or_fingerprint>
|
||||
local key="$1"
|
||||
|
||||
# Try multiple hkps keyservers first
|
||||
for ks in hkps://keyserver.ubuntu.com hkps://keys.openpgp.org hkps://pgp.mit.edu; do
|
||||
if gpg --keyserver "$ks" --keyserver-options timeout=10 --recv-keys "$key"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# HTTP fallback: Ubuntu keyserver
|
||||
if ! gpg --list-keys "$key" >/dev/null 2>&1; then
|
||||
if curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x${key}" | gpg --import; then
|
||||
if gpg --list-keys "$key" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# HTTP fallback: keys.openpgp.org by fingerprint (no 0x)
|
||||
if ! gpg --list-keys "$key" >/dev/null 2>&1; then
|
||||
local fpr_no0x
|
||||
fpr_no0x=$(echo "$key" | sed 's/^0x//')
|
||||
curl -fsSL "https://keys.openpgp.org/vks/v1/by-fingerprint/${fpr_no0x}" | gpg --import || true
|
||||
if gpg --list-keys "$key" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_key_and_verify() {
|
||||
# Usage: ensure_key_and_verify <artifact> <signature>
|
||||
local artifact="$1"
|
||||
local sig="$2"
|
||||
|
||||
echo "Verifying signature: $sig for $artifact"
|
||||
|
||||
# First attempt: verify with whatever keys are available
|
||||
if gpg --batch --status-fd 1 --verify "$sig" "$artifact" 2>verify.stderr | tee verify.status | grep -q "\[GNUPG:\] VALIDSIG"; then
|
||||
echo "GPG verification OK for $artifact"
|
||||
rm -f verify.status verify.stderr
|
||||
return 0
|
||||
fi
|
||||
|
||||
# If missing key, try to fetch by fingerprint or keyid
|
||||
local missing_key
|
||||
missing_key=$(grep "\[GNUPG:\] NO_PUBKEY" verify.status | awk '{print $3}' || true)
|
||||
if [ -z "$missing_key" ]; then
|
||||
# Try to extract key id from stderr (older gpg formats)
|
||||
missing_key=$(grep -Eo 'key [0-9A-Fa-f]+' verify.stderr | awk '{print $2}' | tail -n1 || true)
|
||||
fi
|
||||
|
||||
if [ -n "$missing_key" ]; then
|
||||
echo "Missing public key: $missing_key. Attempting key fetch."
|
||||
fetch_gpg_key "$missing_key" || true
|
||||
fi
|
||||
|
||||
# Second attempt: verify again
|
||||
if gpg --batch --status-fd 1 --verify "$sig" "$artifact" 2>/dev/null | grep -q "\[GNUPG:\] VALIDSIG"; then
|
||||
echo "GPG verification OK for $artifact"
|
||||
rm -f verify.status verify.stderr
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "ERROR: GPG verification failed for $artifact" >&2
|
||||
echo "GPG status:"
|
||||
cat verify.status || true
|
||||
echo "GPG stderr:"
|
||||
cat verify.stderr || true
|
||||
rm -f verify.status verify.stderr
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
download_sources() {
|
||||
# Binutils
|
||||
download_if_missing "https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.xz"
|
||||
download_if_missing "https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.xz.sig"
|
||||
ensure_key_and_verify "binutils-${BINUTILS_VER}.tar.xz" "binutils-${BINUTILS_VER}.tar.xz.sig"
|
||||
tar xf "binutils-${BINUTILS_VER}.tar.xz"
|
||||
|
||||
# mingw-w64 headers & CRT
|
||||
download_if_missing "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-${MINGW_VER}.tar.bz2"
|
||||
download_if_missing "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-${MINGW_VER}.tar.bz2.sig"
|
||||
ensure_key_and_verify "mingw-w64-${MINGW_VER}.tar.bz2" "mingw-w64-${MINGW_VER}.tar.bz2.sig"
|
||||
tar xf "mingw-w64-${MINGW_VER}.tar.bz2"
|
||||
|
||||
# GCC
|
||||
download_if_missing "https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.xz"
|
||||
download_if_missing "https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.xz.sig"
|
||||
ensure_key_and_verify "gcc-${GCC_VER}.tar.xz" "gcc-${GCC_VER}.tar.xz.sig"
|
||||
tar xf "gcc-${GCC_VER}.tar.xz"
|
||||
}
|
||||
|
||||
|
||||
build_binutils() {
|
||||
echo "Building binutils"
|
||||
|
||||
cd $BUILD/build-binutils
|
||||
$SRC/binutils-${BINUTILS_VER}/configure \
|
||||
--target=x86_64-w64-mingw32 \
|
||||
--prefix=$PREFIX \
|
||||
--with-sysroot=$PREFIX \
|
||||
--disable-multilib
|
||||
make -j$(nproc)
|
||||
make install
|
||||
export PATH="$PREFIX/bin:$PATH"
|
||||
|
||||
echo "Built binutils"
|
||||
}
|
||||
|
||||
build_mingw_headers() {
|
||||
echo "Building mingw-w64 headers"
|
||||
|
||||
cd $BUILD/build-headers
|
||||
$SRC/mingw-w64-${MINGW_VER}/mingw-w64-headers/configure \
|
||||
--host=x86_64-w64-mingw32 \
|
||||
--prefix=$PREFIX/x86_64-w64-mingw32
|
||||
make -j$(nproc)
|
||||
make install
|
||||
|
||||
# fixes a path mismatch issue
|
||||
if [ ! -L "$PREFIX/mingw" ]; then
|
||||
ln -s $PREFIX/x86_64-w64-mingw32 $PREFIX/mingw
|
||||
fi
|
||||
|
||||
echo "Built mingw-w64 headers"
|
||||
}
|
||||
|
||||
prepare_gcc_build() {
|
||||
echo "Building gcc"
|
||||
|
||||
cd $BUILD/build-gcc
|
||||
$SRC/gcc-${GCC_VER}/configure \
|
||||
--target=x86_64-w64-mingw32 \
|
||||
--prefix=$PREFIX \
|
||||
--with-sysroot=$PREFIX \
|
||||
--disable-multilib \
|
||||
--enable-languages=c,c++ \
|
||||
--enable-threads=posix
|
||||
make all-gcc -j$(nproc)
|
||||
make install-gcc
|
||||
|
||||
echo "Built gcc"
|
||||
}
|
||||
|
||||
build_mingw_crt() {
|
||||
echo "Building mingw-w64 CRT"
|
||||
|
||||
cd $BUILD/build-crt
|
||||
$SRC/mingw-w64-${MINGW_VER}/mingw-w64-crt/configure \
|
||||
--host=x86_64-w64-mingw32 \
|
||||
--prefix=$PREFIX/x86_64-w64-mingw32 \
|
||||
--with-sysroot=$PREFIX
|
||||
make -j$(nproc)
|
||||
make install
|
||||
|
||||
echo "Built mingw-w64 CRT"
|
||||
}
|
||||
|
||||
finish_gcc() {
|
||||
echo "Finishing gcc build"
|
||||
|
||||
cd $BUILD/build-gcc
|
||||
make -j$(nproc)
|
||||
make install
|
||||
|
||||
|
||||
echo "Built gcc"
|
||||
}
|
||||
|
||||
build_winpthreads() {
|
||||
echo "Building winpthreads.dll"
|
||||
|
||||
cd $BUILD/build-winpthreads
|
||||
|
||||
# 2. Configure winpthreads (static & shared)
|
||||
$SRC/mingw-w64-${MINGW_VER}/mingw-w64-libraries/winpthreads/configure \
|
||||
--host=x86_64-w64-mingw32 \
|
||||
--prefix=$PREFIX/x86_64-w64-mingw32 \
|
||||
--enable-static --enable-shared \
|
||||
--disable-multilib
|
||||
|
||||
# 3. Build & install
|
||||
make -j$(nproc)
|
||||
make install
|
||||
|
||||
echo "Built winpthreads.dll"
|
||||
}
|
||||
|
||||
copy_dlls() {
|
||||
echo "Copying dll's to src-tauri/"
|
||||
cp -f $PREFIX/x86_64-w64-mingw32/lib/{libstdc++-6,libgcc_s_seh-1}.dll $SRC_TAURI_DIR/
|
||||
cp -f $PREFIX/x86_64-w64-mingw32/bin/libwinpthread-1.dll $SRC_TAURI_DIR/
|
||||
}
|
||||
|
||||
setup_path() {
|
||||
export MINGW_TOOLCHAIN_DIR="$PREFIX/bin"
|
||||
|
||||
# Add to PATH only if not already present
|
||||
if [[ ":$PATH:" != *":$PREFIX/bin:"* ]]; then
|
||||
export PATH="$MINGW_TOOLCHAIN_DIR:$PATH"
|
||||
fi
|
||||
|
||||
# When running in GitHub Actions, export the toolchain dir for later steps
|
||||
if [ -n "${GITHUB_ENV:-}" ]; then
|
||||
echo "MINGW_TOOLCHAIN_DIR=$MINGW_TOOLCHAIN_DIR" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
# Also add to GITHUB_PATH for GitHub Actions
|
||||
if [ -n "${GITHUB_PATH:-}" ]; then
|
||||
echo "$PREFIX/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
|
||||
# Add path to .bashrc
|
||||
if ! grep -q "export PATH=\"$PREFIX/bin:\$PATH\"" ~/.bashrc; then
|
||||
echo "export PATH=\"$PREFIX/bin:\$PATH\"" >> ~/.bashrc
|
||||
fi
|
||||
}
|
||||
|
||||
verify_installation() {
|
||||
# 1. check that ~/opt/gcc-mingw-14.3/ exists
|
||||
# 2. check that `x86_64-w64-mingw32-g++ --version` works and the output contains 14.3
|
||||
# 3. make sure the dll's are in the src-tauri directory
|
||||
|
||||
echo "Verifying cross-compiler installation"
|
||||
|
||||
local has_error=0
|
||||
|
||||
# Ensure PREFIX dir exists
|
||||
if [ ! -d "$PREFIX" ]; then
|
||||
echo "ERROR: Expected install directory not found: $PREFIX"
|
||||
has_error=1
|
||||
else
|
||||
echo "OK: Found install directory $PREFIX"
|
||||
fi
|
||||
|
||||
# Ensure the compiler is on PATH for the check
|
||||
if ! command -v x86_64-w64-mingw32-g++ >/dev/null 2>&1; then
|
||||
export PATH="$PREFIX/bin:$PATH"
|
||||
fi
|
||||
|
||||
# Check compiler exists and version matches expected major.minor (e.g., 14.3)
|
||||
local gcc_out=""
|
||||
local gcc_short_ver
|
||||
gcc_short_ver="${GCC_VER%.*}"
|
||||
if ! gcc_out="$(x86_64-w64-mingw32-g++ --version 2>/dev/null)"; then
|
||||
echo "ERROR: x86_64-w64-mingw32-g++ is not runnable or not found on PATH"
|
||||
has_error=1
|
||||
else
|
||||
if echo "$gcc_out" | grep -q "$gcc_short_ver"; then
|
||||
echo "OK: x86_64-w64-mingw32-g++ version contains $gcc_short_ver"
|
||||
else
|
||||
echo "ERROR: x86_64-w64-mingw32-g++ version does not contain $gcc_short_ver"
|
||||
echo "$gcc_out" | head -n1
|
||||
has_error=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check DLLs in src-tauri directory
|
||||
local missing_dlls=()
|
||||
for dll in libstdc++-6.dll libgcc_s_seh-1.dll libwinpthread-1.dll; do
|
||||
if [ ! -f "$SRC_TAURI_DIR/$dll" ]; then
|
||||
missing_dlls+=("$dll")
|
||||
fi
|
||||
done
|
||||
if [ ${#missing_dlls[@]} -eq 0 ]; then
|
||||
echo "OK: Required DLLs are present in $SRC_TAURI_DIR"
|
||||
else
|
||||
echo "ERROR: Missing DLLs in $SRC_TAURI_DIR: ${missing_dlls[*]}"
|
||||
echo "Hint: run `just prepare-windows-build` to build and copy the required DLLs"
|
||||
has_error=1
|
||||
fi
|
||||
|
||||
if [ "$has_error" -eq 0 ]; then
|
||||
echo "Verification successful"
|
||||
return 0
|
||||
else
|
||||
echo "Verification failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "${ONLY_WINPTHREADS}" ]; then
|
||||
echo "ONLY_WINPTHREADS set; building winpthreads.dll"
|
||||
install_deps
|
||||
download_sources
|
||||
build_winpthreads
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "${ONLY_COPY_DLLS}" ]; then
|
||||
echo "ONLY_COPY_DLLS set; copying dll's to src-tauri/"
|
||||
copy_dlls
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "${ONLY_VERIFY}" ]; then
|
||||
verify_installation
|
||||
exit 0
|
||||
fi
|
||||
|
||||
install_deps
|
||||
download_sources
|
||||
|
||||
build_binutils
|
||||
build_mingw_headers
|
||||
prepare_gcc_build
|
||||
build_mingw_crt
|
||||
build_winpthreads
|
||||
finish_gcc
|
||||
copy_dlls
|
||||
|
||||
setup_path
|
||||
|
||||
verify_installation
|
||||
|
||||
echo "Done"
|
||||
Loading…
Add table
Add a link
Reference in a new issue