Repository navigation
Expand file tree
/
Copy pathbuild_rpm.sh
More file actions
executable file
·57 lines (45 loc) · 2.38 KB
/
Copy pathbuild_rpm.sh
File metadata and controls
executable file
·57 lines (45 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -euo pipefail
DEV_DIR="/home/tux/development/fedora-update"
if [ ! -d "$DEV_DIR" ]; then
DEV_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
MIRROR_DIR="/home/tux/SSD2/development/fedora-update"
VERSION="0.3.0"
BACKUP_DIR="/home/tux/SSD2/development/backup/fedora/v${VERSION}"
BUILD_ROOT="/tmp/rpmbuild_fedora_update"
# ------------------------------------------------------------------------------
echo "==> Preparing RPM build environment for v${VERSION}..."
rm -rf "${BUILD_ROOT}"
mkdir -p "${BUILD_ROOT}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} "${DEV_DIR}/releases" "${BACKUP_DIR}" "${MIRROR_DIR}"
tar --exclude-vcs --exclude="./rpmbuild" --exclude="./releases" --exclude="./*.rpm" --exclude="./*.tmp" \
--transform "s,^\.,fedora-update-${VERSION}," -czf "${BUILD_ROOT}/SOURCES/fedora-update-${VERSION}.tar.gz" -C "${DEV_DIR}" .
# Gjør om rpkg-makroer til standard rpmbuild-syntaks for det lokale bygget
sed -e "s|{{{ git_dir_pack }}}|fedora-update-${VERSION}.tar.gz|" \
-e "s|{{{ git_dir_setup_macro }}}|%setup -q -n fedora-update-${VERSION}|" \
"${DEV_DIR}/fedora-update.spec" > "${BUILD_ROOT}/SPECS/fedora-update.spec"
# ------------------------------------------------------------------------------
echo "==> Building RPM package..."
rpmbuild --define "_topdir ${BUILD_ROOT}" -bb "${BUILD_ROOT}/SPECS/fedora-update.spec"
BUILT_RPM=$(find "${BUILD_ROOT}/RPMS" -name "*.rpm" | head -n1)
# ------------------------------------------------------------------------------
if [ -f "$BUILT_RPM" ]; then
cp "$BUILT_RPM" "${DEV_DIR}/fedora-update.rpm"
cp "$BUILT_RPM" "${DEV_DIR}/releases/fedora-update-${VERSION}-1.noarch.rpm"
echo "==> Archiving build release to backup directory..."
cp -r "${DEV_DIR}"/* "${BACKUP_DIR}/"
echo "==> Mirroring active workspace to SSD2 for cross-distro development..."
rsync -a --delete \
--exclude="*.tmp" \
"${DEV_DIR}/" "${MIRROR_DIR}/"
echo "==> Verifying SSD2 mirror 1:1 parity..."
if rsync -acn --delete --exclude="*.tmp" "${DEV_DIR}/" "${MIRROR_DIR}/" | grep -v '^\s*$' | grep -v '^sending incremental file list$' >/dev/null; then
echo "==> Warning: Discrepancies detected between workspace and SSD2 mirror."
else
echo "==> SSD2 mirror verified: 1:1 match."
fi
echo "==> Process completed successfully."
else
echo "==> Error: RPM build failed."
exit 1
fi