minor correction

rsyslog-pkg-ubuntu has trusty, rsyslog-pkg-debian has the debian codenames

David Lang

On Fri, 24 Apr 2015, David Lang wrote:

Date: Fri, 24 Apr 2015 16:45:01 -0700 (PDT)
From: David Lang <[email protected]>
Reply-To: [email protected]
To: Santiago Bassett <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: [ossec-list] Re: building .deb packages

so I installed the git-buildpackage package.

I cloned the current git tree, created a scratch branch, made the changes represented in the agent.patch file above, then ran the command

gbp buildpackage --git-debian-branch=build-agent --git-ignore-new -us -uc --git-upstream-tree=2.8.1 --git-dist=trusty

and it created a package (I think I needed to do a couple things to silence blocking errors, but it should be obvious). I did a similar thing on a different branch for the server version of the debian directory

there is some way to have one debian/ directory and have it create multiple packages. the rsyslog stuff does this in https://github.com/rsyslog/rsyslog-pkg-debian (look in liblognorm/trusty for a simple version that does a couple packages, the rsyslog directory does about a dozen packages)

I haven't looked in detail at this, and what I've done so far is very much hack and slash programming to get a result, not doing it cleanly. but now that it works I can go back and start looking at how to do it cleanly :-)

I don't know how much I will get done over the weekend, but I figured I'd send it to you since you are more familiar with this stuff

docs for the gbp command:
http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/man.gbp.buildpackage.html

other git workflow pages
https://wiki.debian.org/PackagingWithGit
https://wiki.debian.org/GitPackagingWorkflow
http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.intro.html

David Lang

On Fri, 24 Apr 2015, Santiago Bassett wrote:

Date: Fri, 24 Apr 2015 11:12:42 -0700
From: Santiago Bassett <[email protected]>
To: David Lang <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: building .deb packages

Hi David,

I few weeks ago I actually started working on a new version of the deb
packages, fixing multiple issues including:

- init scripts not being installed when packages are reinstalled or upgraded
- use addgroup and adduser in postscripts to avoid gid and uid conflicts
with other users.
- modify ossec configuration file to monitor debian/ubuntu files like
auth.log instead of authlog
- errors when frontend is set to noninteractive

Unfortunately I haven't had time to finish it yet, since I've been pretty
busy at work, but I plan to finish them sometime in the next few days. I
also created the packages for ubuntu that can be found at
http://ossec.wazuh.com/ubuntu/

I am now using an Ubuntu server to create all packages with pbuilder. I've
never packaged directly from a git repository, didn't even know it was
possible. Will definitely have a look into that.

Please don't hesitate to ask for help if you have questions. I'll be
sharing new deb files as soon as I have the new package version ready too.

Best

On Thu, Apr 23, 2015 at 6:46 PM, David Lang <[email protected]> wrote:

I'm trying to build packages for ubuntu using the instructions and scripts
from Santiago https://github.com/santiago-bassett/ossec-debian

After doing a few obvious tweaks to try and make them work for ubuntu
codenames instead of debian codenames, I tried to run generate_ossec.sh and
it complained because the ossec-hids directory is a git repository, not
something that containst a source tarball.

Has anyone put together scripts to create the packages from a git
repository?

I'm pretty new to using the debian infrastructure to create packages. I've
been building local packages for years using checkinstall and/or creating
them manually (ar/cpio/etc). I just finished going through and getting a
similar setup done for rsyslog, so I've got a vauge idea of what's going on
:-)

David Lang

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..9d6b1c8
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,13 @@
+ossec-hids-agent (2.8.1-2) stable; urgency=low
+
+  * Fixed Makefile to use ossec-hids-debian.init instead of ossec-hids.init (fixes LSB headers warning).
+  * Fixed CVE-2014-5284. Patch included.
+  * Included debconf and templates for initial package configuration (server_ip).
+
+ -- Santiago Bassett <[email protected]>  Sat, 20 Sep 2014 14:52:03 +0000
+
+ossec-hids-agent (2.8-1) stable; urgency=low
+
+  * Initial release.
+
+ -- Santiago Bassett <[email protected]>  Mon, 24 Mar 2014 23:54:31 +0000
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..5cfd349
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: ossec-hids-agent
+Section: admin 
+Priority: extra
+Maintainer: Santiago Bassett <[email protected]>
+Build-Depends: debhelper (>= 7.0.50~), libssl-dev
+Standards-Version: 3.8.4
+Homepage: http://www.ossec.net
+
+Package: ossec-hids-agent
+Architecture: any
+Depends: ${shlibs:Depends}, libc6 (>= 2.7), libssl1.0.0, expect
+Conflicts: ossec-hids
+Description: OSSEC Agent - Host Based Intrusion Detection System
+ OSSEC HIDS for log analysis, integrity checking, rootkits detection and
+ active response. This package includes the server and the agent.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..1aaf9af
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,34 @@
+This work was packaged for Debian by:
+
+    Santiago Bassett <[email protected]> on Fri, 29 Nov 2013 03:11:44 +0000
+
+It was downloaded from:
+
+    http://www.ossec.net 
+
+Upstream Authors:
+
+    [email protected]
+    [email protected]
+    [email protected]
+    [email protected]
+    [email protected]
+    [email protected]
+    [email protected]
+    [email protected]
+    [email protected]    
+
+Copyright:
+
+    GNU General Public License version 2.    
+
+License:
+
+    GNU General Public License version 2.
+
+The Debian packaging is:
+
+    Copyright (C) 2014 Santiago Bassett <[email protected]>
+
+and is licensed under the GPL version 2,
+see "/usr/share/common-licenses/GPL-2".
diff --git a/debian/ossec-hids-agent.lintian-overrides b/debian/ossec-hids-agent.lintian-overrides
new file mode 100644
index 0000000..ac8e421
--- /dev/null
+++ b/debian/ossec-hids-agent.lintian-overrides
@@ -0,0 +1,11 @@
+ossec-hids-agent: embedded-library
+ossec-hids-agent: embedded-zlib
+ossec-hids-agent: possible-gpl-code-linked-with-openssl
+ossec-hids-agent: new-package-should-close-itp-bug
+ossec-hids-agent: init.d-script-missing-lsb-section
+ossec-hids-agent: init.d-script-does-not-implement-required-option
+ossec-hids-agent: possibly-insecure-handling-of-tmp-files-in-maintainer-script
+ossec-hids-agent: non-standard-dir-in-var
+ossec-hids-agent: file-in-unusual-dir
+ossec-hids-agent: hardening-no-fortify-functions
+ossec-hids-agent: hardening-no-relro
diff --git a/debian/patches/01_makefile.patch b/debian/patches/01_makefile.patch
new file mode 100644
index 0000000..5422e8e
--- /dev/null
+++ b/debian/patches/01_makefile.patch
@@ -0,0 +1,65 @@
+Description: Added Makefile
+Author: Santiago Bassett <[email protected]>
+
+---
+--- /dev/null
++++ ossec-hids-agent-2.8/Makefile
+@@ -0,0 +1,58 @@
++#
++# Santiago Bassett <[email protected]>
++# 03/25/2014
++#
++
++DESTDIR=/
++DIR=$(DESTDIR)/var/ossec/
++DIR_ETC=$(DESTDIR)/etc/
++DIR_INIT=$(DESTDIR)/etc/init.d/
++OSSEC_INIT=$(DESTDIR)/etc/ossec-init.conf
++CEXTRA="-DCLIENT"
++all:
++	echo "CEXTRA=$(CEXTRA)" >> src/Config.OS
++	(cd src; make all)	
++
++clean:
++	rm bin/* || /bin/true
++	chmod 750 $(DIR) || /bin/true
++	chmod 750 $(DIR)/* || /bin/true
++	(cd src; make clean)
++	rm -f src/Config.OS
++	rm -f src/analysisd/compiled_rules/compiled_rules.h
++	rm -f src/isbigendian.c
++	rm -f src/analysisd/ossec-makelists
++	rm -f src/analysisd/ossec-logtest
++	rm -f src/isbigendian
++
++install:
++	mkdir -p $(DIR_ETC)
++	mkdir -p $(DIR_INIT)
++	cp -p src/init/ossec-hids-debian.init $(DIR_INIT)/ossec
++	mkdir -p $(DIR)
++	(cd $(DIR); mkdir -p logs bin queue queue/ossec queue/alerts queue/syscheck queue/diff queue/rids) 
++	(cd $(DIR); mkdir -p var var/run etc etc/shared active-response active-response/bin agentless .ssh)
++	cp -pr src/rootcheck/db/*.txt $(DIR)/etc/shared/
++	chmod -x $(DIR)/etc/shared/*.txt
++	cp -pr etc/internal_options.conf $(DIR)/etc/
++	chmod -x $(DIR)/etc/internal_options.conf
++	cp -pr etc/local_internal_options.conf $(DIR)/etc/ > /dev/null 2>&1 || /bin/true
++	cp -pr etc/client.keys $(DIR)/etc/ > /dev/null 2>&1 ||/bin/true
++	cp -pr src/agentlessd/scripts/* $(DIR)/agentless/
++	cp -pr src/client-agent/ossec-agentd ${DIR}/bin/
++	cp -pr src/os_auth/agent-auth ${DIR}/bin/
++	cp -pr src/logcollector/ossec-logcollector ${DIR}/bin/
++	cp -pr src/syscheckd/ossec-syscheckd ${DIR}/bin/
++	cp -pr src/os_execd/ossec-execd ${DIR}/bin/
++	cp -pr src/init/ossec-client.sh ${DIR}/bin/ossec-control
++	cp -pr src/addagent/manage_agents ${DIR}/bin/
++	cp -pr contrib/util.sh ${DIR}/bin/
++	sh src/init/fw-check.sh execute > /dev/null
++	cp -pr active-response/*.sh ${DIR}/active-response/bin/
++	cp -pr active-response/firewalls/*.sh ${DIR}/active-response/bin/
++	cp -pr etc/ossec-agent.conf $(DIR)/etc/ossec.conf
++	chmod -x $(DIR)/etc/ossec.conf
++	echo "DIRECTORY=\"/var/ossec\"" > $(OSSEC_INIT)
++	echo "VERSION=\"v2.8\"" >> $(OSSEC_INIT)
++	echo "DATE=\"`date`\"" >> $(OSSEC_INIT)
++	echo "TYPE=\"agent\"" >> $(OSSEC_INIT)
diff --git a/debian/patches/02_CVE-2014-5284.patch b/debian/patches/02_CVE-2014-5284.patch
new file mode 100644
index 0000000..20b297b
--- /dev/null
+++ b/debian/patches/02_CVE-2014-5284.patch
@@ -0,0 +1,30 @@
+Description: Patched active-response/host-deny.sh to fix CVE-2014-5284
+Author: Santiago Bassett <[email protected]>
+
+---
+--- ossec-hids-2.8.orig/active-response/host-deny.sh
++++ ossec-hids-2.8/active-response/host-deny.sh
+@@ -111,13 +111,18 @@ if [ "x${ACTION}" = "xadd" ]; then
+ # Deleting from hosts.deny   
+ elif [ "x${ACTION}" = "xdelete" ]; then   
+    lock;
++   TMP_FILE = `mktemp /tmp/ossec-hosts.XXXXXXXXXX` 
++   if [ "X${TMP_FILE}" = "X" ]; then 
++     # Cheap fake tmpfile, but should be harder then no random data 
++     TMP_FILE = "/tmp/ossec-hosts.`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -1 `"
++   fi
+    if [ "X$UNAME" = "XFreeBSD" ]; then
+-    cat /etc/hosts.allow | grep -v "ALL : ${IP} : deny$"> /tmp/hosts.deny.$$
+-    mv /tmp/hosts.deny.$$ /etc/hosts.allow
++    cat /etc/hosts.allow | grep -v "ALL : ${IP} : deny$"> ${TMP_FILE}
++    mv ${TMP_FILE} /etc/hosts.allow
+    else
+-    cat /etc/hosts.deny | grep -v "ALL:${IP}$"> /tmp/hosts.deny.$$
+-    cat /tmp/hosts.deny.$$ > /etc/hosts.deny
+-    rm /tmp/hosts.deny.$$
++    cat /etc/hosts.deny | grep -v "ALL:${IP}$"> ${TMP_FILE}
++    cat ${TMP_FILE} > /etc/hosts.deny
++    rm ${TMP_FILE}
+    fi 
+    unlock;
+    exit 0;
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..0461fc5
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+01_makefile.patch
+agent-build-files
diff --git a/debian/postinst b/debian/postinst
new file mode 100755
index 0000000..8fd8eb3
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,136 @@
+#!/bin/sh
+# postinst script for ossec-hids
+# Santiago Bassett <[email protected]>
+# 03/25/2014
+
+set -e
+
+case "$1" in
+    configure)
+
+	DIR="/var/ossec/"
+	USER="ossec"
+	GROUP="ossec"
+	OSSEC_HIDS_TMP_DIR="/tmp/ossec-hids"
+
+	OSMYSHELL="/sbin/nologin"
+        if [ ! -f ${OSMYSHELL} ]; then 
+	    if [ -f "/bin/false" ]; then
+	        OSMYSHELL="/bin/false"
+	    fi
+	fi
+
+        if ! getent group | grep -q "^ossec"
+        then
+            groupadd --system ossec
+        fi
+        if ! getent passwd | grep -q "^ossec"
+        then
+            useradd -d ${DIR} -s ${OSMYSHELL} -g ${GROUP} ${USER}
+        fi
+
+	# Default for all directories
+	chmod -R 550 ${DIR}
+	chown -R root:${GROUP} ${DIR}
+
+	# To the ossec queue (default for agentd to read)
+	chown -R ${USER}:${GROUP} ${DIR}/queue/ossec
+	chmod -R 770 ${DIR}/queue/ossec
+
+	# For the logging user
+	chown -R ${USER}:${GROUP} ${DIR}/logs
+	chmod -R 750 ${DIR}/logs
+	chmod -R 775 ${DIR}/queue/rids
+	touch ${DIR}/logs/ossec.log
+	chown ${USER}:${GROUP} ${DIR}/logs/ossec.log
+	chmod 664 ${DIR}/logs/ossec.log
+
+        chown -R ${USER}:${GROUP} ${DIR}/queue/diff
+        chmod -R 750 ${DIR}/queue/diff
+        chmod 740 ${DIR}/queue/diff/* > /dev/null 2>&1 || true
+
+	# For the etc dir
+	chmod 550 ${DIR}/etc
+	chown -R root:${GROUP} ${DIR}/etc
+	if [ -f /etc/localtime ]; then
+	    cp -pL /etc/localtime ${DIR}/etc/;
+	    chmod 555 ${DIR}/etc/localtime
+	    chown root:${GROUP} ${DIR}/etc/localtime
+	fi
+
+	if [ -f /etc/TIMEZONE ]; then
+	    cp -p /etc/TIMEZONE ${DIR}/etc/;
+	    chmod 555 ${DIR}/etc/TIMEZONE
+	fi
+
+	# More files
+	chown root:${GROUP} ${DIR}/etc/internal_options.conf
+	chown root:${GROUP} ${DIR}/etc/local_internal_options.conf >/dev/null 2>&1 || true
+	chown root:${GROUP} ${DIR}/etc/client.keys >/dev/null 2>&1 || true
+	chown root:${GROUP} ${DIR}/agentless/*
+	chown ${USER}:${GROUP} ${DIR}/.ssh
+	chown root:${GROUP} ${DIR}/etc/shared/*
+
+	chmod 550 ${DIR}/etc
+	chmod 440 ${DIR}/etc/internal_options.conf
+	chmod 440 ${DIR}/etc/local_internal_options.conf >/dev/null 2>&1 || true
+	chmod 440 ${DIR}/etc/client.keys >/dev/null 2>&1 || true
+	chmod 550 ${DIR}/agentless/*
+	chmod 700 ${DIR}/.ssh
+	chmod 770 ${DIR}/etc/shared
+	chmod 440 ${DIR}/etc/shared/*
+
+	# For the /var/run
+	chmod 770 ${DIR}/var/run
+	chown root:${GROUP} ${DIR}/var/run
+
+	# For util.sh 
+	chown root:${GROUP} ${DIR}/bin/util.sh
+	chmod +x ${DIR}/bin/util.sh
+
+	# For binaries and active response
+        chmod 755 ${DIR}/active-response/bin/*
+        chown root:${GROUP} ${DIR}/active-response/bin/*
+        chown root:${GROUP} ${DIR}/bin/*
+        chmod 550 ${DIR}/bin/*
+
+	# For ossec.conf
+        chown root:${GROUP} ${DIR}/etc/ossec.conf
+        chmod 440 ${DIR}/etc/ossec.conf
+
+	# Debconf
+	. /usr/share/debconf/confmodule
+	db_input high ossec-hids-agent/server-ip || true
+	db_go || true
+
+	db_get ossec-hids-agent/server-ip
+	SERVER_IP=$RET
+
+	sed -i "s/<server-ip>[^<]\+<\/server-ip>/<server-ip>${SERVER_IP}<\/server-ip>/" ${DIR}/etc/ossec.conf
+	db_stop
+
+	# Service
+	if [ -x /etc/init.d/ossec ]; then
+	    update-rc.d -f ossec defaults
+	fi
+
+	if [ -d ${OSSEC_HIDS_TMP_DIR} ]; then
+	    rm -r ${OSSEC_HIDS_TMP_DIR}
+	fi
+    
+    ;;
+
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >22
+        exit 1
+    ;;
+
+esac
+
+exit 0
diff --git a/debian/postrm b/debian/postrm
new file mode 100755
index 0000000..95bb969
--- /dev/null
+++ b/debian/postrm
@@ -0,0 +1,33 @@
+#!/bin/sh
+# postrm script for ossec-hids
+# Santiago Bassett <[email protected]>
+# 03/25/2014
+
+
+set -e
+
+case "$1" in
+    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+	if getent passwd | grep -q "^ossec"
+	then
+		deluser ossec
+	fi
+	if getent group | grep -q "^ossec"
+	then
+		delgroup ossec
+	fi
+	rm -f /etc/init.d/ossec
+	rm -f /etc/ossec-init.conf
+	update-rc.d -f ossec remove
+
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+
+    ;;
+
+esac
+
+exit 0
diff --git a/debian/preinst b/debian/preinst
new file mode 100755
index 0000000..d355f28
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,36 @@
+#!/bin/sh
+# preinst script for ossec-hids
+# Santiago Bassett <[email protected]>
+# 03/25/2014
+
+set -e
+
+# configuration variables
+OSSEC_HIDS_TMP_DIR="/tmp/ossec-hids"
+
+# environment configuration
+if [ ! -d ${OSSEC_HIDS_TMP_DIR} ]; then
+  mkdir ${OSSEC_HIDS_TMP_DIR}
+fi
+
+case "$1" in
+    install|upgrade)
+        # back up the current user rules
+        if [ -f /var/ossec/rules/local_rules.xml ]; then
+            cp /var/ossec/rules/local_rules.xml ${OSSEC_HIDS_TMP_DIR}/local_rules.xml
+        fi
+    ;;
+
+    abort-upgrade)
+
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+
+    ;;
+
+esac
+
+exit 0
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..7e26af8
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,29 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+#
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+#
+# Modified to make a template file for a multi-binary package with separated
+# build-arch and build-indep targets  by Bill Allombert 2001
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This has to be exported to make some magic below work.
+export DH_OPTIONS
+
+
+%:
+	dh $@ 
+
+override_dh_auto_configure:
+
+override_dh_auto_build:
+	$(MAKE) all
+
+override_dh_auto_clean:
+	$(MAKE) clean
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/templates b/debian/templates
new file mode 100644
index 0000000..3eb9934
--- /dev/null
+++ b/debian/templates
@@ -0,0 +1,4 @@
+Template: ossec-hids-agent/server-ip
+Type: string
+Default: 127.0.0.1
+Description: OSSEC server IP address for this agent. This server is also known as Manager and will receive information from the agent. You need to specify the IP address, the hostname is not valid. The agent still needs to be registered and started manually.
diff --git a/src/external/lua-5.2.3/src/ossec-lua b/src/external/lua-5.2.3/src/ossec-lua
new file mode 100755
index 0000000..e986e98
Binary files /dev/null and b/src/external/lua-5.2.3/src/ossec-lua differ
diff --git a/src/external/lua-5.2.3/src/ossec-luac b/src/external/lua-5.2.3/src/ossec-luac
new file mode 100755
index 0000000..5399f70
Binary files /dev/null and b/src/external/lua-5.2.3/src/ossec-luac differ
diff --git a/src/external/zlib-1.2.8/Makefile b/src/external/zlib-1.2.8/Makefile
index 6bba86c..0cc575a 100644
--- a/src/external/zlib-1.2.8/Makefile
+++ b/src/external/zlib-1.2.8/Makefile
@@ -1,5 +1,288 @@
-all:
-	-@echo "Please use ./configure first.  Thank you."
+# Makefile for zlib
+# Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
+# For conditions of distribution and use, see copyright notice in zlib.h
 
-distclean:
-	make -f Makefile.in distclean
+# To compile and test, type:
+#    ./configure; make test
+# Normally configure builds both a static and a shared library.
+# If you want to build just a static library, use: ./configure --static
+
+# To use the asm code, type:
+#    cp contrib/asm?86/match.S ./match.S
+#    make LOC=-DASMV OBJA=match.o
+
+# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
+#    make install
+# To install in $HOME instead of /usr/local, use:
+#    make install prefix=$HOME
+
+CC=gcc
+
+CFLAGS=-O3  -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
+#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
+#CFLAGS=-g -DDEBUG
+#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
+#           -Wstrict-prototypes -Wmissing-prototypes
+
+SFLAGS=-O3  -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
+LDFLAGS= 
+TEST_LDFLAGS=-L. libz.a
+LDSHARED=gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
+CPP=gcc -E
+
+STATICLIB=libz.a
+SHAREDLIB=libz.so
+SHAREDLIBV=libz.so.1.2.8
+SHAREDLIBM=libz.so.1
+LIBS=$(STATICLIB) $(SHAREDLIBV)
+
+AR=ar
+ARFLAGS=rc
+RANLIB=ranlib
+LDCONFIG=ldconfig
+LDSHAREDLIBC=-lc
+TAR=tar
+SHELL=/bin/sh
+EXE=
+
+prefix =/usr/local
+exec_prefix =${prefix}
+libdir =${exec_prefix}/lib
+sharedlibdir =${libdir}
+includedir =${prefix}/include
+mandir =${prefix}/share/man
+man3dir = ${mandir}/man3
+pkgconfigdir = ${libdir}/pkgconfig
+
+OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
+OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
+OBJC = $(OBJZ) $(OBJG)
+
+PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
+PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
+PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
+
+# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
+OBJA =
+PIC_OBJA =
+
+OBJS = $(OBJC) $(OBJA)
+
+PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
+
+all: static shared all64
+
+static: example$(EXE) minigzip$(EXE)
+
+shared: examplesh$(EXE) minigzipsh$(EXE)
+
+all64: example64$(EXE) minigzip64$(EXE)
+
+check: test
+
+test: all teststatic testshared test64
+
+teststatic: static
+	@TMPST=tmpst_$$; \
+	if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \
+	  echo '		*** zlib test OK ***'; \
+	else \
+	  echo '		*** zlib test FAILED ***'; false; \
+	fi; \
+	rm -f $$TMPST
+
+testshared: shared
+	@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
+	LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
+	DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
+	SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
+	TMPSH=tmpsh_$$; \
+	if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \
+	  echo '		*** zlib shared test OK ***'; \
+	else \
+	  echo '		*** zlib shared test FAILED ***'; false; \
+	fi; \
+	rm -f $$TMPSH
+
+test64: all64
+	@TMP64=tmp64_$$; \
+	if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \
+	  echo '		*** zlib 64-bit test OK ***'; \
+	else \
+	  echo '		*** zlib 64-bit test FAILED ***'; false; \
+	fi; \
+	rm -f $$TMP64
+
+infcover.o: test/infcover.c zlib.h zconf.h
+	$(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c
+
+infcover: infcover.o libz.a
+	$(CC) $(CFLAGS) -o $@ infcover.o libz.a
+
+cover: infcover
+	rm -f *.gcda
+	./infcover
+	gcov inf*.c
+
+libz.a: $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
+
+match.o: match.S
+	$(CPP) match.S > _match.s
+	$(CC) -c _match.s
+	mv _match.o match.o
+	rm -f _match.s
+
+match.lo: match.S
+	$(CPP) match.S > _match.s
+	$(CC) -c -fPIC _match.s
+	mv _match.o match.lo
+	rm -f _match.s
+
+example.o: test/example.c zlib.h zconf.h
+	$(CC) $(CFLAGS) -I. -c -o $@ test/example.c
+
+minigzip.o: test/minigzip.c zlib.h zconf.h
+	$(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
+
+example64.o: test/example.c zlib.h zconf.h
+	$(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
+
+minigzip64.o: test/minigzip.c zlib.h zconf.h
+	$(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
+
+.SUFFIXES: .lo
+
+.c.lo:
+	-@mkdir objs 2>/dev/null || test -d objs
+	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
+	-@mv objs/$*.o $@
+
+placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
+	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
+	rm -f $(SHAREDLIB) $(SHAREDLIBM)
+	ln -s $@ $(SHAREDLIB)
+	ln -s $@ $(SHAREDLIBM)
+	-@rmdir objs
+
+example$(EXE): example.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
+
+minigzip$(EXE): minigzip.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
+
+examplesh$(EXE): example.o $(SHAREDLIBV)
+	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
+
+minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
+	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
+
+example64$(EXE): example64.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
+
+minigzip64$(EXE): minigzip64.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
+
+install-libs: $(LIBS)
+	-@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
+	-@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
+	-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
+	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
+	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
+	cp $(STATICLIB) $(DESTDIR)$(libdir)
+	chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
+	-@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
+	-@if test -n "$(SHAREDLIBV)"; then \
+	  cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
+	  echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
+	  chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
+	  echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
+	  rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
+	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
+	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
+	  ($(LDCONFIG) || true)  >/dev/null 2>&1; \
+	fi
+	cp zlib.3 $(DESTDIR)$(man3dir)
+	chmod 644 $(DESTDIR)$(man3dir)/zlib.3
+	cp zlib.pc $(DESTDIR)$(pkgconfigdir)
+	chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
+# The ranlib in install is needed on NeXTSTEP which checks file times
+# ldconfig is for Linux
+
+install: install-libs
+	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
+	cp zlib.h zconf.h $(DESTDIR)$(includedir)
+	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
+
+uninstall:
+	cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
+	cd $(DESTDIR)$(libdir) && rm -f libz.a; \
+	if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
+	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
+	fi
+	cd $(DESTDIR)$(man3dir) && rm -f zlib.3
+	cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
+
+docs: zlib.3.pdf
+
+zlib.3.pdf: zlib.3
+	groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
+
+zconf.h.cmakein: zconf.h.in
+	-@ TEMPFILE=zconfh_$$; \
+	echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
+	sed -f $$TEMPFILE zconf.h.in > zconf.h.cmakein &&\
+	touch -r zconf.h.in zconf.h.cmakein &&\
+	rm $$TEMPFILE
+
+zconf: zconf.h.in
+	cp -p zconf.h.in zconf.h
+
+mostlyclean: clean
+clean:
+	rm -f *.o *.lo *~ \
+	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
+	   example64$(EXE) minigzip64$(EXE) \
+	   infcover \
+	   libz.* foo.gz so_locations \
+	   _match.s maketree contrib/infback9/*.o
+	rm -rf objs
+	rm -f *.gcda *.gcno *.gcov
+	rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
+
+maintainer-clean: distclean
+distclean: clean zconf zconf.h.cmakein docs
+	rm -f Makefile zlib.pc configure.log
+	-@rm -f .DS_Store
+	-@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
+	-@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
+	-@touch -r Makefile.in Makefile
+
+tags:
+	etags *.[ch]
+
+depend:
+	makedepend -- $(CFLAGS) -- *.[ch]
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+adler32.o zutil.o: zutil.h zlib.h zconf.h
+gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
+compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
+crc32.o: zutil.h zlib.h zconf.h crc32.h
+deflate.o: deflate.h zutil.h zlib.h zconf.h
+infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
+inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
+inftrees.o: zutil.h zlib.h zconf.h inftrees.h
+trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
+
+adler32.lo zutil.lo: zutil.h zlib.h zconf.h
+gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
+compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
+crc32.lo: zutil.h zlib.h zconf.h crc32.h
+deflate.lo: deflate.h zutil.h zlib.h zconf.h
+infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
+inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
+inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
+trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h
diff --git a/src/external/zlib-1.2.8/configure.log b/src/external/zlib-1.2.8/configure.log
new file mode 100644
index 0000000..97ce391
--- /dev/null
+++ b/src/external/zlib-1.2.8/configure.log
@@ -0,0 +1,155 @@
+--------------------
+./configure
+Fri Apr 24 22:25:01 UTC 2015
+Checking for gcc...
+=== ztest6751.c ===
+extern int getchar();
+int hello() {return getchar();}
+===
+gcc -c ztest6751.c
+... using gcc
+
+Checking for obsessive-compulsive compiler options...
+=== ztest6751.c ===
+int foo() { return 0; }
+===
+gcc -c -O3 ztest6751.c
+
+Checking for shared library support...
+=== ztest6751.c ===
+extern int getchar();
+int hello() {return getchar();}
+===
+gcc -w -c -O3 -fPIC ztest6751.c
+gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -o ztest6751.so ztest6751.o
+Building shared library libz.so.1.2.8 with gcc.
+
+=== ztest6751.c ===
+#include <sys/types.h>
+off64_t dummy = 0;
+===
+gcc -c -O3 -D_LARGEFILE64_SOURCE=1 ztest6751.c
+Checking for off64_t... Yes.
+Checking for fseeko... Yes.
+
+=== ztest6751.c ===
+#include <string.h>
+#include <errno.h>
+int main() { return strlen(strerror(errno)); }
+===
+gcc -O3 -D_LARGEFILE64_SOURCE=1 -o ztest6751 ztest6751.c
+Checking for strerror... Yes.
+
+=== ztest6751.c ===
+#include <unistd.h>
+int main() { return 0; }
+===
+gcc -c -O3 -D_LARGEFILE64_SOURCE=1 ztest6751.c
+Checking for unistd.h... Yes.
+
+=== ztest6751.c ===
+#include <stdarg.h>
+int main() { return 0; }
+===
+gcc -c -O3 -D_LARGEFILE64_SOURCE=1 ztest6751.c
+Checking for stdarg.h... Yes.
+
+=== ztest6751.c ===
+#include <stdio.h>
+#include <stdarg.h>
+#include "zconf.h"
+int main()
+{
+#ifndef STDC
+  choke me
+#endif
+  return 0;
+}
+===
+gcc -c -O3 -D_LARGEFILE64_SOURCE=1 ztest6751.c
+Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
+
+=== ztest6751.c ===
+#include <stdio.h>
+#include <stdarg.h>
+int mytest(const char *fmt, ...)
+{
+  char buf[20];
+  va_list ap;
+  va_start(ap, fmt);
+  vsnprintf(buf, sizeof(buf), fmt, ap);
+  va_end(ap);
+  return 0;
+}
+int main()
+{
+  return (mytest("Hello%d\n", 1));
+}
+===
+gcc -O3 -D_LARGEFILE64_SOURCE=1 -o ztest6751 ztest6751.c
+Checking for vsnprintf() in stdio.h... Yes.
+
+=== ztest6751.c ===
+#include <stdio.h>
+#include <stdarg.h>
+int mytest(const char *fmt, ...)
+{
+  int n;
+  char buf[20];
+  va_list ap;
+  va_start(ap, fmt);
+  n = vsnprintf(buf, sizeof(buf), fmt, ap);
+  va_end(ap);
+  return n;
+}
+int main()
+{
+  return (mytest("Hello%d\n", 1));
+}
+===
+gcc -c -O3 -D_LARGEFILE64_SOURCE=1 ztest6751.c
+Checking for return value of vsnprintf()... Yes.
+
+=== ztest6751.c ===
+#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+int ZLIB_INTERNAL foo;
+int main()
+{
+  return 0;
+}
+===
+gcc -c -O3 -D_LARGEFILE64_SOURCE=1 ztest6751.c
+Checking for attribute(visibility) support... Yes.
+
+ALL = static shared all64
+AR = ar
+ARFLAGS = rc
+CC = gcc
+CFLAGS = -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
+CPP = gcc -E
+EXE =
+LDCONFIG = ldconfig
+LDFLAGS =
+LDSHARED = gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
+LDSHAREDLIBC = -lc
+OBJC = $(OBJZ) $(OBJG)
+PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
+RANLIB = ranlib
+SFLAGS = -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
+SHAREDLIB = libz.so
+SHAREDLIBM = libz.so.1
+SHAREDLIBV = libz.so.1.2.8
+STATICLIB = libz.a
+TEST = all teststatic testshared test64
+VER = 1.2.8
+Z_U4 =
+exec_prefix = ${prefix}
+includedir = ${prefix}/include
+libdir = ${exec_prefix}/lib
+mandir = ${prefix}/share/man
+prefix = /usr/local
+sharedlibdir = ${libdir}
+uname = Linux
+--------------------
+
+
diff --git a/src/external/zlib-1.2.8/zconf.h b/src/external/zlib-1.2.8/zconf.h
index 9987a77..996fff2 100644
--- a/src/external/zlib-1.2.8/zconf.h
+++ b/src/external/zlib-1.2.8/zconf.h
@@ -408,11 +408,11 @@ typedef uLong FAR uLongf;
    typedef unsigned long z_crc_t;
 #endif
 
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#if 1    /* was set to #if 1 by ./configure */
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
+#if 1    /* was set to #if 1 by ./configure */
 #  define Z_HAVE_STDARG_H
 #endif
 
diff --git a/src/external/zlib-1.2.8/zlib.pc b/src/external/zlib-1.2.8/zlib.pc
new file mode 100644
index 0000000..6954fcf
--- /dev/null
+++ b/src/external/zlib-1.2.8/zlib.pc
@@ -0,0 +1,13 @@
+prefix=/usr/local
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+sharedlibdir=${libdir}
+includedir=${prefix}/include
+
+Name: zlib
+Description: zlib compression library
+Version: 1.2.8
+
+Requires:
+Libs: -L${libdir} -L${sharedlibdir} -lz
+Cflags: -I${includedir}

Reply via email to