Debian.zsh 2.5 KB

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