dist/debian: Use pbuilder for Ubuntu/Debian debs
Enable pbuilder for Ubuntu/Debian to prevent build enviroment dependent issues. Also support cross building by pbuilder. (cross-building from Fedora 25 and Ubuntu 16.04 are tested) Signed-off-by: Takuya ASADA <syuu@scylladb.com> Message-Id: <20170615100230.18239-1-syuu@scylladb.com>
This commit is contained in:
parent
e954db8444
commit
8d404d8e9f
111
dist/debian/build_deb.sh
vendored
111
dist/debian/build_deb.sh
vendored
@ -1,37 +1,91 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
. /etc/os-release
|
||||||
|
print_usage() {
|
||||||
|
echo "build_deb.sh -target <codename>"
|
||||||
|
echo " --target target distribution codename"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
TARGET=
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
"--target")
|
||||||
|
TARGET=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
print_usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
is_redhat_variant() {
|
||||||
|
[ -f /etc/redhat-release ]
|
||||||
|
}
|
||||||
|
is_debian_variant() {
|
||||||
|
[ -f /etc/debian_version ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pkg_install() {
|
||||||
|
if is_redhat_variant; then
|
||||||
|
sudo yum install -y $1
|
||||||
|
elif is_debian_variant; then
|
||||||
|
sudo apt-get install -y $1
|
||||||
|
else
|
||||||
|
echo "Requires to install following command: $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -e dist/debian/build_deb.sh ]; then
|
if [ ! -e dist/debian/build_deb.sh ]; then
|
||||||
echo "run build_deb.sh in top of scylla dir"
|
echo "run build_deb.sh in top of scylla dir"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [ "$(arch)" != "x86_64" ]; then
|
||||||
|
echo "Unsupported architecture: $(arch)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -e debian ] || [ -e build ] || [ -e target ] || [ -e m2 ] || [ -e dependency-reduced-pom.xml ]; then
|
if [ -e debian ] || [ -e build/release ]; then
|
||||||
rm -rf debian build target m2 dependency-reduced-pom.xml
|
rm -rf debian build conf/hotspot_compiler
|
||||||
|
mkdir build
|
||||||
fi
|
fi
|
||||||
|
if is_debian_variant; then
|
||||||
sudo apt-get -y update
|
sudo apt-get -y update
|
||||||
if [ ! -f /usr/bin/git ]; then
|
|
||||||
sudo apt-get -y install git
|
|
||||||
fi
|
fi
|
||||||
if [ ! -f /usr/bin/lsb_release ]; then
|
# this hack is needed since some environment installs 'git-core' package, it's
|
||||||
sudo apt-get -y install lsb-release
|
# subset of the git command and doesn't works for our git-archive-all script.
|
||||||
|
if is_redhat_variant && [ ! -f /usr/libexec/git-core/git-submodule ]; then
|
||||||
|
yum install -y git
|
||||||
|
fi
|
||||||
|
if [ ! -f /usr/bin/git ]; then
|
||||||
|
pkg_install git
|
||||||
fi
|
fi
|
||||||
if [ ! -f /usr/bin/python ]; then
|
if [ ! -f /usr/bin/python ]; then
|
||||||
sudo apt-get -y install python
|
pkg_install python
|
||||||
fi
|
fi
|
||||||
DISTRIBUTION=`lsb_release -i|awk '{print $3}'`
|
if [ ! -f /usr/sbin/pbuilder ]; then
|
||||||
RELEASE=`lsb_release -r|awk '{print $2}'`
|
pkg_install pbuilder
|
||||||
CODENAME=`lsb_release -c|awk '{print $2}'`
|
fi
|
||||||
|
if [ ! -f /usr/bin/mvn ]; then
|
||||||
if [ "$RELEASE" = "14.04" ]; then
|
pkg_install maven
|
||||||
sudo apt-get -y install software-properties-common
|
fi
|
||||||
sudo add-apt-repository -y ppa:openjdk-r/ppa
|
if [ ! -f /usr/bin/dh_testdir ]; then
|
||||||
sudo apt-get -y update
|
pkg_install debhelper
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CODENAME" = "jessie" ]; then
|
|
||||||
sudo sh -c 'echo deb "http://httpredir.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list'
|
if [ -z "$TARGET" ]; then
|
||||||
sudo apt-get -y update
|
if is_debian_variant; then
|
||||||
sudo apt-get install -t jessie-backports -y ca-certificates-java
|
if [ ! -f /usr/bin/lsb_release ]; then
|
||||||
|
pkg_install lsb-release
|
||||||
|
fi
|
||||||
|
TARGET=`lsb_release -c|awk '{print $2}'`
|
||||||
|
else
|
||||||
|
echo "Please specify target"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION=$(./SCYLLA-VERSION-GEN)
|
VERSION=$(./SCYLLA-VERSION-GEN)
|
||||||
@ -48,7 +102,7 @@ cp dist/debian/changelog.in debian/changelog
|
|||||||
cp dist/debian/rules.in debian/rules
|
cp dist/debian/rules.in debian/rules
|
||||||
sed -i -e "s/@@VERSION@@/$SCYLLA_VERSION/g" debian/changelog
|
sed -i -e "s/@@VERSION@@/$SCYLLA_VERSION/g" debian/changelog
|
||||||
sed -i -e "s/@@RELEASE@@/$SCYLLA_RELEASE/g" debian/changelog
|
sed -i -e "s/@@RELEASE@@/$SCYLLA_RELEASE/g" debian/changelog
|
||||||
sed -i -e "s/@@CODENAME@@/$CODENAME/g" debian/changelog
|
sed -i -e "s/@@CODENAME@@/$TARGET/g" debian/changelog
|
||||||
if [ "$DISTRIBUTION" = "Ubuntu" ]; then
|
if [ "$DISTRIBUTION" = "Ubuntu" ]; then
|
||||||
sed -i -e "s/@@REVISION@@/0ubuntu1/g" debian/changelog
|
sed -i -e "s/@@REVISION@@/0ubuntu1/g" debian/changelog
|
||||||
else
|
else
|
||||||
@ -62,5 +116,18 @@ fi
|
|||||||
cp dist/common/systemd/scylla-jmx.service.in debian/scylla-jmx.service
|
cp dist/common/systemd/scylla-jmx.service.in debian/scylla-jmx.service
|
||||||
sed -i -e "s#@@SYSCONFDIR@@#/etc/default#g" debian/scylla-jmx.service
|
sed -i -e "s#@@SYSCONFDIR@@#/etc/default#g" debian/scylla-jmx.service
|
||||||
|
|
||||||
sudo apt-get install -y debhelper maven openjdk-8-jdk-headless devscripts
|
cp ./dist/debian/pbuilderrc ~/.pbuilderrc
|
||||||
debuild -r fakeroot -us -uc
|
sudo rm -fv /var/cache/pbuilder/$TARGET-base.tgz
|
||||||
|
sudo -E DIST=$TARGET /usr/sbin/pbuilder clean
|
||||||
|
sudo -E DIST=$TARGET /usr/sbin/pbuilder create
|
||||||
|
sudo -E DIST=$TARGET /usr/sbin/pbuilder update
|
||||||
|
if [ "$TARGET" = "trusty" ]; then
|
||||||
|
true
|
||||||
|
elif [ "$TARGET" = "xenial" ]; then
|
||||||
|
true
|
||||||
|
elif [ "$TARGET" = "jessie" ]; then
|
||||||
|
echo "apt-get install -y -t jessie-backports ca-certificates-java" > build/jessie-pkginst.sh
|
||||||
|
chmod a+rx build/jessie-pkginst.sh
|
||||||
|
sudo -E DIST=$TARGET /usr/sbin/pbuilder execute build/jessie-pkginst.sh
|
||||||
|
fi
|
||||||
|
sudo -E DIST=$TARGET pdebuild --buildresult build/debs
|
||||||
|
24
dist/debian/pbuilderrc
vendored
Normal file
24
dist/debian/pbuilderrc
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
USENETWORK=yes
|
||||||
|
BUILD_HOME=/tmp
|
||||||
|
BASETGZ="/var/cache/pbuilder/$DIST-base.tgz"
|
||||||
|
DISTRIBUTION="$DIST"
|
||||||
|
BUILDRESULT="/var/cache/pbuilder/$DIST/result/"
|
||||||
|
APTCACHE="/var/cache/pbuilder/$DIST/aptcache/"
|
||||||
|
ALLOWUNTRUSTED=yes
|
||||||
|
|
||||||
|
if [ "$DIST" = "trusty" ] || [ "$DIST" = "xenial" ]; then
|
||||||
|
MIRRORSITE="http://archive.ubuntu.com/ubuntu/"
|
||||||
|
COMPONENTS="main restricted universe multiverse"
|
||||||
|
DEBOOTSTRAPOPTS="--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg"
|
||||||
|
if [ "$DIST" = "trusty" ]; then
|
||||||
|
OTHERMIRROR="deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu trusty main"
|
||||||
|
fi
|
||||||
|
elif [ "$DIST" = "jessie" ]; then
|
||||||
|
MIRRORSITE="http://ftp.us.debian.org/debian/"
|
||||||
|
COMPONENTS="main contrib non-free"
|
||||||
|
DEBOOTSTRAPOPTS="--keyring=/usr/share/keyrings/debian-archive-keyring.gpg"
|
||||||
|
OTHERMIRROR="deb http://httpredir.debian.org/debian jessie-backports main"
|
||||||
|
else
|
||||||
|
echo "Unknown distribution: $DIST"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user