Debian.zsh 2.6 KB

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