加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
package_linux_amd64.sh 5.95 KB
一键复制 编辑 原始数据 按行查看 历史
Guillaume Lefranc 提交于 2020-04-27 11:51 . Revert "Mark config file"
#!/bin/bash
# exit on error
set -e
nobuild=0
if [ "$1" != "" ]; then
if [ "$1" = "--no-build" ]; then
nobuild=1
fi
fi
echo "# Getting branch info"
git status -bs
builddir="$(pwd)"/build
mkdir -p "$builddir"/binaries "$builddir"/package "$builddir"/tar "$builddir"/release
version=$(git describe --tag --abbrev=4 | sed 's/^v//')
head=$(git rev-parse --short HEAD)
epoch=$(date +%s)
description="Replication Manager for MariaDB and MySQL"
maintainer="info@signal18.io"
license="GPLv3"
if [ $nobuild -eq 0 ]; then
echo "# Building"
make
fi
echo "# Cleaning up previous builds"
rm -rf "$builddir"/package/* "$builddir"/tar/* "$builddir"/release/*
mkdir -p "$builddir"/package/usr/bin
echo "# Building packages replication-manager-cli"
cflags=(-m "$maintainer" --license "$license" -v $version)
cp "$builddir"/binaries/replication-manager-cli "$builddir"/package/usr/bin/
fpm ${cflags[@]} --rpm-os linux -C "$builddir"/package -s dir -t rpm -n replication-manager-client --description "$description - client package" -p "$builddir/release"
fpm ${cflags[@]} -C "$builddir"/package -s dir -t deb -n replication-manager-client --description "$description - client package" -p "$builddir/release"
fpm --package replication-manager-client-$version.tar -C "$builddir"/package -s dir -t tar -n replication-manager-client -p "$builddir"/release/replication-manager-client-$version.tar.gz
mkdir -p "$builddir"/package/usr/share/replication-manager/dashboard
mkdir -p "$builddir"/package/etc/replication-manager
mkdir -p "$builddir"/package/etc/systemd/system
mkdir -p "$builddir"/package/etc/init.d
mkdir -p "$builddir"/package/var/lib/replication-manager/cluster.d
mkdir -p "$builddir"/tar/bin
mkdir -p "$builddir"/tar/etc
mkdir -p "$builddir"/tar/share
mkdir -p "$builddir"/tar/data/cluster.d
echo "# Copying files to build dir"
cp -r dashboard/* "$builddir"/package/usr/share/replication-manager/dashboard/
cp -r share/* "$builddir"/package/usr/share/replication-manager/
# do not package commercial collector docker images
rm -rf "$builddir"/package/usr/share/replication-manager/opensvc/*.tar.gz
for flavor in min osc tst pro osc-cgo
do
echo "# Building packages replication-manager-$flavor"
case $flavor in
min)
extra_desc="Minimal version"
;;
osc)
extra_desc="Open source version"
;;
osc-cgo)
extra_desc="Open source glibc version "
;;
pro)
extra_desc="Professional version"
;;
tst)
extra_desc="Testing version"
;;
esac
cp -r etc/* "$builddir"/package/etc/replication-manager/
if [ "$flavor" != "pro" ]; then
rm -f "$builddir"/package/etc/replication-manager/config.toml.sample.opensvc.*
else
cp -rp test/opensvc "$builddir"/package/usr/share/replication-manager/tests
fi
cp "$builddir"/binaries/replication-manager-$flavor "$builddir"/package/usr/bin/
cp service/replication-manager-$flavor.service "$builddir"/package/etc/systemd/system/replication-manager.service
cp service/replication-manager-$flavor.init.el6 "$builddir"/package/etc/init.d/replication-manager
fpm ${cflags[@]} --rpm-os linux -C "$builddir"/package -s dir -t rpm -n replication-manager-$flavor --epoch $epoch --description "$description - $extra_desc" -p "$builddir/release"
cp service/replication-manager-$flavor.init.deb7 "$builddir"/package/etc/init.d/replication-manager
fpm ${cflags[@]} -C "$builddir"/package -s dir -t deb -n replication-manager-$flavor --description "$description - $extra_desc" -p "$builddir/release"
rm -f "$builddir"/package/usr/bin/replication-manager-$flavor
echo "# Building tarball replication-manager-$flavor"
cp -r etc/* "$builddir"/tar/etc/
if [ "$flavor" != "pro" ]; then
rm -f "$builddir"/tar/etc/config.toml.sample.opensvc.*
else
cp -rp test/opensvc "$builddir"/tar/share/tests
fi
cp "$builddir"/binaries/replication-manager-$flavor-basedir "$builddir"/tar/bin/replication-manager-$flavor
cp service/replication-manager-$flavor-basedir.service "$builddir"/tar/share/replication-manager.service
cp service/replication-manager-$flavor-basedir.init.el6 "$builddir"/tar/share/replication-manager.init
fpm --package replication-manager-$flavor-$version.tar --prefix replication-manager-$flavor -C "$builddir"/tar -s dir -t tar -n replication-manager-$flavor -p "$builddir"/release/replication-manager-$flavor-$version.tar.gz .
rm -rf "$builddir"/tar/bin/replication-manager-$flavor
done
echo "# Building arbitrator packages"
rm -rf "$builddir"/package/etc
rm -rf "$builddir"/package/usr/share
mkdir -p "$builddir"/package/etc/replication-manager
mkdir -p "$builddir"/package/etc/systemd/system
mkdir -p "$builddir"/package/etc/init.d
mkdir -p "$builddir"/package/var/lib/replication-manager
cp service/replication-manager-arb.service "$builddir"/package/etc/systemd/system
cp "$builddir"/binaries/replication-manager-arb "$builddir"/package/usr/bin/
# RPM
cp service/replication-manager-arb.init.el6 "$builddir"/package/etc/init.d/replication-manager-arb
fpm ${cflags[@]} --rpm-os linux -C "$builddir"/package -s dir -t rpm -n replication-manager-arbitrator --epoch $epoch --description "$description - arbitrator package" -p "$builddir/release"
# Debian
cp service/replication-manager-arb.init.deb7 "$builddir"/package/etc/init.d/replication-manager-arbitrator
fpm ${cflags[@]} -C "$builddir"/package -s dir -t deb -n replication-manager-arbitrator --description "$description - arbitrator package" -p "$builddir/release"
# tar
rm -rf "$builddir"/tar/*
mkdir -p "$builddir"/tar/etc
mkdir -p "$builddir"/tar/data
mkdir -p "$builddir"/tar/bin
mv "$builddir"/package/usr/bin/replication-manager-arb "$builddir"/tar/bin
fpm --package replication-manager-arbitrator-$version.tar -C "$builddir"/tar -s dir -t tar -n replication-manager-arbitrator -p "$builddir"/release/replication-manager-arbitrator-$version.tar.gz
echo "# Build complete"
rm -rf "$builddir"/tar/
rm -rf "$builddir"/package/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化