50_debian.zsh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. apt-rbdepends() {
  19. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  20. }
  21. debdoc() {
  22. cd /usr/share/doc/$1 && ls
  23. }
  24. dbug() {
  25. if [[ $# -eq 1 ]]; then
  26. case "$1" in
  27. [0-9]*)
  28. xdg-open "http://bugs.debian.org/$1"
  29. ;;
  30. *@*)
  31. xdg-open "http://bugs.debian.org/cgi-bin/pkgreport.cgi?submitter=$1"
  32. ;;
  33. *)
  34. xdg-open "http://bugs.debian.org/src:$*"
  35. ;;
  36. esac
  37. else
  38. print "$0 needs one argument"
  39. return 1
  40. fi
  41. }
  42. # specific completions
  43. # rdebsign is a trivial shell script wrapper around debsign
  44. compdef rdebsign=scp
  45. # building environements
  46. cow-dist() {
  47. if [ $# -lt 2 ]; then
  48. echo "Error args."
  49. return
  50. fi
  51. DIST=${1}
  52. shift
  53. OPTS=
  54. if [ "$1" = "--update" ]; then
  55. OPTS="--no-cowdancer-update"
  56. elif [ "$1" = "--build" -a -z "$2" ]; then
  57. if [ -f debian/changelog ]; then
  58. dsc=$(egrep -v "^([[:space:]]+|$)" debian/changelog| \
  59. sed 's/\([^ ]*\) (\([^)]*\)).*/..\/\1_\2.dsc/'|head -1)
  60. if [ -f "$dsc" ]; then
  61. OPTS="$dsc"
  62. fi
  63. fi
  64. fi
  65. time sudo -E DIST=${DIST} cowbuilder $@ ${OPTS}
  66. return $?
  67. }
  68. cow-dist-update () {
  69. for dist in $@ ; do
  70. cow-dist ${dist} --update
  71. done
  72. }
  73. PBUILDER_PATH=/var/cache/pbuilder
  74. if [ -d "${PBUILDER_PATH}" ]; then
  75. PBUILDER_DISTS=
  76. for f in ${PBUILDER_PATH}/* ; do
  77. case "$f" in
  78. *-i386.cow|*-amd64.cow)
  79. dist=${f:t:r}
  80. PBUILDER_DISTS="${PBUILDER_DISTS} ${dist}"
  81. alias cow-${dist/-/}="cow-dist ${dist}"
  82. ;;
  83. esac
  84. done
  85. if [ -n "${PBUILDER_DISTS}" ]; then
  86. alias cow-update="cow-dist-update ${PBUILDER_DISTS}"
  87. fi
  88. unset PBUILDER_DISTS
  89. fi
  90. unset PBUILDER_PATH
  91. pdebdiff() {
  92. if [ ! -r debian/changelog ]; then
  93. echo "ERR: can't read debian/changelog"
  94. return
  95. fi
  96. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  97. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  98. head -n2 | tr '\n' $IFS | \
  99. read v1 v2
  100. if [ -z "$v1" -o -z "$v2" ]; then
  101. echo "ERR: can't find version \$n and \$n-1 of the package";
  102. return
  103. fi
  104. if [ ! -r debian/control ]; then
  105. echo "ERR: can't read debian/control"
  106. return
  107. fi
  108. egrep '^(Package|Architecture): ' debian/control | \
  109. while read line ; do
  110. pkg=$(echo $line|sed 's/Package: //')
  111. read line
  112. arch=$(echo $line|sed 's/Architecture: //')
  113. if [ $arch = 'any' ]; then
  114. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  115. fi
  116. (
  117. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  118. echo
  119. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  120. echo
  121. echo "# vim: wrap"
  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. }