mkdeb.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # This script is only supposed to be called by dpkg-deb.
  3. # Its arguments are: <sourcefile> <partsize> <prefix> <totalsize>
  4. # Stdin is also redirected from the source archive by dpkg-split.
  5. # Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. #
  7. # This is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as
  9. # published by the Free Software Foundation; either version 2,
  10. # or (at your option) any later version.
  11. #
  12. # This is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public
  18. # License along with dpkg; if not, write to the Free Software
  19. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. set -e
  21. if [ "$#" != 4 ]; then echo >&2 'Bad invocation of mksplit.sh.'; exit 1; fi
  22. sourcefile="$1"
  23. partsize="$2"
  24. prefix="$3"
  25. orgsize="$4"
  26. myversion=2.0
  27. binary=i386-linux
  28. #csum=`md5sum <"$sourcefile"`
  29. #package="`dpkg-deb --field \"$sourcefile\" Package`"
  30. #version="`dpkg-deb --field \"$sourcefile\" Version`"
  31. #revision="`dpkg-deb --field \"$sourcefile\" Package_Revision`"
  32. startat=0
  33. partnum=0
  34. mkdir /tmp/ds$$
  35. ec=1
  36. trap "rm -r /tmp/ds$$; exit $ec" 0
  37. dsp=/tmp/ds$$/debian-binary
  38. echo -n "Splitting package $package into $nparts parts: "
  39. while [ $startat -lt $orgsize ]
  40. do
  41. showpartnum=$[$partnum+1]
  42. echo $myversion >$dsp
  43. echo $binary >>$dsp
  44. tar -C DEBIAN -cf /tmp/ds$$/control .
  45. tar --
  46. dd bs=$partsize skip=$partnum count=1 \
  47. of=/tmp/ds$$/data.$showpartnum \
  48. 2>&1 | (egrep -v '.* records (in|out)' || true)
  49. rm -f /tmp/ds$$/part
  50. echo -n "$showpartnum "
  51. (cd /tmp/ds$$ &&
  52. ar qc part debian-split data.$showpartnum)
  53. mv /tmp/ds$$/part $prefix.${showpartnum}of$nparts.deb
  54. startat=$[$startat+$partsize]
  55. partnum=$showpartnum
  56. done
  57. echo "done"
  58. ec=0