~maria-captains/mariadb-tools/trunk

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash - 
#===============================================================================
#
#          FILE:  mkrepo-ubuntu.sh
# 
#         USAGE:  $0 <galera_pkgs?> <enterprise?> <reponame> <archive_dir>
# 
#   DESCRIPTION:  A script to generate the Ubuntu repositories for MariaDB
#                 Ubuntu packages.
#
#                 The script copies files from the archive directory into
#                 separate directories for each distribution/cpu combination
#                 (just like they are stored in the archive directory). For
#                 best results, it should be run within an empty directory.
#
#                 After running the script, the directories are uploaded to the
#                 mirrors, replacing the previous version in that series (i.e.
#                 the 10.0.15 files are replaced by the 10.0.16 files and the
#                 10.1.1 files are replaced by the 10.1.2 files, and so on).
# 
#===============================================================================

umask 002

#killall gpg-agent
# Right off the bat we want to log everything we're doing and exit immediately
# if there's an error
set -ex
  # -e  Exit immediately if a simple command exits with a non-zero status,
  #     unless the command that fails is part of an until or  while loop, part
  #     of an if statement, part of a && or || list, or if the command's return
  #     status is being inverted using !.  -o errexit
  #
  # -x  Print a trace of simple commands and their arguments after they are
  #     expanded and before they are executed.

#-------------------------------------------------------------------------------
#  Set command-line options
#-------------------------------------------------------------------------------
GALERA="$1"                       # copy in galera packages? 'yes' or 'no'
ENTERPRISE="$2"                   # is this an enterprise release? 'yes' or 'no'
REPONAME="$3"                     # name of the dir, usually 'ubuntu'
ARCHDIR="$4"                      # path to the packages
P8_ARCHDIR="$5"                   # path to p8 packages (optional)

#-------------------------------------------------------------------------------
#  Variables which are not set dynamically (because they don't change often)
#-------------------------------------------------------------------------------
galera_versions="25.3.19"                          # Version of galera in repos
dir_galera="/ds413/galera"                        # Location of galera pkgs
dir_jemalloc="/ds413/vms-customizations/jemalloc" # Location of jemalloc pkgs
#dir_xtrabackup="/ds413/repo/xtrabackup"           # Location of xtrabackup pkgs
#ver_xtrabackup="2.2.9"                            # Version of xtrabackup
dir_at="/ds413/vms-customizations/advance-toolchain" # Location of at pkgs

# If we are on 5.5 then only precise & trusty
if [[ "${ARCHDIR}" == *"5.5"* ]]; then
  ubuntu_dists="precise trusty"
else
  ubuntu_dists="precise trusty xenial yakkety"
fi
architectures="amd64 i386 source"

#-------------------------------------------------------------------------------
#  Main Script
#-------------------------------------------------------------------------------
# Get the GPG daemon running so we don't have to keep entering the password for
# the GPG key every time we sign a package
eval $(gpg-agent --daemon)

# At this point, all variables should be set. Print a usage message if the
# ${ARCHDIR} variable is not set (the last of the command-line variables).
if [ ! -d "$ARCHDIR" ] ; then
    echo 1>&2 "Usage: $0 <galera_pkgs?> <enterprise?> <reponame> <archive_dir>"
    echo 1>&2 "example: $0 yes no ubuntu /media/backup/archive/pack/10.0/build-1234"
    exit 1
fi

# After this point, we tread unset variables as an error
set -u
  # -u  Treat unset variables as an error when performing parameter expansion.
  #     An error message will be written to the standard error, and a
  #     non-interactive shell will exit.

# If this is an "Enterprise" MariaDB release, sign with the mariadb.com key,
# otherwise, sign with the mariadb.org key
if [ "${ENTERPRISE}" = "yes" ]; then
  origin="MariaDB Enterprise"
  description="MariaDB Enterprise Repository"
  gpg_key="signing-key@mariadb.com"            # new enterprise key (2014-12-18)
  #gpg_key="0xce1a3dd5e3c94f49"                # new enterprise key (2014-12-18)
  #ubuntu_dists="precise trusty utopic"
  ubuntu_dists="precise trusty xenial"                # no utopic for enterprise just yet 
  architectures="amd64 i386 source"                  # for enterprise, add i386
  architectures_ppc64el="amd64 i386 ppc64el source"   # for trusty and xenial, add ppc64el
  suffix="signed-ent"
else
  origin="MariaDB"
  description="MariaDB Repository"
  #gpg_key="package-signing-key@mariadb.org"    # mariadb.org signing key
  gpg_key="0xcbcb082a1bb943db"                  # mariadb.org signing key
  gpg_key_2016="0xF1656F24C74CD1D8"             # 2016-03-30 mariadb.org signing key
  #gpg_key="0xcbcb082a1bb943db 0xF1656F24C74CD1D8" # both keys
  #architectures_ppc64el="${architectures}"       # same if not enterprise
  architectures_ppc64el="amd64 i386 ppc64el source"   # for trusty and xenial, add ppc64el
  suffix="signed"
fi

if [ ! -d ${REPONAME} ]; then
  mkdir "$REPONAME"
fi

cd "$REPONAME"

if [ ! -d conf ]; then
  mkdir conf
fi

# Delete the conf/distributions file if it exists
#if [ -f conf/distributions ]; then
#  rm -f "conf/distributions"
#fi

# Removing conf/distributions file creation step - 2016-09-12
## Create the conf/distributions file
#for dist in ${ubuntu_dists}; do
#  case ${dist} in 
#    'trusty') cat >>conf/distributions <<END
#Origin: ${origin}
#Label: MariaDB
#Codename: trusty
#Architectures: ${architectures_ppc64el}
#Components: main
#Description: ${description}
#SignWith: ${gpg_key}
#
#END
#      ;;
#    'xenial') cat >>conf/distributions <<END
#Origin: ${origin}
#Label: MariaDB
#Codename: ${dist}
#Architectures: ${architectures_ppc64el}
#Components: main
#Description: ${description}
#SignWith: ${gpg_key_2016}
#
#END
#      ;;
#    *) cat >>conf/distributions <<END
#Origin: ${origin}
#Label: MariaDB
#Codename: ${dist}
#Architectures: ${architectures}
#Components: main
#Description: ${description}
#SignWith: ${gpg_key}
#
#END
#      ;;
#  esac
#done

# Remove packages from deprecated distros (if they are present)
#reprepro --basedir=. --delete clearvanished

# Add packages
for dist in ${ubuntu_dists}; do
  echo ${dist}
  case ${dist} in 
    'trusty'|'utopic'|'xenial')
      reprepro --basedir=. include ${dist} $ARCHDIR/kvm-deb-${dist}-amd64/debs/binary/mariadb-*_amd64.changes
      ;;
    * )
      for file in $(find "$ARCHDIR/kvm-deb-${dist}-amd64/" -name '*.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      for file in $(find "$ARCHDIR/kvm-deb-${dist}-amd64/" -name '*.dsc'); do reprepro --basedir=. includedsc ${dist} ${file} ; done
      ;;
  esac

  if [ "${ENTERPRISE}" != "yes" ]; then
    for file in $(find "$ARCHDIR/kvm-deb-${dist}-x86/" -name '*_i386.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
  fi

  # Include trusty ppc64le debs
  if [ "${dist}" = "trusty" ]; then
    for file in $(find "$ARCHDIR/kvm-deb-${dist}-ppc64le/" -name '*_ppc64el.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
    for file in $(find "${dir_at}/${dist}-ppc64el-${suffix}/" -name '*_ppc64el.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
  fi

  #if [ "${ENTERPRISE}" = "yes" ]; then
    if [ "${dist}" = "xenial" ]; then
      if [ ! -d "${P8_ARCHDIR}" ] ; then
        echo 1>&2 "! I can't find the directory for Power 8 debs! '${P8_ARCHDIR}'"
        exit 1
      else
        for file in $(find "${P8_ARCHDIR}/p8-${dist}-deb/" -name '*_ppc64el.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
        # Add xtrabackup files
        #reprepro --basedir=. include ${dist} ${dir_xtrabackup}/ppc64el/${ver_xtrabackup}-${suffix}/${dist}/percona-xtrabackup_${ver_xtrabackup}*_ppc64el.changes
      fi
    fi
  #fi

  # Add in custom jemalloc packages for distros that need them
  case ${dist} in
    "lucid")
      for file in $(find "${dir_jemalloc}/${dist}-amd64/" -name '*_amd64.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      if [ "${ENTERPRISE}" != "yes" ]; then
        for file in $(find "${dir_jemalloc}/${dist}-i386/" -name '*_i386.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      fi
      ;;
    "precise")
      for file in $(find "${dir_jemalloc}/${dist}-amd64/" -name '*_amd64.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      if [ "${ENTERPRISE}" != "yes" ]; then
        for file in $(find "${dir_jemalloc}/${dist}-i386/" -name '*_i386.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      fi
      ;;
    "quantal")
      for file in $(find "${dir_jemalloc}/${dist}-amd64/" -name '*_amd64.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      if [ "${ENTERPRISE}" != "yes" ]; then
        for file in $(find "${dir_jemalloc}/${dist}-i386/" -name '*_i386.deb'); do reprepro --basedir=. includedeb ${dist} ${file} ; done
      fi
      ;;
    * )
      echo "no custom jemalloc packages for ${dist}"
      ;;
  esac





  # Copy in galera packages if requested
  if [ ${GALERA} = "yes" ]; then
    for gv in ${galera_versions}; do
      if [ "${ENTERPRISE}" = "yes" ]; then
        #for file in $(find "${dir_galera}/galera-${gv}-${suffix}/" -name "*${dist}*amd64.deb"); do reprepro -S optional -P misc --basedir=. includedeb ${dist} ${file} ; done
        reprepro --basedir=. include ${dist} ${dir_galera}/galera-${gv}-${suffix}/deb/galera-3_${gv}-${dist}*_amd64.changes
        if [ "${dist}" = "trusty" ] || [ "${dist}" = "xenial" ]; then
          reprepro --basedir=. include ${dist} ${dir_galera}/galera-${gv}-${suffix}/deb/galera-3_${gv}-${dist}*_ppc64el.changes
        fi
      else
        #for file in $(find "${dir_galera}/galera-${gv}-${suffix}/" -name "*${dist}*.deb"); do reprepro -S optional -P misc --basedir=. includedeb ${dist} ${file} ; done
        reprepro --basedir=. include ${dist} ${dir_galera}/galera-${gv}-${suffix}/deb/galera-3_${gv}-${dist}*_amd64.changes
        reprepro --basedir=. include ${dist} ${dir_galera}/galera-${gv}-${suffix}/deb/galera-3_${gv}-${dist}*_i386.changes
        if [ "${dist}" = "trusty" ] || [ "${dist}" = "xenial" ]; then
          reprepro --basedir=. include ${dist} ${dir_galera}/galera-${gv}-${suffix}/deb/galera-3_${gv}-${dist}*_ppc64el.changes
        fi
      fi
    done
  fi
done

# Create sums of .deb packages
md5sum ./pool/main/*/*/*.deb >> md5sums.txt
sha1sum ./pool/main/*/*/*.deb >> sha1sums.txt
sha256sum ./pool/main/*/*/*.deb >> sha256sums.txt
sha512sum ./pool/main/*/*/*.deb >> sha512sums.txt