mkinary 1.33 KB
Newer Older
sulincix's avatar
sulincix committed
1 2 3 4 5 6
#!/bin/bash
pwd=$(pwd)
[ "$1" != "" ] && cd $1
echo "Checking"
if [ -f inary_files/metadata.xml ] && [ -d install ] ; then
	cd install
sulincix's avatar
sulincix committed
7
	echo "Creating install.tar.xz"
sulincix's avatar
sulincix committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
	tar --xz -cf ../inary_files/install.tar.xz ./*
	echo "Creating files.xml"
	echo -e "<Files>" > ../inary_files/files.xml
	find | sed "s|^\./||g" | while read line
	do
	if [ -f $line ] ; then
		echo -e "   <File>" >> ../inary_files/files.xml
	        echo -e "      <Path>$line</Path>" >> ../inary_files/files.xml
        	echo -e "      <Type>data</Type>" >> ../inary_files/files.xml
        	echo -e "      <Size>$(du -b $line | awk '{print $1}')</Size>" >> ../inary_files/files.xml
        	echo -e "      <Uid>0</Uid>" >> ../inary_files/files.xml
        	echo -e "      <Gid>0</Gid>" >> ../inary_files/files.xml
        	echo -e "      <Mode>0o755</Mode>" >> ../inary_files/files.xml
        	echo -e "      <Hash>$(sha1sum $line | awk '{print $1}')</Hash>" >> ../inary_files/files.xml
        	echo -e "   </File>" >> ../inary_files/files.xml
	fi
	done
	echo -e "</Files>" >> ../inary_files/files.xml
	cd ..
	echo "Calculating tar hash"
	cd inary_files
	sed -i "s/InstallTarHash>.*</InstallTarHash>$(sha1sum install.tar.xz | awk '{print $1}')</g" metadata.xml
	echo "Creating inary package"
	zip -q ../output.inary metadata.xml files.xml install.tar.xz

else
	echo "Invalid path"
fi
cd $pwd