1 | #!/bin/sh
|
---|
2 |
|
---|
3 | . $(dirname $0)/conf.sh
|
---|
4 |
|
---|
5 | help="Options:
|
---|
6 | setup
|
---|
7 | add </path/to/1.rpm> ..."
|
---|
8 |
|
---|
9 | createrepo_check() {
|
---|
10 | cd $repos/rpm/ || {
|
---|
11 | echo "Repository not found. Have you set it up?" >&2
|
---|
12 | exit 1
|
---|
13 | }
|
---|
14 | test -x `which createrepo` || {
|
---|
15 | echo "Must install createrepo to manage rpm packages" >&2
|
---|
16 | exit 1
|
---|
17 | }
|
---|
18 | test -x `which rpmsign` || {
|
---|
19 | echo "Must install rpmsign to sign rpm packages" >&2
|
---|
20 | exit 1
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | case $1 in
|
---|
25 | setup)
|
---|
26 | echo "Making rpm package repository folders"
|
---|
27 | for arch in any x86_64 i386; do
|
---|
28 | mkdir -p $repos/rpm/$arch || exit 1
|
---|
29 | done
|
---|
30 | echo "Making repo file"
|
---|
31 | echo "\
|
---|
32 | [$label]
|
---|
33 | name=$origin
|
---|
34 | baseurl=http://$domain/repos/rpm/\$basearch
|
---|
35 | enabled=1
|
---|
36 | gpgcheck=1
|
---|
37 | gpgkey=http://$domain/repos/gpg.key" > "$repos/rpm/${label}.repo"
|
---|
38 | ;;
|
---|
39 | add)
|
---|
40 | if test -f $base/gpg.key.id; then
|
---|
41 | keyid=$(cat $base/gpg.key.id)
|
---|
42 | else
|
---|
43 | gpg --list-keys
|
---|
44 | echo "Enter the keyid of the GPG key to use:"
|
---|
45 | while test -z $keyid; do
|
---|
46 | echo -n "> "
|
---|
47 | read keyid
|
---|
48 | done
|
---|
49 | echo $keyid > $base/gpg.key.id
|
---|
50 | echo
|
---|
51 | fi
|
---|
52 | createrepo_check
|
---|
53 | shift
|
---|
54 | for pkg in $@; do
|
---|
55 | # Default to all architectures unless an architecture is specified
|
---|
56 | arch="any"
|
---|
57 | echo $pkg | grep 'x86_64\.rpm' >/dev/null 2>/dev/null && {
|
---|
58 | arch="x86_64"
|
---|
59 | }
|
---|
60 | echo $pkg | grep 'i686\.rpm' >/dev/null 2>/dev/null && {
|
---|
61 | arch="i386"
|
---|
62 | }
|
---|
63 | name="$(basename $pkg)"
|
---|
64 | echo "$name: $arch"
|
---|
65 | cp $pkg $arch/
|
---|
66 | # Unfortunately RPM is (as usual) sub-standard, and will not use
|
---|
67 | # gpg-agent. As such, you will probably be forced to enter a pass
|
---|
68 | # phrase for every single package that gets signed, regardless of
|
---|
69 | # whether your GPG key even has a pass-phrase (just hit enter in
|
---|
70 | # that case)
|
---|
71 | echo "Signing $name..."
|
---|
72 | rpmsign --key-id=$keyid --addsign $arch/$name
|
---|
73 | # If arch is any, symlink package into all architectures
|
---|
74 | if test "$arch" = "any"; then
|
---|
75 | for link in x86_64 i386; do
|
---|
76 | echo "$name: $link (linked)"
|
---|
77 | cd $link
|
---|
78 | ln -sf ../any/$name $name
|
---|
79 | cd ..
|
---|
80 | done
|
---|
81 | fi
|
---|
82 | done
|
---|
83 | for arch in x86_64 i386; do
|
---|
84 | cd $arch
|
---|
85 | createrepo --update .
|
---|
86 | rm -f repodata/repomd.xml.asc
|
---|
87 | gpg --detach-sign --armor --use-agent --default-key $keyid repodata/repomd.xml
|
---|
88 | cd ..
|
---|
89 | done
|
---|
90 | ;;
|
---|
91 | -h|--help|help)
|
---|
92 | echo "$help"
|
---|
93 | ;;
|
---|
94 | *)
|
---|
95 | if test -z "$*"; then
|
---|
96 | echo "$help"
|
---|
97 | else
|
---|
98 | createrepo_check
|
---|
99 | createrepo $@
|
---|
100 | fi
|
---|
101 | ;;
|
---|
102 | esac
|
---|