aboutsummaryrefslogtreecommitdiffstats
path: root/src/getname.sh
blob: f9ed5ec227bb1041a27f875216561107c9bb1d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

# Usage:
#   getname.sh
#       Returns the list of all known .udeb files.
#   getname.sh [name]
#       Returns the canonical name of a package name.

set -ue

if [ $# -gt 0 ]; then
    name="${1#src/}"
    case "$1" in
        src/*-udeb/*) name="${name%%/*}";;
        *-udeb);;
        *) name="${name%.udeb}"; name="${name%%_*}-udeb";;
    esac
    echo $name
else
    for dir in src/*-udeb/; do
    if [ -r "$dir/debian/files" ]; then
        echo src/$(cut -d' ' -f1 "$dir/debian/files")
    else
        sed -nr 's@^(\S+) \(([0-9.]+)\).*@src/\1_\2_all.udeb@p' "$dir/debian/changelog"
    fi
    done
fi