Skip to content

Instantly share code, notes, and snippets.

@jlu5
Forked from thepaul/changelog_from_deb.sh
Last active January 11, 2017 02:11
Show Gist options
  • Save jlu5/40388c1ed08bc04c12d7b7be50215dd4 to your computer and use it in GitHub Desktop.
Save jlu5/40388c1ed08bc04c12d7b7be50215dd4 to your computer and use it in GitHub Desktop.

Revisions

  1. James Lu revised this gist Jan 11, 2017. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions genchanges.sh
    Original file line number Diff line number Diff line change
    @@ -36,6 +36,12 @@ if [[ -z "$1" ]]; then
    fi

    for deb in $(find "$1" | grep ".deb$"); do
    echo "Processing $deb..." >&2
    changelog_from_deb "$deb" "${1%.deb}.changelog"
    echo "Processing $deb..." >&2
    # This format creates changelogs for synaptic - pkgname_version_arch.changelog (reference: https://github.com/smira/aptly/issues/170)
    target="${deb%.deb}.changelog"
    changelog_from_deb "$deb" "$target"
    # Symlink that to the format apt uses - pkgname_version.changelog
    #apt_target="$(cut -d '_' -f 1-2 <<< $target).changelog"
    #echo "Symlinking $target to $apt_target" >&2
    #ln -s "$target" "$apt_target"
    done
  2. James Lu revised this gist Dec 22, 2016. 1 changed file with 0 additions and 0 deletions.
    Empty file modified genchanges.sh
    100644 → 100755
    Empty file.
  3. James Lu renamed this gist Dec 22, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. James Lu revised this gist Dec 12, 2016. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions changelog_from_deb.sh
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,11 @@ changelog_from_deb () {
    # won't work when packages symlink their docs from another package from the same source;
    # you'll get "No changelog found."

    if [[ -z "$2" || -e "$2" ]]; then
    echo "Target file \"$2\" exists or is empty; skipping" >&2
    return 0
    fi

    t="$(mktemp -d)"
    p="$(dpkg-deb -f "$1" Package)"
    echo "Package name found as $p" >&2
    @@ -13,7 +18,7 @@ changelog_from_deb () {
    tar -x --wildcards -C $t ./usr/share/doc/"$p"/changelog\* 2>/dev/null
    for f in changelog.Debian.gz changelog.gz; do
    if [ -e "$t/usr/share/doc/$p/$f" ]; then
    target="${1%.deb}.changelog"
    target="$2"
    echo "Writing changelog to $target" >&2
    gzip -dc < "$t/usr/share/doc/$p/$f" | tee "$target"
    fail=0
    @@ -31,6 +36,6 @@ if [[ -z "$1" ]]; then
    fi

    for deb in $(find "$1" | grep ".deb$"); do
    echo "Processing $deb..." >&2
    changelog_from_deb "$deb"
    echo "Processing $deb..." >&2
    changelog_from_deb "$deb" "${1%.deb}.changelog"
    done
  5. James Lu revised this gist Dec 12, 2016. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions changelog_from_deb.sh
    Original file line number Diff line number Diff line change
    @@ -7,28 +7,30 @@ changelog_from_deb () {

    t="$(mktemp -d)"
    p="$(dpkg-deb -f "$1" Package)"
    echo "Package name found as $p"
    echo "Package name found as $p" >&2
    fail=1
    dpkg-deb --fsys-tarfile "$1" | \
    tar -x --wildcards -C $t ./usr/share/doc/"$p"/changelog\* 2>/dev/null
    for f in changelog.Debian.gz changelog.gz; do
    if [ -e "$t/usr/share/doc/$p/$f" ]; then
    gzip -dc < "$t/usr/share/doc/$p/$f" | tee "./${1%.deb}.changelog"
    target="${1%.deb}.changelog"
    echo "Writing changelog to $target" >&2
    gzip -dc < "$t/usr/share/doc/$p/$f" | tee "$target"
    fail=0
    break
    fi
    done
    #rm -rf $t
    rm -rf $t
    [ $fail -eq 0 ] || echo "No changelog found." >&2
    return $fail
    }

    if [[ -z "$1" ]]; then
    echo "Missing command line argument (path of .deb's)"
    echo "Missing command line argument (path of .deb's)" >&2
    exit 1
    fi

    for deb in $(find "$1" | grep ".deb$"); do
    echo "Processing $deb..."
    echo "Processing $deb..." >&2
    changelog_from_deb "$deb"
    done
  6. James Lu revised this gist Dec 12, 2016. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions changelog_from_deb.sh
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,34 @@
    #!/bin/bash

    # Adapted from https://gist.github.com/thepaul/1002763
    changelog_from_deb () {
    # won't work when packages symlink their docs from another package from the same source;
    # you'll get "No changelog found."

    t="$(mktemp -d)"
    p="$(dpkg-deb -f "$1" Package)"
    echo "Package name found as $p"
    fail=1
    dpkg-deb --fsys-tarfile "$1" | \
    tar -x --wildcards -C $t ./usr/share/doc/"$p"/changelog\* 2>/dev/null
    for f in changelog.Debian.gz changelog.gz; do
    if [ -e "$t/usr/share/doc/$p/$f" ]; then
    gzip -dc < "$t/usr/share/doc/$p/$f"
    gzip -dc < "$t/usr/share/doc/$p/$f" | tee "./${1%.deb}.changelog"
    fail=0
    break
    fi
    done
    rm -rf $t
    #rm -rf $t
    [ $fail -eq 0 ] || echo "No changelog found." >&2
    return $fail
    }
    }

    if [[ -z "$1" ]]; then
    echo "Missing command line argument (path of .deb's)"
    exit 1
    fi

    for deb in $(find "$1" | grep ".deb$"); do
    echo "Processing $deb..."
    changelog_from_deb "$deb"
    done
  7. @thepaul thepaul created this gist Jun 1, 2011.
    20 changes: 20 additions & 0 deletions changelog_from_deb.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    changelog_from_deb () {
    # won't work when packages symlink their docs from another package from the same source;
    # you'll get "No changelog found."

    t="$(mktemp -d)"
    p="$(dpkg-deb -f "$1" Package)"
    fail=1
    dpkg-deb --fsys-tarfile "$1" | \
    tar -x --wildcards -C $t ./usr/share/doc/"$p"/changelog\* 2>/dev/null
    for f in changelog.Debian.gz changelog.gz; do
    if [ -e "$t/usr/share/doc/$p/$f" ]; then
    gzip -dc < "$t/usr/share/doc/$p/$f"
    fail=0
    break
    fi
    done
    rm -rf $t
    [ $fail -eq 0 ] || echo "No changelog found." >&2
    return $fail
    }