#!/bin/sh # --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: bin/sde-create-pkgdb # Copyright (C) 2008 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 --- #Description: Creates a packagedb file for a build [ -n "$SDEROOT" ] || export SDEROOT=$( cd "${0%/*}/.."; pwd -P ) . "$SDEROOT/lib/libsde.in" . "$SDEROOT/lib/sde-config.in" create_usage() { local progname=${0##*/} echo "Usage: ${progname//-/ } -c " } shortopts='c:' longopts='cfg:' options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" ) if [ $? -ne 0 ]; then create_usage exit -1 fi # load new arguments list eval set -- "$options" config=default while [ $# -gt 0 ]; do case "$1" in -c|--cfg) config=$2; shift ;; --) shift; break ;; esac shift done config_exists "$config" || echo_abort 1 "$config: config not found." builddir="$SDEROOT/build/$(config_id "$config")" admdir="$builddir/var/adm" tarballdir="$builddir/TOOLCHAIN/pkgs" pkgdbfile="$tarballdir/packages.db" pkgfile_ver=$(config_getvar PKGFILE_VER "$config") pkgfile_ext=$(config_getvar PKGFILE_TYPE "$config") # validate $admdir and $tarballdir for x in packages descs dependencies cksums; do [ -d "$admdir/$x" ] || echo_abort 1 "$config: var/adm/ is incomplete." done [ -d "$tarballdir/" ] || echo_abort 1 "$config: no built packages." create_pkgdb_entry() { local admdir="$1" pkg="$2" x= $ECHO_E "$pkg" $ECHO_E "\027" grep -v '^\[COPY\]' "$admdir/descs/$pkg" $ECHO_E "\027" for x in dependencies cksums; do cat "$admdir/$x/$pkg" $ECHO_E "\027" done $ECHO_E "\004" } trap ':' INT for pkg in $( cd "$admdir/descs/"; ls -1 * 2> /dev/null ) ; do [ "$pkg" != "TRANS.TBL" ] || continue if [ "$pkgfile_ver" = 1 ]; then ver=$(grep '^Package Name and Version' \ "$admdir/packages/$pkg" | cut -f6 -d' ') else ver= fi pkgfile="$pkg${ver:+-$ver}.$pkgfile_ext" if [ -s "$tarballdir/$pkgfile" ]; then create_pkgdb_entry "$admdir" "$pkg" else echo_warning "$pkg: binary package not found." fi done | gzip -c > "$pkgdbfile.$$" errno=$? if [ $errno -eq 0 ]; then mv "$pkgdbfile.$$" "$pkgdbfile" else rm -f "$pkgdbfile.$$" exit $errno fi