#!/bin/sh
# test we are root
if [ "$USER" != "root" ] ; then
   echo "Run as root please, exiting." 
   exit 1                                                      
fi

export CFLAGS="-mtune=generic -Os -pipe"
export CXX="-mtune=generic -Os -pipe -fno-rtti -fno-exceptions "

P=man-pages
V=6.04
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc xz man-db-dev util-linux "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
URL=https://mirrors.edge.kernel.org/pub/linux/docs/man-pages
su -c "/usr/local/bin/wget -nc --no-check-certificate \
$URL/$SRC.tar.xz " $USER 

xz -d $SRC*xz && tar xvf $SRC.tar
cd $SRC
make -j5 install prefix=/tmp/$P/usr/local # 10 seconds
cd /tmp

# TCZ 
#####
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
done

ls -hal

echo "Title:          man-pages.tcz
Description:    man-pages 
Version:        6.04
Author:         see inside each man page 
Original-site:  https://www.kernel.org/pub/linux/docs/man-pages/
Copying-policy: GPL v3
Size:           3.1M		
Extension_by:   aus9
Tags:           man-pages man
Comments:       man-pages from kernel.org 
                load man-db or  
                your preferred man page viewer

Change-log:     2015/07/15 v 4.0 on 6x (gordon64)
Current:        2023/04/06 v 6.04 on any arch (aus9) " > $P.tcz.info


submitqc --libs

# for TC64
echo 'man-db.tcz' > $P.tcz.dep