-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrpmx
More file actions
executable file
·39 lines (33 loc) · 1007 Bytes
/
srpmx
File metadata and controls
executable file
·39 lines (33 loc) · 1007 Bytes
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
#!/bin/bash -
# srpm-extract -- Extract files from a source RPM
# 2002-05-27 JPV
# 2025-01-13,09-23: if this fails, like as follows, `apt install rpm2cpio`
# or see the BINARY `/bin/rpm2cpio` on an RPM system!
# Error: header not recognized
# cpio: premature end of archive
if [ -z "$1" -o "$1" == '-h' -o "$1" == '--help' ]; then
echo ''
echo 'Extract files from an (S)RPM:'
echo " usage: $0 {Package Name}"
echo ''
echo "Will create a dir name based on the file by removing .(s)rpm suffix."
echo ''
exit 1
fi
file="$1"
dir="${file%%.srpm}" # Remove trailing .srpm, if any
dir="${dir%%.rpm}" # Remove trailing .rpm, if any
set -e # Exit immediately if a command exits with a non-zero status
if [ ! -f "$file" ]; then
echo "FATAL: '$file' not found!"
exit 2
fi
if [ -d "$dir" ]; then
echo "FATAL: '$dir' already exists!"
exit 3
else
mkdir "$dir"
fi
cd "$dir"
echo "Extracting to '$dir'..."
rpm2cpio "../$file" | cpio -i --make-directories