Debian Codegraph @

build-tools/pkgos-keyring-package

raw
1 #!/bin/sh
2
3 set -e
4 set -x
5
6 #################################
7 # AUTOMATICALLY DETECT ENV HERE #
8 #################################
9
10 if ! [ -r /etc/pkgos/pkgos.conf ] ; then
11 echo "Could not read /etc/pkgos/pkgos.conf"
12 exit 1
13 else
14 . /etc/pkgos/pkgos.conf
15 fi
16
17 detect_env () {
18 DEB_RELEASE=`lsb_release -a | grep Codename: | awk '{print $2}'`
19 DEB_RELEASE_NUM=`lsb_release -a | grep Release: | awk '{print $2}'`
20 DEB_DIST_TYPE=$(lsb_release -a | grep "Distributor ID:" | awk '{print $3}')
21 APT="apt-get install -y"
22 echo 'APT::Install-Recommends "0";' >/etc/apt/apt.conf.d/80norecommends
23 }
24
25 build_ostack_archive_keyring_package () {
26 # # Export the jenkins GPG key as pubkey.gpg in debian/dists/pubkey.gpg
27 # mkdir -p ${REPO_ROOT}/debian/dists
28 # chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${REPO_ROOT}/debian/dists
29 # chown ${THE_DEV_USER}:${THE_DEV_USER} ${REPO_ROOT}/debian
30 # su ${THE_DEV_USER} -c "gpg --export -a ${THE_DEV_USER}" >${REPO_ROOT}/debian/dists/pubkey.gpg
31
32 # Create a Debian package out of it, called openstack-debian-archive-keyring
33 # and put it in the newly created Debian repository.
34 # Yes, a working, Debian-policy-compliant package is really only a few lines of shell... :)
35 TMPDIR=`mktemp -d`
36 MYCWD=`pwd`
37 cd ${TMPDIR}
38 VER=0.1
39 NAME=openstack-backports-archive-keyring
40 rm -rf ${NAME}-${VER}
41 mkdir -p ${NAME}-${VER}/debian/source
42 cd ${NAME}-${VER}
43 export DEBFULLNAME="Autogenerated key"
44 export DEBEMAIL="${THE_DEV_USER}@${HOST_FQDN}"
45 dch --create --package ${NAME} -D unstable --noquery --newversion 0.1 -m "Automatic archive package build."
46 sed -i 's/MAINTAINER <EMAIL>/Autogenerated key <'${THE_DEV_USER}'@'${HOST_FQDN}'>/' debian/changelog
47 echo "3.0 (native)" >debian/source/format
48 echo 9 >debian/compat
49 echo "#!/usr/bin/make -f
50 %:
51 dh \$@
52 " >debian/rules
53 echo "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
54 Upstream-Name: ${NAME}
55 Source: See the openstack-pkg-tools package
56
57 Files: *
58 Copyright: (c) 2015, Thomas Goirand <[email protected]>
59 License: Apache-2
60 Licensed under the Apache License, Version 2.0 (the \"License\");
61 you may not use this file except in compliance with the License.
62 You may obtain a copy of the License at
63 .
64 http://www.apache.org/licenses/LICENSE-2.0
65 .
66 Unless required by applicable law or agreed to in writing, software
67 distributed under the License is distributed on an \"AS IS\" BASIS,
68 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69 See the License for the specific language governing permissions and
70 limitations under the License.
71 .
72 On Debian-based systems the full text of the Apache version 2.0 license
73 can be found in /usr/share/common-licenses/Apache-2.0.
74 " >debian/copyright
75 echo "Source: ${NAME}
76 Section: net
77 Priority: extra
78 Maintainer: PKG OpenStack <[email protected]>
79 Uploaders: Thomas Goirand <[email protected]>
80 Build-Depends: debhelper (>= 9)
81 Standards-Version: 3.9.6
82
83 Package: ${NAME}
84 Architecture: all
85 Depends: gnupg, \${misc:Depends}
86 Description: OpenStack ${TARGET_OPENSTACK_REL} ${TARGET_DISTRO} archive keyring
87 OpenStack ${TARGET_OPENSTACK_REL} ${TARGET_DISTRO} archive keyring
88 ">debian/control
89 #su ${THE_DEV_USER} -c "gpg --export -a ${THE_DEV_USER}" >pubkey.gpg
90 gpg --export -a >pubkey.gpg
91 echo "pubkey.gpg /usr/share/${NAME}" >debian/${NAME}.install
92 echo "#!/bin/sh
93 set -e
94
95 if [ \"\$1\" = \"configure\" ] || [ \"\$1\" = \"reconfigure\" ] ; then
96 apt-key add /usr/share/${NAME}/pubkey.gpg
97 fi
98
99 #DEBHELPER#
100
101 exit 0
102 " >debian/${NAME}.postinst
103 #chown -R ${THE_DEV_USER}:${THE_DEV_USER} .
104 #su ${THE_DEV_USER} -c dpkg-buildpackage || true
105 dpkg-buildpackage
106 FIRST_LETTER=`echo ${NAME} | awk '{print substr($0,0,2)}'`
107 cd ..
108 MYDEST=${REPO_ROOT}/debian/pool/${REPO_DEST}/main/${FIRST_LETTER}/${NAME}
109 MYDEST2=${REPO_ROOT}/debian/pool/${REPO_NOCHANGE_BACKPORT_DEST}/main/${FIRST_LETTER}/${NAME}
110 for i in ${MYDEST} ${MYDEST2} ; do
111 mkdir -p ${i}
112 cp *.changes *.tar.xz *.deb *.dsc ${i}
113 done
114 cd ${MYCWD}
115 rm -r ${TMPDIR}
116 }
117
118 HOST_FQDN=`hostname --fqdn`
119 THE_DEV_USER=jenkins
120 build_ostack_archive_keyring_package