1124057Sobrien#! /bin/sh 2124088Sobrien# ex:ts=8 3124057Sobrien 4124057Sobrien# Copyright (c) 2003 David E. O'Brien 5124057Sobrien# All rights reserved. 6124057Sobrien# 7124057Sobrien# Redistribution and use in source and binary forms, with or without 8124057Sobrien# modification, are permitted provided that the following conditions 9124057Sobrien# are met: 10124057Sobrien# 1. Redistributions of source code must retain the above copyright 11124057Sobrien# notice, this list of conditions and the following disclaimer. 12124057Sobrien# 2. Redistributions in binary form must reproduce the above copyright 13124057Sobrien# notice, this list of conditions and the following disclaimer in the 14124057Sobrien# documentation and/or other materials provided with the distribution. 15124057Sobrien# 16124057Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17124057Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18124057Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19124057Sobrien# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20124057Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21124057Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22124057Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23124057Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24124057Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25124057Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26124057Sobrien# SUCH DAMAGE. 27124057Sobrien# 28124057Sobrien# $FreeBSD$ 29124057Sobrien 30124057Sobrien# Creates an INDEX file suitable for an ISO distribution image from a master 31124057Sobrien# INDEX file. The generated INDEX file contains only the packages in the 32124057Sobrien# supplied directory. 33124057Sobrien 34124057Sobriencase $# in 35124057Sobrien 3) PKG_EXT="tbz" ;; 36124057Sobrien 4) PKG_EXT=$4 ;; 37124057Sobrien *) 38124057Sobrien echo `basename $0` "<master index file> <output index file> <pkg dir> [pkg ext]" 39124057Sobrien exit 1 40124057Sobrien ;; 41124057Sobrienesac 42124057Sobrien 43124057SobrienPKG_LIST=$(basename `ls $3/*.${PKG_EXT}` | sed -e "s/\.${PKG_EXT}$//") 44124088SobrienREGEX=$(echo ${PKG_LIST} | sed \ 45124088Sobrien -e 's/ /|/g' \ 46124088Sobrien -e 's/\./\\\./g' \ 47124088Sobrien -e 's/\+/\\\+/g' \ 48124088Sobrien -e 's/\^/\\\^/g') 49124057Sobrien 50124057Sobrienegrep "^(${REGEX})" $1 > $2 51124057Sobrien 52124057Sobrienif [ $(echo ${PKG_LIST} | wc -w) != $(wc -l < $2) ]; then 53124057Sobrien echo "ERROR: some packages not found in $1" 54124057Sobrien exit 1 55124057Sobrienelse 56124057Sobrien exit 0 57124057Sobrienfi 58