1 | #!/bin/sh
|
---|
2 | # $Id: $
|
---|
3 | # dass IT GmbH
|
---|
4 | #
|
---|
5 | # This script reads some information out of rpm packages and generates Suse patch files, signs and
|
---|
6 | # checks signature of package and finally puts patch descriptions and rpms onto the you server
|
---|
7 | #
|
---|
8 | # Parameter: binary rpm file
|
---|
9 | # TODO: Make patches consisting of more than one rpm, proceed some more rpm attributes into patch file
|
---|
10 |
|
---|
11 | ## customize THIS:
|
---|
12 |
|
---|
13 | YOUSERVER=lxcdtower
|
---|
14 | # There must be subirectories named patches and rpm below this path
|
---|
15 | YOUPATH=/cds/linux/i386/update/lvermgeo
|
---|
16 |
|
---|
17 | SIGNID="build@lvermgeo.rlp.de"
|
---|
18 |
|
---|
19 | ##
|
---|
20 |
|
---|
21 | function out()
|
---|
22 | {
|
---|
23 | echo $1 >> $PATCHFILE
|
---|
24 | #echo -e "\n" >> $PATCHFILE
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | #DESCRDIR=/usr/src/packages/PATCH/
|
---|
29 | DESCRDIR=/tmp
|
---|
30 |
|
---|
31 | PAKET=`rpm --queryformat %{NAME} -qp $1`
|
---|
32 | SUFFIX=`rpm --queryformat %{VERSION}-%{RELEASE} -qp $1`
|
---|
33 | SUMMARY=`rpm --queryformat %{SUMMARY} -qp $1`
|
---|
34 | DESCRIPTION=`rpm --queryformat %{DESCRIPTION} -qp $1`
|
---|
35 | ARCH=`rpm --queryformat %{ARCH} -qp $1`
|
---|
36 | GROUP=`rpm --queryformat %{GROUP} -qp $1`
|
---|
37 | SIZE=`rpm --queryformat %{SIZE} -qp $1`
|
---|
38 |
|
---|
39 | RELEASE=`date +%Y%m%d%H%M`
|
---|
40 |
|
---|
41 | RPMFILEBASENAME=`basename $1`
|
---|
42 |
|
---|
43 | # Name of patch-description file
|
---|
44 | PATCHFILE="$DESCRDIR/patch-$PAKET-$SUFFIX"
|
---|
45 |
|
---|
46 | if [ -e $PATCHFILE ]
|
---|
47 | then
|
---|
48 | rm $PATCHFILE
|
---|
49 | fi
|
---|
50 | out "##"
|
---|
51 | out "## Patch Description for $PAKET"
|
---|
52 | out "##"
|
---|
53 | out
|
---|
54 | out "Kind: recommended"
|
---|
55 | out "Shortdescription.english: $SUMMARY"
|
---|
56 | out "Longdescription.english:"
|
---|
57 | out "$DESCRIPTION"
|
---|
58 | out " "
|
---|
59 | out "Hsilgne.noitpircsedgnol:"
|
---|
60 | out "UpdateOnlyInstalled: false"
|
---|
61 | out "Size: $SIZE"
|
---|
62 | out "MinYaST1Version:"
|
---|
63 | out "MinYaST2Version:"
|
---|
64 | out
|
---|
65 | out "Packages:"
|
---|
66 | out "##"
|
---|
67 | out "Filename: $PAKET.rpm"
|
---|
68 | out "Label: $PAKET"
|
---|
69 | out "Series: $ARCH"
|
---|
70 | out "DepAND:"
|
---|
71 | out "DepOR:"
|
---|
72 | out "DepExcl:"
|
---|
73 | out "Flag:"
|
---|
74 | out "Category:"
|
---|
75 | out "RpmGroup: $GROUP"
|
---|
76 | out "Copyright: see package"
|
---|
77 | out "AuthorAddress:"
|
---|
78 | out "Version: $SUFFIX"
|
---|
79 | out "StartCommand:"
|
---|
80 | out "Obsoletes:"
|
---|
81 | out "Segakcap:"
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | #for i in $SIGNID
|
---|
86 | #do
|
---|
87 | # echo Please enter Passphrase for gpg ID $SIGNID:
|
---|
88 | # read PASS
|
---|
89 |
|
---|
90 | echo -n "Passphrase for signing packages: "
|
---|
91 | read PASS
|
---|
92 |
|
---|
93 | echo $PASS | gpg -u $SIGNID --passphrase-fd 0 --clearsign $PATCHFILE
|
---|
94 | expect -c "spawn rpm --addsign $1" -c 'expect -ex "Enter pass phrase:"' -c "send $PASS\n" -c 'expect "Pass phrase"' -c 'wait'
|
---|
95 |
|
---|
96 | # gpg -u $SIGNID --clearsign $PATCHFILE
|
---|
97 | mv $PATCHFILE.asc $PATCHFILE
|
---|
98 | # rpm --addsign $1
|
---|
99 |
|
---|
100 | #done
|
---|
101 |
|
---|
102 | if (rpm --checksig $1 | grep -q "gpg OK")
|
---|
103 | then
|
---|
104 | # publish
|
---|
105 | echo "Lösche alte Patch-Description"
|
---|
106 | ssh $YOUSERVER "rm $YOUPATH/patches/patch-$PAKET-*"
|
---|
107 | echo "Kopiere Dateien ..."
|
---|
108 | scp $PATCHFILE $YOUSERVER:$YOUPATH/patches
|
---|
109 | ssh $YOUSERVER "cd $YOUPATH/patches; ls -1 -A > directory.3"
|
---|
110 | scp $1 $YOUSERVER:$YOUPATH/rpm/$ARCH/
|
---|
111 | ssh $YOUSERVER "cd $YOUPATH/rpm/$ARCH/; ln -sf $RPMFILEBASENAME $PAKET.rpm; ls -1 -A > directory.3"
|
---|
112 | else
|
---|
113 | echo "rpm Signature _not_ Ok. stop"
|
---|
114 | exit 1
|
---|
115 | fi
|
---|