#!/bin/sh
#
# Create all the various junk that shouldn't exist upstream.  We do much of it
# here rather than in the template so that Lintian itself can be imported into
# revision control systems.

set -e
dir="$1"


EMPTY_OLE_OBJECT='\320\317\021\340\241\261\032\341'

mkdir "${dir}/CVS"
echo 'source-contains-cvs-control-dir' > "${dir}/CVS/Entries"
mkdir "${dir}/.svn"
echo 'source-contains-svn-control-dir' > "${dir}/.svn/format"
mkdir "${dir}/.bzr"
echo 'source-contains-bzr-control-dir' > "${dir}/.bzr/foo"
mkdir "${dir}/{arch}"
echo 'source-contains-arch-control-dir' > "${dir}/{arch}/foo"
mkdir "${dir}/.git"
echo 'source-contains-git-control-dir' > "${dir}/.git/foo"
mkdir "${dir}/.hg"
echo 'source-contains-hg-control-dir' > "${dir}/.hg/foo"
mkdir "${dir}/.be"
echo 'source-contains-bts-control-dir' > "${dir}/.be/foo"

echo 'source-contains-svn-commit-file' > "${dir}/svn-commit.tmp"
echo 'source-contains-svk-commit-file' > "${dir}/svk-commit444.tmp"
echo 'source-contains-arch-inventory-file' > "${dir}/.arch-inventory"
echo 'source-contains-hg-tags-file' > "${dir}/.hgtags"
echo 'source-contains-cvs-conflict-copy' > "${dir}/.#foo.1.1"
echo 'source-contains-svn-conflict-file' > "${dir}/foo.r1352"

echo 'configure-generated-file-in-source' > "${dir}/config.cache"

printf "MZ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x3c" > "${dir}/fake-win32-bin.exe"
# use old magic \001\000\000\000 part is optional but needed with old file
printf "ITSF\003\000\000\000\140\000\000\000\001\000\000\000" > "${dir}/fake-help-file.chm"
# .chm files with "Halibut" are probably generated by free software
printf "ITSF\003\000\000\000\140\000\000\000\001\000\000\000Halibut," > "${dir}/fake-help-file-halibut.chm"

printf "CWS\011    x" > "${dir}/fakeflash.swf"
echo '//comment' > "${dir}/fake.min.js"
# Make python generate python bytecode files
# - more reliable than crafting them ourselves
echo '' > "${dir}/fake.py"
echo 'import fake' > "${dir}/main.py"
unset PYTHONDONTWRITEBYTECODE
PYTHONPATH="${dir}" python3 "${dir}/main.py" > /dev/null
PYTHONPATH="${dir}" python3 -O "${dir}/main.py"  > /dev/null
rm -f "${dir}"/main.py*

zip -q "${dir}/fake.jar" "${dir}/fake.min.js"
cp "${dir}/fake.jar" "${dir}/fakesilverlight.XAC"

# need to pad
printf "\320\317\021\340\241\261\032\341" > "${dir}/fakefla.fla"
dd if=/dev/zero of="${dir}/fakefla.fla" count=1 bs=1 seek=2047 > /dev/null 2> /dev/null
cp "${dir}/fakefla.fla" "${dir}/fakeflasourced.fla"
printf '//fake .as flash' > "${dir}/fakeflasourced.as"
