#!/bin/sh
#
# $Id: file_get_files,v 1.7 2005/02/10 17:01:36 jg Exp $
#
#
# Project     :  SCPM (System Configuration Profile Management)
# Module      :  SCPM utilities
# File        :  file_get_files
# Description :  Generates file names from input pattern
# Author      :  Joachim Gleissner <jg@suse.de>
#
# Copyright 2002-2004 SuSE Linux AG
#           2005 SUSE LINUX Products GmbH
#
# Released under the terms of the GNU General Public License
# (see file COPYRIGHT in project root directory).
#

test -z "$1" && { echo "you have to give an input pattern" >&2; exit 1; }

. /etc/scpm.conf || exit 1

LANG=C
test -n "$2" && ROOT="${2}"

# catch special cases
test "$1" = "/etc/sysconfig/network" && \
    exec $LIBDIR/resource_types/file/get_files/sysconfig_network "$2"
test "$1" = "/etc/sysconfig/isdn" && \
    exec $LIBDIR/resource_types/file/get_files/sysconfig_isdn "$2"
test "$1" = "/etc/cups" && \
    exec $LIBDIR/resource_types/file/get_files/cups "$2"

echo $1
test -d $ROOT$1 && FLIST="$( cd $ROOT$1 ; echo * )"

for i in $FLIST ; do
    test $i = ${i%*.scpmbackup-*} -a ! -d ${ROOT}$1/$i && echo ${1}/$i
    test -d ${ROOT}${1}/${i} -a ! -L ${ROOT}${1}/${i} && $0 ${1}/${i} "$2"
done | grep -v '*' | grep -v '?' | sort

exit 0
