Prechádzať zdrojové kódy

Add shell functions related to debian packaging.

Emmanuel Bouthenot 15 rokov pred
rodič
commit
2c211ac9fc
1 zmenil súbory, kde vykonal 72 pridanie a 3 odobranie
  1. 72 3
      .zsh.d/os.d/Debian.zsh

+ 72 - 3
.zsh.d/os.d/Debian.zsh

@@ -5,8 +5,7 @@
 alias lintian="lintian --color=auto -IEm"
 
 # building environements
-
-function cow-dist () {
+cow-dist () {
     [ $# -lt 2 ] \
 	&& echo "Error args." \
 	&& return
@@ -21,4 +20,74 @@ function cow-dist () {
 }
 
 alias cow-stable="cow-dist stable"
-alias cow-sid="cow-dist sid"
+alias cow-sid="cow-dist sid"
+
+# tools
+apt-rbdepends () {
+    grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
+}
+
+pdebdiff() {
+    if [ ! -r debian/changelog ]; then
+        echo "ERR: can't read debian/changelog"
+        exit
+    fi
+
+    egrep -v "^([[:space:]]+|$)" debian/changelog | \
+        sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
+        head -n2|tr '\n' $IFS | \
+        read v1 v2
+
+    if [ -z "$v1" -o -z "$v2" ]; then
+        echo "ERR: can't find version \$n and \$n-1 of the package";
+        exit
+    fi
+
+    if [ ! -r debian/control ]; then
+        echo "ERR: can't read debian/control"
+        exit
+    fi
+
+    egrep '^(Package|Architecture): ' debian/control | \
+        while read line ; do
+            pkg=$(echo $line|sed 's/Package: //')
+            read line
+            arch=$(echo $line|sed 's/Architecture: //')
+            if [ $arch = 'any' ]; then
+                arch=$(dpkg-architecture -qDEB_HOST_ARCH)
+            fi
+            (
+                echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
+                echo
+                debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
+                )|$PAGER
+    done
+}
+
+pdeblint() {
+    if [ ! -r debian/changelog ]; then
+        echo "ERR: can't read debian/changelog"
+        exit
+    fi
+
+    v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
+        sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
+        head -n1)
+
+    if [ ! -r debian/control ]; then
+        echo "ERR: can't read debian/control"
+        exit
+    fi
+
+    pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
+    arch=$(dpkg-architecture -qDEB_HOST_ARCH)
+
+    changes="../${pkg}_${v}_${arch}.changes"
+    if [ ! -r "$changes" ]; then
+        echo "ERR: can't read changes file : ${changes}"
+        exit
+    fi
+
+    lintian --color=auto -IEm $changes $@
+}
+