source: openpam/trunk/mkpkgng.in

Last change on this file was 787, checked in by des, 4 months ago

Compress man pages before generating the manifest.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1#!/bin/sh
2#-
3# Copyright (c) 2013 Dag-Erling Smørgrav
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
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
16#    permission.
17#
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
28# SUCH DAMAGE.
29#
30# $Id$
31#
32
33# Print an informational message
34info() {
35        echo "mkpkgng: $@"
36}
37
38# Print an error message and exit
39error() {
40        echo "mkpkgng: $@" 1>&2
41        exit 1
42}
43
44# Ask a yes / no question
45yesno() {
46        while :; do
47                echo -n "mkpkgng: $@ (yes/no) "
48                read answer
49                case $answer in
50                [Yy]|[Yy][Ee][Ss])
51                        return 0
52                        ;;
53                [Nn]|[Nn][Oo])
54                        return 1
55                        ;;
56                esac
57        done
58}
59
60#
61# Locate source and build directory
62#
63srcdir="@abs_top_srcdir@"
64[ -f "$srcdir/include/security/openpam.h" ] || \
65    error "Unable to locate source directory."
66builddir="@abs_top_builddir@"
67cd "$srcdir"
68
69#
70# Determine pkgng version and ABI
71#
72pkgver=$(pkg -v)
73[ -n "$pkgver" ] || error "Unable to determine pkgng version."
74pkgabi=$(pkg config abi)
75[ -n "$pkgabi" ] || error "Unable to determine package ABI."
76
77#
78# Determine package name and version
79#
80package="@PACKAGE@"
81version="@PACKAGE_VERSION@"
82if ! 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}"
87        fi
88fi
89
90#
91# Locate GNU make
92#
93if which gmake >/dev/null ; then
94        make=gmake
95else
96        make=make
97fi
98make="$make --no-print-directory --quiet V=0"
99
100#
101# Create temporary directory
102#
103info "Creating the temporary directory."
104tmproot=$(mktemp -d "${TMPDIR:-/tmp}/$package-$version.XXXXXX")
105[ -n "$tmproot" -a -d "$tmproot" ] || \
106    error "Unable to create the temporary directory."
107trap "exit 1" INT
108trap "info Deleting the temporary directory. ; rm -rf '$tmproot'" EXIT
109set -e
110
111#
112# Install into tmproot
113#
114info "Installing into the temporary directory."
115$make install DESTDIR="$tmproot"
116
117#
118# Compress man pages
119#
120find $tmproot -type d -name 'man[0-9]' |
121while read mandir ; do
122        find $mandir -type f -name '*.[0-9]' |
123        while read manpage ; do
124                gzip "$manpage"
125        done
126done
127
128#
129# Generate stub manifest
130#
131info "Generating the stub manifest."
132manifest="$tmproot/+MANIFEST"
133cat >"$manifest" <<EOF
134name: $package
135version: $version
136origin: local/$package
137comment: BSD-licensed PAM implementation
138arch: $pkgabi
139www: @PACKAGE_URL@
140maintainer: @PACKAGE_BUGREPORT@
141prefix: @prefix@
142desc:
143  OpenPAM is an open source PAM library that focuses on simplicity,
144  correctness, and cleanliness.
145 
146  OpenPAM aims to gather the best features of Solaris PAM, XSSO and
147  Linux-PAM, plus some innovations of its own.  In areas where these
148  implementations disagree, OpenPAM tries to remain compatible with
149  Solaris, at the expense of XSSO conformance and Linux-PAM
150  compatibility.
151categories: local, security
152EOF
153
154#
155# Generate file list
156#
157info "Generating the file list."
158(
159        echo "files:"
160        find -s "$tmproot" -type f | while read file ; do
161                [ "$file" = "$manifest" ] && continue
162                mode=$(stat -f%p "$file" | cut -c 3-)
163                file="${file#$tmproot}"
164                echo "  $file: { uname: root, gname: wheel, perm: $mode }"
165        done
166)>>"$manifest"
167
168#
169# Create the package
170#
171info "Creating the package."
172pkg create -r "$tmproot" -m "$tmproot" -o "$builddir"
173
174#
175# Done
176#
177info "Package created for $package-$version."
Note: See TracBrowser for help on using the repository browser.