Debian.zsh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #
  2. # Debian stuff
  3. #
  4. # specific aliases
  5. alias lintian="lintian --color=auto -IEm --pedantic"
  6. # building environements
  7. cow-dist () {
  8. if [ $# -lt 2 ]; then
  9. echo "Error args."
  10. return
  11. fi
  12. DIST=$1
  13. shift
  14. OPTS=
  15. if [ "$1" = "--update" ]; then
  16. OPTS="--no-cowdancer-update"
  17. elif [ "$1" = "--build" -a -z "$2" ]; then
  18. if [ -f debian/changelog ]; then
  19. dsc=$(egrep -v "^([[:space:]]+|$)" debian/changelog| \
  20. sed 's/\([^ ]*\) (\([^)]*\)).*/..\/\1_\2.dsc/'|head -1)
  21. if [ -f "$dsc" ]; then
  22. OPTS="$dsc"
  23. fi
  24. fi
  25. fi
  26. sudo DIST=$DIST cowbuilder $@ $OPTS
  27. return $?
  28. }
  29. alias cow-sid32="cow-dist sid32"
  30. alias cow-stable32="cow-dist stable32"
  31. alias cow-sid64="cow-dist sid64"
  32. alias cow-stable64="cow-dist stable64"
  33. alias cow-stable-bpo="cow-dist stable-bpo"
  34. # tools
  35. apt-rbdepends () {
  36. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  37. }
  38. pdebdiff() {
  39. if [ ! -r debian/changelog ]; then
  40. echo "ERR: can't read debian/changelog"
  41. exit
  42. fi
  43. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  44. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  45. head -n2|tr '\n' $IFS | \
  46. read v1 v2
  47. if [ -z "$v1" -o -z "$v2" ]; then
  48. echo "ERR: can't find version \$n and \$n-1 of the package";
  49. exit
  50. fi
  51. if [ ! -r debian/control ]; then
  52. echo "ERR: can't read debian/control"
  53. exit
  54. fi
  55. egrep '^(Package|Architecture): ' debian/control | \
  56. while read line ; do
  57. pkg=$(echo $line|sed 's/Package: //')
  58. read line
  59. arch=$(echo $line|sed 's/Architecture: //')
  60. if [ $arch = 'any' ]; then
  61. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  62. fi
  63. (
  64. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  65. echo
  66. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  67. )|$PAGER
  68. done
  69. }
  70. pdeblint() {
  71. if [ ! -r debian/changelog ]; then
  72. echo "ERR: can't read debian/changelog"
  73. exit
  74. fi
  75. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  76. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  77. head -n1)
  78. if [ ! -r debian/control ]; then
  79. echo "ERR: can't read debian/control"
  80. exit
  81. fi
  82. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  83. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  84. changes="../${pkg}_${v}_${arch}.changes"
  85. if [ ! -r "$changes" ]; then
  86. echo "ERR: can't read changes file : ${changes}"
  87. exit
  88. fi
  89. lintian --color=auto -IEm --pedantic $changes $@
  90. }