-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_zimbra_rpms.sh
More file actions
executable file
·72 lines (60 loc) · 2.16 KB
/
extract_zimbra_rpms.sh
File metadata and controls
executable file
·72 lines (60 loc) · 2.16 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -euo pipefail
#
# Author: 6/24/2025 - JDunphy
#
# Purpose:
# This script downloads and extracts the latest versions of selected Zimbra RPMs
# to enable offline inspection of file contents and installation scripts.
# This is especially useful when deciding whether to apply patches revealed
# by 'dnf update' or defer them for scheduled maintenance.
#
# Usage:
# 1. Identify relevant Zimbra RPMs listed in the 'dnf update' output.
# 2. Add those package names to the PACKAGES array below.
# 3. Run this script to download, extract, and log script and build metadata.
#
# Summary:
# - WORKDIR: The working directory used to download and extract RPMs.
# Defaults to ~/zimbra_rpms with a subdirectory 'extracted'.
# - RPMs: Downloaded with all dependencies via `dnf download --resolve`
# - Extracted Files:
# * Extracted contents of each RPM go to WORKDIR/extracted/{rpm-name}
# * install_scripts.txt contains post/pre install/remove scriptlets
# * Build timestamp and metadata printed per RPM
#
# Requirements:
# - rpm2cpio and cpio must be installed
# - sudo privileges are needed for dnf operations
#
# Example Packages:
# zimbra-mbox-admin-console-war
# zimbra-mbox-webclient-war
# zimbra-patch
PACKAGES=(
zimbra-mbox-admin-console-war
zimbra-mbox-webclient-war
zimbra-patch
)
WORKDIR=~/zimbra_rpms
mkdir -p "$WORKDIR/extracted"
cd "$WORKDIR" || exit 1
echo "🧹 Cleaning up previous RPMs..."
rm -f "$WORKDIR"/*.rpm
echo "🔄 Cleaning and refreshing DNF metadata..."
sudo dnf clean all
sudo dnf makecache --refresh
echo "📥 Downloading latest RPM packages..."
sudo dnf download --resolve --downloaddir="$WORKDIR" "${PACKAGES[@]}"
echo "📦 Extracting RPMs..."
for rpm in "$WORKDIR"/*.rpm; do
name="${rpm##*/}"
name="${name%%.rpm}"
target_dir="$WORKDIR/extracted/$name"
mkdir -p "$target_dir"
echo "📂 Extracting $name to $target_dir"
rpm2cpio "$rpm" | (cd "$target_dir" && cpio -idmv)
echo "📄 Scripts in $name:"
rpm -q --scripts -p "$rpm" > "$target_dir/install_scripts.txt"
echo "🧾 Build info: $(rpm -qp --qf '%{name}-%{version}-%{release}.%{arch} :: %{buildtime:date}\n' "$rpm")"
done