-
Notifications
You must be signed in to change notification settings - Fork 3
/
fix-linux-rpm-package
executable file
·61 lines (52 loc) · 1.29 KB
/
fix-linux-rpm-package
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
#!/bin/bash
. ./BUILDDEFS
# Create RPM spec file from existing RPM
create_rpm_spec() {
local package=$1
local spec=$2
rpm -qp --qf "Name: %{NAME}
Version: %{VERSION}
Release: %{RELEASE}
BuildArch: %{ARCH}
Group: %{GROUP}
License: %{LICENSE}
Source RPM: %{SOURCERPM}
Vendor: Olofson Arcade
Packager: David Olofson <[email protected]>
URL: %{URL}
Summary: %{SUMMARY}
%%description
%{DESCRIPTION}
%%files
/usr/bin/*
/usr/share/doc/*
/usr/share/kobo*/*
/usr/share/applications/*
/usr/share/pixmaps/*
" ${package} > ${spec}
}
set -ex
PKGFILE=$1
PKGTMP="${WORKDIR}/$(basename ${PKGFILE}).tmp"
rm -rf ${PKGTMP}
# Unpack
mkdir ${PKGTMP}
cd ${PKGTMP}
rpm2cpio ${PKGFILE} | cpio -idmv
cd ..
# Fix bogus permissions
find "${PKGTMP}/." -type d -print0 | xargs -0 chmod 755
find "${PKGTMP}/usr/share" -type f -print0 | xargs -0 chmod 644
find "${PKGTMP}/usr/bin" -type f -print0 | xargs -0 chmod 755
create_rpm_spec ${PKGFILE} "${WORKDIR}/koboredux.spec"
echo "--- Generated spec ---"
cat "${WORKDIR}/koboredux.spec"
echo "----------------------"
# Repackage and clean up
archdir=$(rpm -qp --qf "%{ARCH}" ${PKGFILE})
rm ${PKGFILE}
rpmbuild --buildroot "${PKGTMP}" --define "_rpmdir $(pwd)" -bb "${WORKDIR}/koboredux.spec"
mv ${archdir}/*.rpm ${PKGFILE}
rm -rf ${archdir}
rm "${WORKDIR}/koboredux.spec"
rm -rf ${PKGTMP}