#!/bin/sh
# test we are root
if [ "$(id -u)" != "0" ]; then
   echo "run as root now exitting"
   exit 1
fi

# no flags first script as no deps

P=cpanm
USER=`cat /etc/sysconfig/tcuser`
LIST="squashfs-tools wget"
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://cpanmin.us/ -O /tmp/cpanm-exe"  $USER
mkdir -p $P/usr/local/bin
cp $P-exe $P/usr/local/bin/$P
chmod 755 $P/usr/local/bin/$P

# TCZ them
###########
LIST2="$P "
for Z in $LIST2
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
        sed 's|usr|/usr|g' -i /tmp/$Z.tcz.list
	cd /tmp
        zsyncmake $Z.tcz
done

ls -hal

echo 'Title:          cpanm.tcz
Description:    script to get, unpack, build and install modules from CPAN 
Version:        20201010
Author:         Tatsuhiko Miyagawa 
Original-site:  https://cpanmin.us/
Copying-policy: open source
Size:           112K
Extension_by:   aus9
Tags:           perl
Comments:       help=https://metacpan.org/pod/cpanm 
                main use to install a module
                $ sudo cpanm module-name
                To check what modules you have installed,  I run
                $ instmodsh
                (at prompt input l )

                If you have to package something, please check 
                the build log under /root/.cpanm
                as it shows what was installed and where

Change-log:     2020/10/11 Original on 12x
Current:        2020/10/11   ' > $P.tcz.info


# retest deps  wget total 2.21Mb curl 2.28M
echo 'perl5.tcz
make.tcz
wget.tcz' > $P.tcz.dep

# test $ sudo cpanm ExtUtils::Depends

