#!/bin/sh -exu
# 2013 Marco B Caminati

read srcid
naive=""; recuwarn=""; b=busybox; mtp=/tmp/mtp

me="Marco B. Caminati (caminati.net.tf)"
name="$1"; [ "$name" ] 
sep="-"
osver="$(version)"
today=`date +%Y/%m/%d`

ver="20120701"
description="TeX-based typesetting/document preparation systems, markup languages and related packages"
tags="typesetting/document preparation systems, markup languages TeX LaTeX LuaTeX pdf dvi text print format"
authors="Donald Knuth, Michael Plass, John Hobby, Leslie Lamport, Sebastian Rahtz, Karl Berry, the TeX Users Group and others"
homepage="http://www.tug.org/texlive/"
license="LPPL and GPL2"
deps=""

rmdir $mtp || true
mkdir $mtp
sudo $b mount "${name}" "${mtp}"
(cd ${mtp} && find -mindepth 1 -not -type d| $b sed -e "s_^\./\(.*$\)_\1_" | sort) > ${name}.list
umount "${mtp}"
rmdir "${mtp}"
md5sum ${name} > ${name}.md5.txt
rm -f ${name}.dep
for each in ${deps}; do echo ${each} >> ${name}.dep; done
size=`du -h ${name} | cut -f 1`

cat <<EOF > ${name}.info
Title:		${name}
Description:	${description}
Version:	${ver}
Author:		${authors}
Original-site:	${homepage}
Copying-policy:	${license}
Size:		${size}
Extension_by:	${me}
Tags:		${tags}
Comments:	Includes collection-basic and collection-latex
		Can be extended via other texlive-*.tcz and texlive-*.scm files in the repo.
		Built under Core version ${osver} from 
		${srcid}
		available on Original-site.
		${naive}
		${recuwarn}
Change-log:     2012/01/18 Packaged i386-linux 20120118 under Core Linux 4.0.1 by Xianwen Chen
Current:	${today} version ${ver}
EOF
