|
|
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: lib/sde-binary/package.sh # Copyright (C) 2007 The OpenSDE Project # # More information can be found in the files COPYING and README. # # 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. A copy of the # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END ---
. lib/libsde.in
pkg_type= pkg_name= versioned= root=
usage() { cat <<EOT Creates a binary package for a given package based on it's flist
Usage: ${0} --type <type> [--versioned] [--root <root>] [--output <output>] <package> type package format (tar.gz,tar.bz2,tar.lzo,gem) root location of the root of the sandbox output folder to place the binary packages package name of the package
--versioned use package version in the resulting file name EOT }
while [ $# -gt 0 ]; do case "$1" in --versioned) versioned=1 ;; --type) pkg_type="$2"; shift ;; --root) root="$2"; shift ;; --output) output="$2"; shift ;; --*) usage; exit 1 ;; *) if [ "$pkg_name" ]; then usage; exit 1 else pkg_name="$1" fi ;; esac shift done
if [ -z "$pkg_name" ]; then usage; exit 1 elif [ ! -r "${root}/var/adm/packages/$pkg_name" ]; then echo_error "package '$pkg_name' not found." exit 2 elif [ "$versioned" ]; then version=$( grep '^Package Name and Version:' "${root}/var/adm/packages/$pkg_name" | cut -f6 -d' ' ) if [ -z "$version" ]; then echo_error "package '$pkg_name' is broken." exit 2 fi else version= fi
output="${output:-.}"
case "$pkg_type" in tar.gz) compressor=gzip ;; tar.bz2) compressor=bzip2 ;; tar.lzo) compressor=lzop ;; *) # external type if [ -x "$SDEROOT/lib/sde-package/package-$pkg_type.sh" ]; then exec $SDEROOT/lib/sde-package/package-$pkg_type.sh ${versioned:+--versioned} --root "${root}" \
--output "${output}" "${pkg_name}" else echo_error "packaging type '$pkg_type' not handled." exit 3 fi esac
echo_info "Creating binary package for '$pkg_name'" mkdir -p "$output"
filename="$pkg_name${versioned:+-${version}}.$pkg_type" flist="$root/var/adm/flists/$pkg_name"
( grep ' var/adm' "$flist" grep -v ' var/adm' "$flist" ) | cut -f2- -d' ' | tar -C "$root" -cf- --no-recursion --files-from=- | $compressor > "$output/$filename.tmp" errno=$?
if [ "$errno" != "0" ]; then echo_error "failed to create '$output/$filename' (errno:$errno)" rm -f "$output/$filename.tmp" exit 4 else mv "$output/$filename"{.tmp,} fi
|