Commit c8ea3135 authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount

Stub repository for building RPM and DEB packages

parent 3cb1da80
# zimbra-package-stub
Stub files for package builds
# package-stub
This repository is a stub for package builds, holding the basic
Makefile definitions and platform information script necessary
for building packages in the Zimbra packages repository and
other external repositories using these tools.
#!/bin/bash
#
# ***** BEGIN LICENSE BLOCK *****
# Zimbra Collaboration Suite Server
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Zimbra, Inc.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software Foundation,
# version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <http://www.gnu.org/licenses/>.
# ***** END LICENSE BLOCK *****
#
if [ -f /etc/redhat-release ]; then
i=`uname -i`
if [[ "x$i" == "xx86_64" ]] || [[ "x$i" == "xppc64"* ]]; then
i="_64"
else
i=""
fi
grep "Red Hat Enterprise Linux.*release 7" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHEL7${i}"
exit 0
fi
grep "Red Hat Enterprise Linux.*release 6" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHEL6${i}"
exit 0
fi
grep "CentOS Linux release 7" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHEL7${i}"
exit 0
fi
grep "CentOS release 6" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHEL6${i}"
exit 0
fi
grep "Scientific Linux release 7" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHEL7${i}"
exit 0
fi
grep "Scientific Linux release 6" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHEL6${i}"
exit 0
fi
grep "Fedora release 23" /etc/redhat-release >/dev/null 2>&1
if [ $? = 0 ]; then
echo "F23${i}"
exit 0
fi
grep "Fedora release 22" /etc/redhat-release >/dev/null 2>&1
if [ $? = 0 ]; then
echo "F22${i}"
exit 0
fi
grep "Red Hat Enterprise Linux.*release" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "RHELUNKNOWN${i}"
exit 0
fi
grep "CentOS release" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "CentOSUNKNOWN${i}"
exit 0
fi
grep "Fedora Core release" /etc/redhat-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "FCUNKNOWN${i}"
exit 0
fi
fi
if [ -f /etc/SuSE-release ]; then
i=`uname -i`
if [[ "x$i" == "xx86_64" ]] || [[ "x$i" == "xppc64"* ]]; then
i="_64"
else
i=""
fi
grep "SUSE Linux Enterprise Server 11" /etc/SuSE-release >/dev/null 2>&1
if [ $? = 0 ]; then
echo "SLES11${i}"
exit 0
fi
grep "SUSE Linux Enterprise Server 10" /etc/SuSE-release >/dev/null 2>&1
if [ $? = 0 ]; then
echo "SLES10${i}"
exit 0
fi
grep "SUSE Linux Enterprise Server" /etc/SuSE-release >/dev/null 2>&1
if [ $? = 0 ]; then
echo "SLESUNKNOWN${i}"
exit 0
fi
grep "openSUSE" /etc/SuSE-release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "openSUSEUNKNOWN${i}"
exit 0
fi
fi
if [ -f /etc/lsb-release ]; then
LSB="lsb_release"
i=`dpkg --print-architecture`
if [ "x$i" = "xamd64" ]; then
i="_64"
else
i=""
fi
RELEASE=$($LSB -s -c)
DISTRIBUTOR=$($LSB -s -i)
if [ "$DISTRIBUTOR" = "Ubuntu" ]; then
echo -n "UBUNTU"
if [ "$RELEASE" = "precise" ]; then
echo "12${i}"
exit 0
fi
if [ "$RELEASE" = "trusty" ]; then
echo "14${i}"
exit 0
fi
if [ "$RELEASE" = "xenial" ]; then
echo "16${i}"
exit 0
fi
echo "UNKNOWN${i}"
exit 0
fi
if [ "$DISTRIBUTOR" = "Debian" ]; then
echo -n "DEBIAN"
if [ "$RELEASE" = "wheezy" ]; then
echo "7${i}"
exit 0
fi
if [ "$RELEASE" = "jessie" ]; then
echo "8${i}"
exit 0
fi
if [ "$RELEASE" = "stretch" ]; then
echo "9${i}"
exit 0
fi
echo "UNKNOWN${i}"
exit 0
fi
if [ "$DISTRIBUTOR" = "Univention" ]; then
echo -n "UCS"
if [ "$RELEASE" = "Vahr" ]; then
echo "4${i}"
exit 0
fi
echo "UNKNOWN${i}"
exit 0
fi
fi
if [ -f /etc/debian_version ]; then
echo "DEBIANUNKNOWN${i}"
exit 0
fi
if [ -f /etc/mandriva-release ]; then
echo "MANDRIVAUNKNOWN"
exit 0
fi
if [ -f /etc/release ]; then
egrep 'Solaris 10.*X86' /etc/release > /dev/null 2>&1
if [ $? = 0 ]; then
echo "SOLARISX86"
exit 0
fi
echo "SOLARISUNKNOWN"
fi
a=`uname -a | awk '{print $1}'`
p=`uname -p`
if [ "x$a" = "xDarwin" ]; then
v=`sw_vers | grep ^ProductVersion | awk '{print $NF}' | awk -F. '{print $1"."$2}'`
if [ "x$v" = "x10.4" ]; then
if [ "x$p" = "xi386" ]; then
echo "MACOSXx86"
exit 0
fi
if [ "x$p" = "xpowerpc" ]; then
echo "MACOSX"
exit 0
fi
else
if [ "x$p" = "xi386" ]; then
p=x86
fi
echo "MACOSX${p}_${v}"
exit 0
fi
fi
echo "UNKNOWN${i}"
exit 1
include $(DEF_ROOT)/package-rpm.def
PKG_APPEND.RHEL7_64 = .el7
PKG_APPEND.RHEL6_64 = .el6
include $(DEF_ROOT)/package-deb.def
PKG_APPEND.UBUNTU16_64 := .16.04
PKG_APPEND.UBUNTU14_64 := .14.04
PKG_APPEND.UBUNTU12_64 := .12.04
PKG_EXT := deb
PKG_BUILD := dpkg-buildpackage -irpm
PKG_EXTRACT := sudo apt-get --assume-yes --verbose-versions install
PKG_PURGE := sudo apt-get --assume-yes --purge purge
PKG_DEV := dev
PKG_LIB := lib
PKG_EXT := rpm
PKG_BUILD := rpmbuild -v --define "_topdir $$PWD" -ba
PKG_EXTRACT := sudo yum -y install
PKG_PURGE := sudo yum erase -y
PKG_DEV := devel
PKG_LIB := libs
### ~from ThirdParty/Makefile:
# - include via ThirdParty/${package}/Makefile
SHELL := /bin/bash
DEF_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
STUB_ROOT := $(DEF_ROOT)/..
BUILD_PLATFORM ?= $(shell sh $(STUB_ROOT)/bin/get_plat_tag.sh)
ifeq ($(BUILD_PLATFORM), )
BUILD_PLATFORM := "UNKNOWN"
endif
CFLAGS := -g -O2
MAKE ?= make
MAKEARGS := -j3
CD := cd
CHMOD := chmod
CP := cp
MKDIR := mkdir -p
MV := mv
PERL := perl
RM := rm
SED := sed
TAR := tar
WGET := wget -q
ZIMBRA_HOME ?= /opt/zimbra
OZC ?= $(ZIMBRA_HOME)/common
OZCB ?= $(OZC)/bin
OZCE ?= $(OZC)/etc
OZCI ?= $(OZC)/include
OZCL ?= $(OZC)/lib
OZCLE ?= $(OZC)/libexec
OZCS ?= $(OZC)/share
###
MAJOR := $(shell cat $(STUB_ROOT)/version/MAJOR)
MINOR := $(shell cat $(STUB_ROOT)/version/MINOR)
MICRO := $(shell cat $(STUB_ROOT)/version/MICRO)
PKG_REVNUM = 1
PKG_REVISION = zimbra$(MAJOR).$(MINOR)b$(PKG_REVNUM)
PKG_ITERATION = 1$(PKG_REVISION)
# Platform specific:
# - PKG_BUILD
# - PKG_EXT
# - PKG_EXTRACT
# - PKG_PURGE
# - PKG_DEV
# - PKG_LIB
# - PKG_APPEND
BUILD_DISTRIBUTION := $(shell $(SED) -e 's/[0-9]*_[0-9]*$$//' <<< $(BUILD_PLATFORM))
ifneq ($(wildcard $(DEF_ROOT)/package-$(BUILD_DISTRIBUTION).def), )
include $(DEF_ROOT)/package-$(BUILD_DISTRIBUTION).def
else
include $(error unsupported BUILD_PLATFORM $(BUILD_PLATFORM))
endif
PKG_APPEND ?= $(PKG_APPEND.$(BUILD_PLATFORM))
# Platform specific package overrides
ifneq ($(wildcard $(DEF_ROOT)/$(BUILD_DISTRIBUTION).def), )
include $(DEF_ROOT)/$(BUILD_DISTRIBUTION).def
endif
ifneq ($(wildcard $(DEF_ROOT)/$(BUILD_PLATFORM).def), )
include $(DEF_ROOT)/$(BUILD_PLATFORM).def
endif
define generic-setup
$(MKDIR) $(PLATFORM_DIR)
$(CP) -prf zimbra-* $(PLATFORM_DIR)
endef
define generic-clean
$(RM) -rf $(PLATFORM_DIR)
endef
# $pkg.spec OR $pkg/debian/{changelog,*.shlibs}
define replace-pkginfo
$(PERL) -pi -e 's|VERSION|$(pvers)|; s|ITERATION|$(PKG_ITERATION)|; s|ZAPPEND|$(PKG_APPEND)|'
endef
# $pkg.spec OR $pkg/debian/rules
define replace-pathinfo
$(PERL) -pi -e 's|OZCLE|$(OZCLE)|g; s|OZCB|$(OZCB)|g; s|OZCE|$(OZCE)|g; s|OZCI|$(OZCI)|g; s|OZCL|$(OZCL)|g; s|OZCS|$(OZCS)|g; s|OZC|$(OZC)|g;'
endef
# $pkg.spec only
define replace-dictinfo
$(PERL) -pi -e 's/ADICT/$(dictver)/g;'
endef
# $pkg.spec OR $pkg/debian/{changelog, control, copyright, watch}
define replace-perl-modinfo
$(PERL) -pi -e 's/MODNAME/$(pname)/g; s/MODNORMNAME/$(pname_lc)/g;'
endef
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment