1255365Sdes#!/bin/sh 2255365Sdes#- 3255365Sdes# Copyright (c) 2013 Dag-Erling Sm��rgrav 4255365Sdes# All rights reserved. 5255365Sdes# 6255365Sdes# Redistribution and use in source and binary forms, with or without 7255365Sdes# modification, are permitted provided that the following conditions 8255365Sdes# are met: 9255365Sdes# 1. Redistributions of source code must retain the above copyright 10255365Sdes# notice, this list of conditions and the following disclaimer. 11255365Sdes# 2. Redistributions in binary form must reproduce the above copyright 12255365Sdes# notice, this list of conditions and the following disclaimer in the 13255365Sdes# documentation and/or other materials provided with the distribution. 14255365Sdes# 3. The name of the author may not be used to endorse or promote 15255365Sdes# products derived from this software without specific prior written 16255365Sdes# permission. 17255365Sdes# 18255365Sdes# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19255365Sdes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20255365Sdes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21255365Sdes# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22255365Sdes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23255365Sdes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24255365Sdes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25255365Sdes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26255365Sdes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27255365Sdes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28255365Sdes# SUCH DAMAGE. 29255365Sdes# 30255365Sdes# $Id: mkpkgng.in 740 2013-09-07 13:03:20Z des $ 31255365Sdes# 32255365Sdes 33255365Sdes# Print an informational message 34255365Sdesinfo() { 35255365Sdes echo "mkpkgng: $@" 36255365Sdes} 37255365Sdes 38255365Sdes# Print an error message and exit 39255365Sdeserror() { 40255365Sdes echo "mkpkgng: $@" 1>&2 41255365Sdes exit 1 42255365Sdes} 43255365Sdes 44255365Sdes# Ask a yes / no question 45255365Sdesyesno() { 46255365Sdes while :; do 47255365Sdes echo -n "mkpkgng: $@ (yes/no) " 48255365Sdes read answer 49255365Sdes case $answer in 50255365Sdes [Yy]|[Yy][Ee][Ss]) 51255365Sdes return 0 52255365Sdes ;; 53255365Sdes [Nn]|[Nn][Oo]) 54255365Sdes return 1 55255365Sdes ;; 56255365Sdes esac 57255365Sdes done 58255365Sdes} 59255365Sdes 60255365Sdes# 61255365Sdes# Locate source and build directory 62255365Sdes# 63255365Sdessrcdir="@abs_top_srcdir@" 64255365Sdes[ -f "$srcdir/include/security/openpam.h" ] || \ 65255365Sdes error "Unable to locate source directory." 66255365Sdesbuilddir="@abs_top_builddir@" 67255365Sdescd "$srcdir" 68255365Sdes 69255365Sdes# 70255365Sdes# Determine pkgng version and ABI 71255365Sdes# 72255365Sdespkgver=$(pkg -vv | awk '$1 == "Version:" { print $2 }') 73255365Sdes[ -n "$pkgver" ] || error "Unable to determine pkgng version." 74255365Sdespkgabi=$(pkg -vv | awk '$1 == "ABI:" { print $2 }') 75255365Sdes[ -n "$pkgabi" ] || error "Unable to determine package ABI." 76255365Sdes 77255365Sdes# 78255365Sdes# Determine package name and version 79255365Sdes# 80255365Sdespackage="@PACKAGE@" 81255365Sdesversion="@PACKAGE_VERSION@" 82255365Sdesif ! expr "$version" : "[0-9]{1,}$" >/dev/null ; then 83255365Sdes svnversion="$(svnversion 2>&1)" 84255365Sdes svnversion=$(expr "$svnversion" : '\([0-9][0-9]*\)[A-Z]\{0,1\}$') 85255365Sdes if [ -n "$svnversion" ] ; then 86255365Sdes version="$version-r${svnversion}" 87255365Sdes fi 88255365Sdesfi 89255365Sdes 90255365Sdes# 91255365Sdes# Locate GNU make 92255365Sdes# 93255365Sdesif which gmake >/dev/null ; then 94255365Sdes make=gmake 95255365Sdeselse 96255365Sdes make=make 97255365Sdesfi 98255365Sdesmake="$make --no-print-directory --quiet V=0" 99255365Sdes 100255365Sdes# 101255365Sdes# Create temporary directory 102255365Sdes# 103255365Sdesinfo "Creating the temporary directory." 104255365Sdestmproot=$(mktemp -d "${TMPDIR:-/tmp}/$package-$version.XXXXXX") 105255365Sdes[ -n "$tmproot" -a -d "$tmproot" ] || \ 106255365Sdes error "Unable to create the temporary directory." 107255365Sdestrap "exit 1" INT 108255365Sdestrap "info Deleting the temporary directory. ; rm -rf '$tmproot'" EXIT 109255365Sdesset -e 110255365Sdes 111255365Sdes# 112255365Sdes# Install into tmproot 113255365Sdes# 114255365Sdesinfo "Installing into the temporary directory." 115255365Sdes$make install DESTDIR="$tmproot" 116255365Sdes 117255365Sdes# 118255365Sdes# Generate stub manifest 119255365Sdes# 120255365Sdesinfo "Generating the stub manifest." 121255365Sdesmanifest="$tmproot/+MANIFEST" 122255365Sdescat >"$manifest" <<EOF 123255365Sdesname: $package 124255365Sdesversion: $version 125255365Sdesorigin: local/$package 126255365Sdescomment: BSD-licensed PAM implementation 127255365Sdesarch: $pkgabi 128255365Sdeswww: @PACKAGE_URL@ 129255365Sdesmaintainer: @PACKAGE_BUGREPORT@ 130255365Sdesprefix: @prefix@ 131255365Sdesdesc: 132255365Sdes OpenPAM is an open source PAM library that focuses on simplicity, 133255365Sdes correctness, and cleanliness. 134255365Sdes 135255365Sdes OpenPAM aims to gather the best features of Solaris PAM, XSSO and 136255365Sdes Linux-PAM, plus some innovations of its own. In areas where these 137255365Sdes implementations disagree, OpenPAM tries to remain compatible with 138255365Sdes Solaris, at the expense of XSSO conformance and Linux-PAM 139255365Sdes compatibility. 140255365Sdescategories: local, security 141255365SdesEOF 142255365Sdes 143255365Sdes# 144255365Sdes# Generate file list 145255365Sdes# 146255365Sdesinfo "Generating the file list." 147255365Sdes( 148255365Sdes echo "files:" 149255365Sdes find -s "$tmproot" -type f | while read file ; do 150255365Sdes [ "$file" = "$manifest" ] && continue 151255365Sdes mode=$(stat -f%p "$file" | cut -c 3-) 152255365Sdes file="${file#$tmproot}" 153255365Sdes echo " $file: { uname: root, gname: wheel, perm: $mode }" 154255365Sdes done 155255365Sdes)>>"$manifest" 156255365Sdes 157255365Sdes# 158255365Sdes# Create the package 159255365Sdes# 160255365Sdesinfo "Creating the package." 161255365Sdespkg create -r "$tmproot" -m "$tmproot" -o "$builddir" 162255365Sdes 163255365Sdes# 164255365Sdes# Done 165255365Sdes# 166255365Sdesinfo "Package created for $package-$version." 167