#!/bin/sh
tc=$(grep CPE_NAME /etc/os-release 2>/dev/null | sed "s#CPE_NAME=##g;s#\"##g;s#cpe:/o:tinycore:tinycore_linux:##g;s#\..*#.x#g;"); test ${tc//.*} -ge 12 || exit;
arch=x86; test "$(uname -m 2>/dev/null)" == "x86_64" && arch=x86_64;
current=$(date +%Y/%m/%d);
version=0.7.3;
tce-load -wi cmake compiletc squashfs-tools submitqc fuse-dev ruby-dev mbedtls-dev;
wget -O /tmp/dislocker-$version.tar.gz https://github.com/Aorimn/dislocker/archive/refs/tags/v$version.tar.gz;
sudo rm -rf /tmp/dislocker-$version; tar -C /tmp -xzf /tmp/dislocker-$version.tar.gz;
cd /tmp/dislocker-$version;
export CFLAGS=; export CXXFLAGS=; export LDFLAGS=;
cmake .;
mkdir build;
make DESTDIR=build install;
mkdir build/usr/local/tce.installed;
cat<<EOF>build/usr/local/tce.installed/dislocker;
#!/bin/sh
test -f /usr/local/lib/libruby.so.2.5 || sudo ln -s /usr/local/lib/libruby.so /usr/local/lib/libruby.so.2.5;
EOF
chmod 755 build/usr/local/tce.installed/dislocker;
for i in bin lib; do ( cd build/usr/local/$i && { for o in --strip-all --strip-unneeded --strip-debug -g; do sudo strip $o *; done; }; ); done;
mkdir summary;
mksquashfs build summary/dislocker.tcz;
cd summary;
for i in dislocker*.tcz; do md5sum $i > $i.md5.txt; unsquashfs -l $i > $i.list; done;
{ for i in fuse ruby ntfs-3g mbedtls-lib; do echo $i.tcz; done } > dislocker.tcz.dep;
cat<<EOF>dislocker.tcz.info;
Title:          dislocker.tcz
Description:    read/write encrypted BitLocker volumes
Version:        $version
Author:         see list of sites below
Original-site:  see list of sites below
Copying-policy: see list of sites below
Size:           $(du -h dislocker.tcz | cut -f 1)
Extension_by:   hurzli
Tags:           encrypt decrypt
Comments:       Dislocker has been designed to read BitLocker encrypted
                partitions under a Linux system. The FUSE driver is able
                to read/write partitions which were encrypted running
                Windows Vista up to 10 or BitLocker-To-Go.
                ----
                This extension contains:
                dislocker-$version - GPLv2 - https://github.com/Aorimn/dislocker/archive/refs/tags/v$version.tar.gz
                ----
                Compiled running TC $tc $arch
Change-log:     ----
Current:        $current First version, $version
EOF
