#if the pkg created in packages-woof has something wrong, this file is a last
#resort to fix it. Current-dir is where this file FIXUPHACK is located.
#w469 added English.pm, NamedCapture.pm, Errno.pm, needed by 'pnmquant' utility.
#091126 added Hash.pm needed by POSIX.pm (needed by foomatic-rip).
#110621 add CORE/libperl.so to tiny list (needed in mageia 1).

PERL_TINY_FILELIST='CORE/libperl.so IO.pm Data/Dumper.pm File/GlobMapper.pm File/Glob.pm POSIX.pm Fcntl.pm IO/File.pm IO/Pipe.pm IO/Poll.pm IO/Handle.pm IO/Seekable.pm IO/Select.pm IO/Socket.pm IO/Dir.pm Socket.pm DynaLoader.pm Config.pm XSLoader.pm Cwd.pm Socket/Socket.so POSIX/atof.al POSIX/waitpid.al POSIX/setjmp.al POSIX/perror.al SigAction/handler.al SigAction/safe.al SigAction/flags.al SigAction/new.al SigAction/mask.al SigRt/new.al SigRt/_init.al SigRt/CLEAR.al SigRt/_check.al SigRt/_exist.al SigRt/DELETE.al SigRt/SCALAR.al SigRt/STORE.al SigRt/_croak.al SigRt/_getsig.al SigRt/EXISTS.al SigRt/FETCH.al POSIX/scanf.al POSIX/malloc.al POSIX/rewind.al POSIX/strcmp.al POSIX/rename.al POSIX/setvbuf.al POSIX/memset.al POSIX/fgets.al POSIX/getgid.al POSIX/autosplit.ix POSIX/fileno.al POSIX/getpwuid.al POSIX/link.al POSIX/fputc.al POSIX/opendir.al POSIX/strpbrk.al POSIX/sprintf.al POSIX/strcpy.al POSIX/fread.al POSIX/getuid.al POSIX/strncat.al POSIX/gets.al POSIX/cos.al POSIX/ldiv.al POSIX/memcpy.al POSIX/siglongjmp.al POSIX/abs.al POSIX/geteuid.al POSIX/memmove.al POSIX/unlink.al POSIX/putchar.al POSIX/clearerr.al POSIX/execle.al POSIX/fscanf.al POSIX/bsearch.al POSIX/chdir.al POSIX/calloc.al POSIX/getgrgid.al POSIX/vprintf.al POSIX/qsort.al POSIX/rewinddir.al POSIX/puts.al POSIX/creat.al POSIX/atan2.al POSIX/gmtime.al POSIX/fdopen.al POSIX/load_imports.al POSIX/memchr.al POSIX/time.al POSIX/printf.al POSIX/getlogin.al POSIX/getpid.al POSIX/ferror.al POSIX/getc.al POSIX/tmpfile.al POSIX/rand.al POSIX/system.al POSIX/utime.al POSIX/getenv.al POSIX/atexit.al POSIX/execl.al POSIX/longjmp.al POSIX/remove.al POSIX/tolower.al POSIX/strtok.al POSIX/fflush.al POSIX/strrchr.al POSIX/offsetof.al POSIX/vsprintf.al POSIX/alarm.al POSIX/div.al POSIX/errno.al POSIX/labs.al POSIX/raise.al POSIX/redef.al POSIX/fcntl.al POSIX/sin.al POSIX/getgrnam.al POSIX/execlp.al POSIX/putc.al POSIX/sigsetjmp.al POSIX/strspn.al POSIX/ungetc.al POSIX/strncmp.al POSIX/ftell.al POSIX/atoi.al POSIX/sleep.al POSIX/fputs.al POSIX/getppid.al POSIX/execv.al POSIX/assert.al POSIX/realloc.al POSIX/feof.al POSIX/getpwnam.al POSIX/strstr.al POSIX/kill.al POSIX/exit.al POSIX/atol.al POSIX/strcat.al POSIX/fork.al POSIX/fwrite.al POSIX/srand.al POSIX/fseek.al POSIX/readdir.al POSIX/POSIX.so POSIX/fclose.al POSIX/mkdir.al POSIX/pow.al POSIX/umask.al POSIX/log.al POSIX/exp.al POSIX/getgroups.al POSIX/unimpl.al POSIX/fgetpos.al POSIX/fabs.al POSIX/strcspn.al POSIX/fsetpos.al POSIX/sqrt.al POSIX/free.al POSIX/sscanf.al POSIX/localtime.al POSIX/fstat.al POSIX/chown.al POSIX/setbuf.al POSIX/strlen.al POSIX/getpgrp.al POSIX/closedir.al POSIX/strchr.al POSIX/rmdir.al POSIX/strerror.al POSIX/getegid.al POSIX/fgetc.al POSIX/getchar.al POSIX/fsync.al POSIX/fopen.al POSIX/strncpy.al POSIX/isatty.al POSIX/usage.al POSIX/stat.al POSIX/freopen.al POSIX/wait.al POSIX/chmod.al POSIX/toupper.al POSIX/fprintf.al POSIX/execvp.al POSIX/execve.al POSIX/vfprintf.al POSIX/memcmp.al Fcntl/Fcntl.so Dumper/Dumper.so Glob/Glob.so IO/IO.so DynaLoader/autosplit.ix DynaLoader/dl_find_symbol_anywhere.al DynaLoader/dl_findfile.al DynaLoader/dl_expandspec.al Cwd/Cwd.so AutoLoader.pm strict.pm CGI.pm Getopt/Std.pm Getopt/Long.pm getopt.pl Exporter.pm Symbol.pm warnings/register.pm overload.pm File/Basename.pm File/DosGlob.pm File/Path.pm File/Temp.pm File/Fetch.pm File/CheckTree.pm Spec/OS2.pm Spec/Win32.pm Spec/Cygwin.pm Spec/Functions.pm Spec/Mac.pm Spec/VMS.pm Spec/Unix.pm Spec/Epoc.pm File/Copy.pm File/Spec.pm File/Find.pm File/stat.pm File/Compare.pm SelectSaver.pm Carp.pm Exporter/Heavy.pm constant.pm bytes.pm CGI/Cookie.pm CGI/Apache.pm CGI/Push.pm CGI/Pretty.pm CGI/Carp.pm CGI/Switch.pm CGI/Util.pm vars.pm IO/Zlib.pm sigtrap.pm warnings.pm Benchmark.pm Config_heavy.pl English.pm NamedCapture.pm Errno.pm Hash.pm'

#have some difficulty with the different distros having quite different directory layout for their perl pkg...
#so, template allows everything, as-is, then we cut it down...

mkdir -p ../tempdir1
cp -a ./* ../tempdir1/
PERL_ALL_FILELIST="`find ./ -not -type d | sed -e 's%^\./%%'`"
rm -rf ./usr

for ONE_PERL_FILE in $PERL_TINY_FILELIST
do
 opfPATTERN='/'"$ONE_PERL_FILE"'$'
 for ONEFND in `echo "$PERL_ALL_FILELIST" | grep "$ONE_PERL_FILE" | tr '\n' ' '`
 do
  [ ! -f ../tempdir1/$ONEFND ] && continue
  ONEFND_PATH="`dirname $ONEFND`"
  mkdir -p $ONEFND_PATH
  cp -a -f ../tempdir1/$ONEFND $ONEFND_PATH/
 done
done

mkdir -p usr/bin
cp -a ../tempdir1/usr/bin/perl* usr/bin/

#for Perl, just leave 'perl' executable... um, no, make 'perl' a symlink... 120824 fix...
UPKGVERSION="$(find usr/bin -mindepth 1 -maxdepth 1 -type f -executable -name 'perl[0-9]*' | sed -e 's%usr/bin/perl%%' | head -n 1)"
if [ "$UPKGVERSION" != "" ];then
 if [ ! -h usr/bin/perl${UPKGVERSION} ];then
  rm -f usr/bin/perl
  ln -s perl${UPKGVERSION} usr/bin/perl
 fi
fi

#120715 debian squeeze has libperl* in perl_base pkg -- not in libperl pkg!
if [ -d ../tempdir1/usr/lib ];then
 mkdir -p usr/lib
 cp -a -f --remove-destination ../tempdir1/usr/lib/libperl.so* usr/lib/ 2>/dev/null
fi

rm -rf ../tempdir1
