This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
MahiroOS-jhalfs/extras/filelist

59 lines
1.2 KiB
Text
Raw Normal View History

2006-04-09 20:14:49 +02:00
#!/bin/bash
2006-04-09 20:07:03 +02:00
#$Id$
2006-04-09 10:49:42 +02:00
2006-04-09 20:07:03 +02:00
# Acknowledgment:
# The following code is a modified version of an original work written by
# Ken Moffat for the "DIY Linux" project and is included here with his
# permission.
#
2006-04-09 10:49:42 +02:00
2006-04-09 20:07:03 +02:00
set -e
2006-04-09 10:49:42 +02:00
2006-04-09 20:07:03 +02:00
: <<inline_doc
desc: creates farce file lists
usage: filelist $DEST_FARCE/$ITERATION $DEST_FARCE/$ITERATION.filelist
input vars: $1 directory where files from current iteration are stored
$2 name of the file list to be created
externals: --
modifies: --
returns: --
on error:
on success:
inline_doc
2006-04-09 10:49:42 +02:00
if [ $# -eq 2 ]; then
2006-04-09 20:07:03 +02:00
OUTFILE=$2
if [ -e $2 ]; then
echo -e "\nOutput $2 already exists\n"
exit
fi
2006-04-09 10:49:42 +02:00
else
2006-04-09 20:07:03 +02:00
echo -e "\nMissing argument\n"
exit 2
2006-04-09 10:49:42 +02:00
fi
if [ "$1" == "/" ]; then
2006-04-09 20:07:03 +02:00
LOC=$1
2006-04-09 10:49:42 +02:00
else
2006-04-09 20:07:03 +02:00
# ensure the path or mountpoint ends with a slash
# because of the seds after the 'find'
LOC=`echo $1 | sed 's%[^/]$%&/%'`
2006-04-09 10:49:42 +02:00
fi
2006-04-09 20:07:03 +02:00
echo "Will create file list in $OUTFILE"
2006-04-09 10:49:42 +02:00
if [ -f $OUTFILE ]; then
2006-04-09 20:07:03 +02:00
echo "refusing to overwrite $OUTFILE"
exit 1
2006-04-09 10:49:42 +02:00
fi
# check we can indeed do this
>$OUTFILE
if [ $? -ne 0 ]; then
2006-04-09 20:07:03 +02:00
echo "error, cannot write to $OUTFILE"
exit 1
2006-04-09 10:49:42 +02:00
fi
2006-04-09 20:07:03 +02:00
find $LOC -xdev -xtype f | sed "s%^${LOC}%/%" | sort >$OUTFILE
2006-04-09 10:49:42 +02:00
exit