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

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

P=id3tool
V=1.2a
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc "
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 \
http://nekohako.xware.cx/$P/$SRC.tar.gz "  $USER
tar xvf $SRC*gz
cd $SRC
./configure  prefix=/usr/local 
make -j5 # seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# doc
#####
mkdir -p $P-doc/usr/local/share
mv $P/usr/local/man $P-doc/usr/local/share/ # wrong pathway fixed

# main
#####
# YIKES
file COPYING 
# -> COPYING: Audio file with ID3 version 2.116.111, extended header, experimental
# use the web for doc

# TCZ them
###########
LIST2="$P $P-doc "
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:          id3tool-doc.tcz
Description:    man page
Version:        1.2a
Author:         Chris Collins
Original-site:  http://nekohako.xware.cx/id3tool/
Copying-policy: https://github.com/yuanshanxiaoni/id3tool/blob/master/COPYING
Size:           4.0K          		
Extension_by:   aus9 @ linuxquestions.org
Tags:           music tag editor mp3 ogg
Comments:       man page
                Source Copying file was corrupt so used above link (mirror)    
            
Change-log:     2024/04/26 v 1.2a on 15x 
Current:        2024/04/26                     ' > $P-doc.tcz.info
echo 'man-db.tcz                               ' > $P-doc.tcz.dep

echo 'Title:          id3tool.tcz
Description:    command line music tag editor
Version:        1.2a
Author:         Chris Collins
Original-site:  http://nekohako.xware.cx/id3tool/
Copying-policy: https://github.com/yuanshanxiaoni/id3tool/blob/master/COPYING
Size:           8.0K          		
Extension_by:   aus9 @ linuxquestions.org
Tags:           music tag editor mp3 ogg
Comments:       $ id3tool filename -> displays current tags
                $ id3tool -h  -> displays usage

                eg $ id3tool sample.ogg
                     Filename: sample.ogg
                     No ID3 Tag
                   $ id3tool -t test2 sample.ogg
                   $ id3tool sample.ogg
                     Filename: sample.ogg
                     Song Title: Test2
                  Source Copying file was corrupt so used above link (mirror)

Change-log:     2024/04/26 v 1.2a on 15x 
Current:        2024/04/26                     ' > $P.tcz.info

readelf -d $P/usr/local/bin/$P | grep 'NEEDED'
#

submitqc --libs
rm -rf *.zsync
