# build
tce-load -wi compiletc

mkdir /tmp/build
cd /tmp/build
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansBengali-unhinted.zip
unzip NotoSansBengali-unhinted.zip
mkdir -p notosansbengali-fonts-ttf/usr/local/share/fonts/notosansbengali
cp NotoSansBengali-Regular.ttf NotoSansBengaliUI-Regular.ttf notosansbengali-fonts-ttf/usr/local/share/fonts/notosansbengali
mkdir notosansbengali-fonts-ttf/usr/local/tce.installed
cat <<__EOF__ > notosansbengali-fonts-ttf/usr/local/tce.installed/notosansbengali-fonts-ttf
#!/bin/sh
fc-cache /usr/local/share/fonts/notosanbengali
__EOF__

# set permission
chmod 644 notosansbengali-fonts-ttf/usr/local/share/fonts/notosansbengali/*.ttf
chmod 775 notosansbengali-fonts-ttf/usr/local/tce.installed
sudo chown -R root:staff notosansbengali-fonts-ttf
sudo chmod 755 notosansbengali-fonts-ttf/usr/local/tce.installed/notosansbengali-fonts-ttf
sudo chown tc:staff notosansbengali-fonts-ttf/usr/local/tce.installed/notosansbengali-fonts-ttf

# TCZ packaging
tce-load -wi squashfs-tools submitqc
mksquashfs notosansbengali-fonts-ttf notosansbengali-fonts-ttf.tcz
md5sum notosansbengali-fonts-ttf.tcz > notosansbengali-fonts-ttf.tcz.md5.txt
unsquashfs -ll notosansbengali-fonts-ttf.tcz | grep -v ^d | grep ^- | awk '{print $6}' | sed -e 's/^squashfs-root//g' > notosansbengali-fonts-ttf.tcz.list

cat <<__EOF__ > notosansbengali-fonts-ttf.tcz.dep
fontconfig.tcz
__EOF__

cat <<__EOF__ > notosansbengali-fonts-ttf.tcz.info
Title:          notosansbengali-fonts-ttf.tcz
Description:    Stripped Noto Sans Bengali Regular fonts
Version:        see comments
Author:         see comments
Original-site:  https://github.com/googlefonts/noto-fonts
Copying-policy: SIL Open Font License, Version 1.1
Size:           144K
Extension_by:   Yoshihiro Sato
Tags:           Bengali Fonts Sans
Change-log:     First version
Current:        2020-06-19
Comments:       This package is part of the noto project. Visit https://www.google.com/get/noto for more information.
__EOF__

# (optional) prepare build-dep file
vi notosansbengali-fonts-ttf.tcz.build-dep
  (... this file ...)

# copy all to-be-packaged files to the directory
mkdir /tmp/notosansbengali-fonts-ttf
cp /tmp/build/notosansbengali-fonts-ttf.tcz* /tmp/notosansbengali-fonts-ttf/

# (optional) .tgz file is including source and script
#tar zcvpf /tmp/notosansbengali-fonts-ttf/notosansbengali-fonts-ttf.tcz.tgz NotoSansBengali-unhinted.zip

# run submitqc (Tiny Core Extension audit script) before submission
cd /tmp/notosansbengali-fonts-ttf
sudo submitqc
# ... have warnings for copyright / dep-libs, which are not required for this package, so OK

# prep tar.gz archive for submission
cd /tmp
tar cvzf notosansbengali-fonts-ttf.tar.gz notosansbengali-fonts-ttf/

# submit request
# ... attach notosansbengali-fonts-ttf.tar.gz file, and email to tcesubmit@gmail.com

# cleanup
cd /tmp
sudo rm -rf build/ notosansbengali-fonts-ttf/ submitqc/
