3 # Copyright (c) 2013 Dag-Erling Smørgrav
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. The name of the author may not be used to endorse or promote
15 # products derived from this software without specific prior written
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # $Id: mkpkgng.in 816 2014-09-12 07:50:22Z des $
33 # Print an informational message
38 # Print an error message and exit
40 echo "mkpkgng: $@" 1>&2
44 # Ask a yes / no question
47 echo -n "mkpkgng: $@ (yes/no) "
61 # Locate source and build directory
63 srcdir="@abs_top_srcdir@"
64 [ -f "$srcdir/include/security/openpam.h" ] || \
65 error "Unable to locate source directory."
66 builddir="@abs_top_builddir@"
70 # Determine pkgng version and ABI
73 [ -n "$pkgver" ] || error "Unable to determine pkgng version."
74 pkgabi=$(pkg config abi)
75 [ -n "$pkgabi" ] || error "Unable to determine package ABI."
78 # Determine package name and version
81 version="@PACKAGE_VERSION@"
82 if ! expr "$version" : "[0-9]{1,}$" >/dev/null ; then
83 svnversion="$(svnversion 2>&1)"
84 svnversion=$(expr "$svnversion" : '\([0-9][0-9]*\)[A-Z]\{0,1\}$')
85 if [ -n "$svnversion" ] ; then
86 version="$version-r${svnversion}"
93 if which gmake >/dev/null ; then
98 make="$make --no-print-directory --quiet V=0"
101 # Create temporary directory
103 info "Creating the temporary directory."
104 tmproot=$(mktemp -d "${TMPDIR:-/tmp}/$package-$version.XXXXXX")
105 [ -n "$tmproot" -a -d "$tmproot" ] || \
106 error "Unable to create the temporary directory."
108 trap "info Deleting the temporary directory. ; rm -rf '$tmproot'" EXIT
112 # Install into tmproot
114 info "Installing into the temporary directory."
115 $make install DESTDIR="$tmproot"
118 # Generate stub manifest
120 info "Generating the stub manifest."
121 manifest="$tmproot/+MANIFEST"
122 cat >"$manifest" <<EOF
125 origin: local/$package
126 comment: BSD-licensed PAM implementation
129 maintainer: @PACKAGE_BUGREPORT@
132 OpenPAM is an open source PAM library that focuses on simplicity,
133 correctness, and cleanliness.
135 OpenPAM aims to gather the best features of Solaris PAM, XSSO and
136 Linux-PAM, plus some innovations of its own. In areas where these
137 implementations disagree, OpenPAM tries to remain compatible with
138 Solaris, at the expense of XSSO conformance and Linux-PAM
140 categories: local, security
146 info "Generating the file list."
149 find -s "$tmproot" -type f | while read file ; do
150 [ "$file" = "$manifest" ] && continue
151 mode=$(stat -f%p "$file" | cut -c 3-)
152 file="${file#$tmproot}"
153 echo " $file: { uname: root, gname: wheel, perm: $mode }"
160 info "Creating the package."
161 pkg create -r "$tmproot" -m "$tmproot" -o "$builddir"
166 info "Package created for $package-$version."