-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-driver-disk
executable file
·79 lines (61 loc) · 1.85 KB
/
create-driver-disk
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
72
73
74
75
76
77
78
79
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
set -e
## support funcs
die() {
echo >&2 "$0: ERROR: $*"
exit 1
}
die_usage() {
usage >&2
die "$@"
}
## parameter and environment handling, sanity checks
usage() {
echo "Usage: $0 <driver-info.cfg>"
}
[ $# = 1 ] || die_usage "not enough arguments"
# read config
. "./$1"
PACKAGE_NAME=$(rpm -q --qf "%{NAME}" -p "$RPM_FILE")
RPM_VERSION=$(rpm -q --qf "%{VERSION}" -p "$RPM_FILE")
RPM_RELEASE=$(rpm -q --qf "%{RELEASE}" -p "$RPM_FILE")
GPG_UID=$(gpg --batch --with-colons "$GPG_PUBKEY_FILE" 2>/dev/null | awk -F: '$1=="pub" {print $5}')
[ -r "$GPG_PUBKEY_FILE" ] || die "GPG_PUBKEY_FILE not found: '$GPG_PUBKEY_FILE'"
PACK_VERSION="$RPM_VERSION+$RPM_RELEASE+$PACK_BUILD"
ISO="${PACKAGE_NAME}-${PACK_VERSION}.iso"
echo "$RPM_SHA256 $RPM_FILE" | sha256sum --check
## the real stuff
GROUPSFILE=$(mktemp groups-XXXXXX.xml)
trap "rm '$GROUPSFILE'" EXIT
sed -e "s/@DRIVER@/${PACKAGE_NAME}/g" > "$GROUPSFILE" <<EOF
<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
<comps>
<group>
<id>update</id>
<default>False</default>
<uservisible>True</uservisible>
<name>Driver Update</name>
<description></description>
<packagelist>
<packagereq type="mandatory">update-@DRIVER@</packagereq>
</packagelist>
</group>
<group>
<id>drivers</id>
<default>False</default>
<uservisible>True</uservisible>
<name>Host Installer Driver Update</name>
<description></description>
<packagelist>
<packagereq type="mandatory">update-@DRIVER@</packagereq>
</packagelist>
</group>
</comps>
EOF
build-update --uuid "$PACK_UUID" --label "$PACKAGE_NAME" \
--version "$PACK_VERSION" \
--description "$PACK_DESC" \
--groupfile "$GROUPSFILE" \
--key "$GPG_UID" --keyfile "$GPG_PUBKEY_FILE" \
-o "$ISO" "$RPM_FILE"