mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-12 02:10:54 +00:00
65 lines
2.0 KiB
Bash
65 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# build-@[email protected]
|
|
#
|
|
# Script to build both binary and source RPMs for @PACKAGE_NAME@
|
|
# using the @[email protected] file in the current directory.
|
|
#
|
|
# This version:
|
|
# - Works without rpmdevtools
|
|
#
|
|
# Requirements:
|
|
# - rpmbuild available
|
|
# - gcc and make installed (for building @PACKAGE@)
|
|
#
|
|
# Usage:
|
|
# 1. Place this script and your @[email protected] (and optionally the tarball) in the same directory.
|
|
# 2. Make it executable: chmod +x build-@[email protected]
|
|
# 3. Run it: ./build-@[email protected]
|
|
|
|
set -euo pipefail
|
|
|
|
VERSION=@PACKAGE_VERSION@
|
|
SPEC_FILE="@[email protected]"
|
|
|
|
if [[ ! -f "pkg/$SPEC_FILE" ]]; then
|
|
echo "Error: $SPEC_FILE not found in the current directory."
|
|
echo "Please run this script from the directory containing your $SPEC_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "SnapRAID version: $VERSION"
|
|
|
|
TARBALL="@PACKAGE@-${VERSION}.tar.gz"
|
|
|
|
# Set up rpmbuild tree manually in ~/rpmbuild if it doesn't exist
|
|
RPMBUILD_DIR="$HOME/rpmbuild"
|
|
if [[ ! -d "$RPMBUILD_DIR/SPECS" ]]; then
|
|
echo "Setting up rpmbuild directory structure in $RPMBUILD_DIR..."
|
|
mkdir -p "$RPMBUILD_DIR"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
|
else
|
|
echo "rpmbuild directory structure already exists in $RPMBUILD_DIR"
|
|
fi
|
|
|
|
# Look for the tarball in the current directory
|
|
if [[ -f "./$TARBALL" ]]; then
|
|
echo "Found $TARBALL in the current directory. Copying to ~/rpmbuild/SOURCES..."
|
|
cp "./$TARBALL" "$RPMBUILD_DIR/SOURCES/"
|
|
else
|
|
echo "Error: $TARBALL not found in the current directory."
|
|
exit 1
|
|
fi
|
|
|
|
# Copy spec file to SPECS directory (preserving the original filename)
|
|
cp "pkg/$SPEC_FILE" "$RPMBUILD_DIR/SPECS/"
|
|
|
|
echo "Building RPMs using rpmbuild -ba..."
|
|
rpmbuild -ba --nodeps --nocheck "$RPMBUILD_DIR/SPECS/$SPEC_FILE"
|
|
|
|
cp $RPMBUILD_DIR/RPMS/*/@PACKAGE@-${VERSION}*.rpm .
|
|
|
|
echo "Package created: $RPMBUILD_DIR/RPMS/@PACKAGE@-${VERSION}*.rpm"
|
|
echo ""
|
|
echo "You can install the RPM with:"
|
|
echo " sudo dnf install @PACKAGE@-${VERSION}*.rpm # Fedora"
|
|
echo " sudo rpm -ivh @PACKAGE@-${VERSION}*.rpm # Others"
|