50_debian.zsh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #
  2. # Debian stuff
  3. #
  4. if [[ ! -r /etc/debian_version ]]; then
  5. return 0
  6. fi
  7. # specific aliases / functions
  8. alias lintian="lintian --color=auto -IE --pedantic"
  9. alias acp="apt-cache policy"
  10. alias acs="apt-cache search"
  11. alias acsh="apt-cache show"
  12. alias adg"sudo apt-get dist-upgrade"
  13. alias ag="sudo apt-get upgrade"
  14. alias agi="sudo apt-get install"
  15. alias au="sudo apt-get update"
  16. alias aug="sudo apt-get update && sudo apt-get upgrade"
  17. alias dbuild="time debuild -eDEB_BUILD_OPTIONS='parallel=9' -i -us -uc --lintian-opts --color=always -IE --pedantic"
  18. # fix some zpresto aliases
  19. unalias debi
  20. apt-rbdepends() {
  21. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  22. }
  23. debdoc() {
  24. cd /usr/share/doc/$1 && ls
  25. }
  26. dbug() {
  27. if [[ $# -eq 1 ]]; then
  28. case "$1" in
  29. [0-9]*)
  30. xdg-open "http://bugs.debian.org/$1"
  31. ;;
  32. *@*)
  33. xdg-open "http://bugs.debian.org/cgi-bin/pkgreport.cgi?submitter=$1"
  34. ;;
  35. *)
  36. xdg-open "http://bugs.debian.org/src:$*"
  37. ;;
  38. esac
  39. else
  40. print "$0 needs one argument"
  41. return 1
  42. fi
  43. }
  44. # specific completions
  45. # rdebsign is a trivial shell script wrapper around debsign
  46. #compdef rdebsign=scp
  47. # building environements
  48. cow-dist() {
  49. if [ $# -lt 2 ]; then
  50. echo "Error args."
  51. return
  52. fi
  53. DIST=${1}
  54. shift
  55. OPTS=
  56. if [ "$1" = "--update" ]; then
  57. OPTS="--no-cowdancer-update"
  58. elif [ "$1" = "--build" -a -z "$2" ]; then
  59. if [ -f debian/changelog ]; then
  60. dsc=$(egrep -v "^([[:space:]]+|$)" debian/changelog| \
  61. sed 's/\([^ ]*\) (\([^)]*\)).*/..\/\1_\2.dsc/'|head -1)
  62. if [ -f "$dsc" ]; then
  63. OPTS="$dsc"
  64. fi
  65. fi
  66. fi
  67. time sudo -E DIST=${DIST} cowbuilder $@ ${OPTS}
  68. return $?
  69. }
  70. cow-dist-update () {
  71. for dist in $@ ; do
  72. cow-dist ${dist} --update
  73. done
  74. }
  75. PBUILDER_PATH=/var/cache/pbuilder
  76. if [ -d "${PBUILDER_PATH}" ]; then
  77. PBUILDER_DISTS=
  78. for f in ${PBUILDER_PATH}/* ; do
  79. case "$f" in
  80. *-i386.cow|*-amd64.cow)
  81. dist=${f:t:r}
  82. PBUILDER_DISTS="${PBUILDER_DISTS} ${dist}"
  83. alias cow-${dist/-/}="cow-dist ${dist}"
  84. ;;
  85. esac
  86. done
  87. if [ -n "${PBUILDER_DISTS}" ]; then
  88. alias cow-update="cow-dist-update ${PBUILDER_DISTS}"
  89. fi
  90. unset PBUILDER_DISTS
  91. fi
  92. unset PBUILDER_PATH
  93. pdebdiff() {
  94. if [ ! -r debian/changelog ]; then
  95. echo "ERR: can't read debian/changelog"
  96. return
  97. fi
  98. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  99. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  100. head -n2 | tr '\n' $IFS | \
  101. read v1 v2
  102. if [ -z "$v1" -o -z "$v2" ]; then
  103. echo "ERR: can't find version \$n and \$n-1 of the package";
  104. return
  105. fi
  106. if [ ! -r debian/control ]; then
  107. echo "ERR: can't read debian/control"
  108. return
  109. fi
  110. egrep '^(Package|Architecture): ' debian/control | \
  111. while read line ; do
  112. pkg=$(echo $line|sed 's/Package: //')
  113. read line
  114. arch=$(echo $line|sed 's/Architecture: //')
  115. if [ $arch = 'any' ]; then
  116. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  117. fi
  118. (
  119. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  120. echo
  121. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  122. ) | $PAGER
  123. done
  124. }
  125. pdeblint() {
  126. if [ ! -r debian/changelog ]; then
  127. echo "ERR: can't read debian/changelog"
  128. return
  129. fi
  130. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  131. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  132. head -n1)
  133. if [ ! -r debian/control ]; then
  134. echo "ERR: can't read debian/control"
  135. return
  136. fi
  137. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  138. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  139. changes="../${pkg}_${v}_${arch}.changes"
  140. if [ ! -r "$changes" ]; then
  141. echo "ERR: can't read changes file : ${changes}"
  142. return
  143. fi
  144. =lintian --color=auto -IE --pedantic $changes $@
  145. }