-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrustdesk_nightly_reversion.sh
executable file
·54 lines (48 loc) · 1.75 KB
/
rustdesk_nightly_reversion.sh
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
#!/bin/bash
set -oue pipefail
SOURCE_DIR="$1" # Directory containing the original .rpm files
IS_NIGHTLY_ARG="$2" # Input arg that determine whether needs reversion or not
TARGET_DIR=$(dirname "$SOURCE_DIR") # Target directory is the parent directory of SOURCE_DIR
DATE=$(date +%Y%m%d) # Current date in YYYYMMDD format
# Ensure the target directory exists
mkdir -p "$TARGET_DIR"
# Use $IS_NIGHTLY_ARG to determine it needs reversion or not
if [[ "$IS_NIGHTLY_ARG" == "IS_NIGHTLY" ]]; then
echo "IS_NIGHTLY passed in, will reversion."
IS_REVERSION=true
elif [[ -z "$IS_NIGHTLY_ARG" ]]; then
echo "IS_NIGHTLY IS NOT passed in, will repackage (recompression) only."
IS_REVERSION=false
else
echo "Unexpected input, exit."
exit 1
fi
# Iterate over all .rpm files in the source directory
for rpm_file in "$SOURCE_DIR"/*.rpm; do
if [ -f "$rpm_file" ]; then
(
echo "Processing: $rpm_file"
# Extract the original version
ORIGINAL_VERSION=$(rpm -qp --qf '%{VERSION}' "$rpm_file")
NEW_VERSION="${ORIGINAL_VERSION}+$DATE"
# Arg determine by $IS_REVERSION
if [[ "$IS_REVERSION" == true ]]; then
FPM_RPM_VERSION_ARG="--version $NEW_VERSION"
else
FPM_RPM_VERSION_ARG=""
fi
# Rebuild the RPM using fpm
fpm -t rpm -s rpm \
$FPM_RPM_VERSION_ARG --rpm-compression xz\
-p "$TARGET_DIR/$(basename "$rpm_file")" \
"$rpm_file"
echo "Processed and moved to: $TARGET_DIR/$(basename "$rpm_file")"
) &
else
echo "Skipping: $rpm_file"
fi
done
wait
echo "Done, all modified files moved to: $TARGET_DIR"
echo "Cleanup....."
rm -rf "$SOURCE_DIR"