Debian.zsh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. time sudo -E DIST=${DIST} cowbuilder $@ ${OPTS}
  27. return $?
  28. }
  29. cow-dist-update () {
  30. for dist in $@ ; do
  31. cow-dist ${dist} --update
  32. done
  33. }
  34. PBUILDER_PATH=/var/cache/pbuilder
  35. if [ -d "${PBUILDER_PATH}" ]; then
  36. PBUILDER_DISTS=
  37. for dist in ${PBUILDER_PATH}/*-{i386,amd64}.cow ; do
  38. dist=${dist:t:r}
  39. PBUILDER_DISTS="${PBUILDER_DISTS} ${dist}"
  40. alias cow-${dist/-/}="cow-dist ${dist}"
  41. done
  42. alias cow-update="cow-dist-update ${PBUILDER_DISTS}"
  43. unset PBUILDER_DISTS
  44. fi
  45. unset PBUILDER_PATH
  46. # tools
  47. apt-rbdepends () {
  48. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  49. }
  50. pdebdiff() {
  51. if [ ! -r debian/changelog ]; then
  52. echo "ERR: can't read debian/changelog"
  53. exit
  54. fi
  55. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  56. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  57. head -n2|tr '\n' $IFS | \
  58. read v1 v2
  59. if [ -z "$v1" -o -z "$v2" ]; then
  60. echo "ERR: can't find version \$n and \$n-1 of the package";
  61. exit
  62. fi
  63. if [ ! -r debian/control ]; then
  64. echo "ERR: can't read debian/control"
  65. exit
  66. fi
  67. egrep '^(Package|Architecture): ' debian/control | \
  68. while read line ; do
  69. pkg=$(echo $line|sed 's/Package: //')
  70. read line
  71. arch=$(echo $line|sed 's/Architecture: //')
  72. if [ $arch = 'any' ]; then
  73. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  74. fi
  75. (
  76. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  77. echo
  78. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  79. )|$PAGER
  80. done
  81. }
  82. pdeblint() {
  83. if [ ! -r debian/changelog ]; then
  84. echo "ERR: can't read debian/changelog"
  85. exit
  86. fi
  87. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  88. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  89. head -n1)
  90. if [ ! -r debian/control ]; then
  91. echo "ERR: can't read debian/control"
  92. exit
  93. fi
  94. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  95. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  96. changes="../${pkg}_${v}_${arch}.changes"
  97. if [ ! -r "$changes" ]; then
  98. echo "ERR: can't read changes file : ${changes}"
  99. exit
  100. fi
  101. lintian --color=auto -IEm --pedantic $changes $@
  102. }