mkinary 1.3 KB

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