Debian.zsh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 sid-32"
  30. alias cow-stable32="cow-dist stable-32"
  31. alias cow-exp64="cow-dist experimental-64"
  32. alias cow-sid64="cow-dist sid-64"
  33. alias cow-stable64="cow-dist stable-64"
  34. alias cow-stablebpo="cow-dist stable-bpo-64"
  35. # tools
  36. apt-rbdepends () {
  37. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  38. }
  39. pdebdiff() {
  40. if [ ! -r debian/changelog ]; then
  41. echo "ERR: can't read debian/changelog"
  42. exit
  43. fi
  44. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  45. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  46. head -n2|tr '\n' $IFS | \
  47. read v1 v2
  48. if [ -z "$v1" -o -z "$v2" ]; then
  49. echo "ERR: can't find version \$n and \$n-1 of the package";
  50. exit
  51. fi
  52. if [ ! -r debian/control ]; then
  53. echo "ERR: can't read debian/control"
  54. exit
  55. fi
  56. egrep '^(Package|Architecture): ' debian/control | \
  57. while read line ; do
  58. pkg=$(echo $line|sed 's/Package: //')
  59. read line
  60. arch=$(echo $line|sed 's/Architecture: //')
  61. if [ $arch = 'any' ]; then
  62. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  63. fi
  64. (
  65. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  66. echo
  67. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  68. )|$PAGER
  69. done
  70. }
  71. pdeblint() {
  72. if [ ! -r debian/changelog ]; then
  73. echo "ERR: can't read debian/changelog"
  74. exit
  75. fi
  76. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  77. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  78. head -n1)
  79. if [ ! -r debian/control ]; then
  80. echo "ERR: can't read debian/control"
  81. exit
  82. fi
  83. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  84. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  85. changes="../${pkg}_${v}_${arch}.changes"
  86. if [ ! -r "$changes" ]; then
  87. echo "ERR: can't read changes file : ${changes}"
  88. exit
  89. fi
  90. lintian --color=auto -IEm --pedantic $changes $@
  91. }