From 2ae819add5d37ba39df7219900671b88ca7ec896 Mon Sep 17 00:00:00 2001 From: Evgeniy Patlan Date: Wed, 1 Feb 2017 23:00:34 +0200 Subject: [PATCH 1/2] Allow to build arch-dependent packages --- config/deb/control | 2 +- config/rpm/percona-toolkit.spec | 2 +- util/build-packages | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config/deb/control b/config/deb/control index 71d0f52d..e5c7b578 100644 --- a/config/deb/control +++ b/config/deb/control @@ -10,7 +10,7 @@ Vcs-Browser: https://github.com/percona/percona-toolkit Vcs-Git: git://github.com/percona/percona-toolkit.git Package: percona-toolkit -Architecture: all +Architecture: @@ARHITECTURE@@ Depends: ${perl:Depends}, libdbi-perl (>= 1.13), libdbd-mysql-perl | libdbd-mysql-5.1-perl, libterm-readkey-perl (>=2.10), libio-socket-ssl-perl Description: Advanced MySQL and system command-line tools diff --git a/config/rpm/percona-toolkit.spec b/config/rpm/percona-toolkit.spec index 11d0b747..5fa61054 100644 --- a/config/rpm/percona-toolkit.spec +++ b/config/rpm/percona-toolkit.spec @@ -8,7 +8,7 @@ Vendor: Percona URL: http://www.percona.com/software/percona-toolkit/ Source: percona-toolkit-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -BuildArch: noarch +BuildArch: @@ARHITECTURE@@ Requires: perl(DBI) >= 1.13, perl(DBD::mysql) >= 1.0, perl(Time::HiRes), perl(IO::Socket::SSL), perl(Digest::MD5), perl(Term::ReadKey) AutoReq: no diff --git a/util/build-packages b/util/build-packages index 8fea7755..2a9d617a 100755 --- a/util/build-packages +++ b/util/build-packages @@ -353,7 +353,7 @@ build_tar() { } build_rpm() { - echo -n "Building $PKG-1.noarch.rpm... " + echo -n "Building $PKG-1.$ARCH.rpm... " cd $RELEASE_DIR if [ ! -f "$PKG.tar.gz" ]; then die "Cannot build RPM because $PKG.tar.gz does not exist" @@ -375,10 +375,10 @@ build_rpm() { warn "rpmbuild has warnings; see $tmpdir/rpmbuild" fi - if [ ! -f "RPMS/noarch/$PKG-1.noarch.rpm" ]; then - die "RPMS/noarch/$PKG-1.noarch.rpm did not build" + if [ ! -f "RPMS/$ARCH/$PKG-1.$ARCH.rpm" ]; then + die "RPMS/$ARCH/$PKG-1.$ARCH.rpm did not build" fi - mv "RPMS/noarch/$PKG-1.noarch.rpm" $RELEASE_DIR/RPM + mv "RPMS/$ARCH/$PKG-1.$ARCH.rpm" $RELEASE_DIR/RPM rm -rf $RELEASE_DIR/rpm echo "OK" @@ -478,6 +478,17 @@ if [ $OS_ARCH != "linux-amd64" ] && [ $OS_ARCH != "linux-386" ] && [ $OS_ARCH != die "Valid OS-ARCH combinations are: linux-amd64, linux-386, darwin-amd64" fi +if [ $OS_ARCH == "linux-amd64" ]; then + ARCH="x86_64" +elif [ $OS_ARCH == "linux-386" ]; then + ARCH="i386" +else + ARCH="noarch" +fi + +sed -i'.bak' -e "s/@@ARHITECTURE@@/$ARCH/" $RPM_CONFIG_DIR/percona-toolkit.spec +sed -i'.bak' -e "s/@@ARHITECTURE@@/$ARCH/" $DEB_CONFIG_DIR/control + if [ ! -f $REL_NOTES ]; then die "$REL_NOTES does not exist" fi From 4ad2ccc423f8a670a3ce6e764ad4198cfbeea35e Mon Sep 17 00:00:00 2001 From: Evgeniy Patlan Date: Fri, 3 Feb 2017 17:45:42 +0200 Subject: [PATCH 2/2] Build packages changes --- config/deb/preinst | 9 +++++++++ config/rpm/percona-toolkit.spec | 10 ++++++++++ util/build-packages | 7 +++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 config/deb/preinst diff --git a/config/deb/preinst b/config/deb/preinst new file mode 100644 index 00000000..8041f791 --- /dev/null +++ b/config/deb/preinst @@ -0,0 +1,9 @@ +#!/bin/sh +INSTALLED=`dpkg-query -l | grep percona-toolkit | awk '{print $3}' | awk -F'.' '{print $1}'` +if [ $INSTALLED != "0" -a "x$INSTALLED" != "x3" ]; then + echo "** It is not possible to install percona-toolkit-3.0.0rc as it will replace already installed package" + echo "** Please note that percona-toolkit-3.0.0 is RC" + echo "** If you want to install it you need to remove already installed package" + exit 1 +fi + diff --git a/config/rpm/percona-toolkit.spec b/config/rpm/percona-toolkit.spec index 5fa61054..a0f6d118 100644 --- a/config/rpm/percona-toolkit.spec +++ b/config/rpm/percona-toolkit.spec @@ -41,6 +41,16 @@ find $RPM_BUILD_ROOT -type d -depth -exec rmdir {} 2>/dev/null ';' find $RPM_BUILD_ROOT -type f -name 'percona-toolkit.pod' -exec rm -f {} ';' chmod -R u+w $RPM_BUILD_ROOT/* +%pre +INSTALLED=`rpm -q percona-toolkit | awk -F'-' '{print $3}' | awk -F'.' '{print $1}'` +if [ $INSTALLED < 3 ]; then + echo "** It is not possible to install percona-toolkit-3.0.0rc as it will replace already installed package" + echo "** Please note that percona-toolkit-3.0.0 is RC" + echo "** If you want to install it you need to remove already installed package" + exit 1 +fi + + %clean rm -rf $RPM_BUILD_ROOT diff --git a/util/build-packages b/util/build-packages index 2a9d617a..56a84a13 100755 --- a/util/build-packages +++ b/util/build-packages @@ -385,7 +385,7 @@ build_rpm() { } build_deb() { - local deb_pkg="percona-toolkit_$VERSION-1_all.deb" + local deb_pkg="percona-toolkit_$VERSION-1_$DEB_ARCH.deb" echo -n "Building $deb_pkg... " cd $RELEASE_DIR @@ -480,14 +480,17 @@ fi if [ $OS_ARCH == "linux-amd64" ]; then ARCH="x86_64" + DEB_ARCH="amd64" elif [ $OS_ARCH == "linux-386" ]; then ARCH="i386" + DEB_ARCH="i386" else ARCH="noarch" + ARCH="all" fi sed -i'.bak' -e "s/@@ARHITECTURE@@/$ARCH/" $RPM_CONFIG_DIR/percona-toolkit.spec -sed -i'.bak' -e "s/@@ARHITECTURE@@/$ARCH/" $DEB_CONFIG_DIR/control +sed -i'.bak' -e "s/@@ARHITECTURE@@/$DEB_ARCH/" $DEB_CONFIG_DIR/control if [ ! -f $REL_NOTES ]; then die "$REL_NOTES does not exist"