aboutsummaryrefslogtreecommitdiffstats
path: root/System/apt-get-src-package-version.sh
blob: 1776b9da9cb3a2fc338c20fdf34102e1969e989a (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
########################################################################################################################
# apt-get-src-package-version.sh
########################################################################################################################
#
# All rights reserved Ⓒ 2017-2023 sdxlive.com
#
# Written by Jean-Christophe Manciot <jcmanciot@sdxlive.com>
#
# Licensed under a GPLv3 License.
# You may not use this file except in compliance with the License. You may obtain a copy of the License at
#
#    https://www.gnu.org/licenses/gpl-3.0.md
#
# The licensor cannot revoke these freedoms as long as you follow the license terms.
#
# Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. 
# You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
#
########################################################################################################################

########################################################################################################################
#
# Showing the version of an apt source package.
#
########################################################################################################################
#
# Requirements:
# ------------
#
# - We assume that apt is already installed.
#
########################################################################################################################
#
# Parameters:
# ----------
#
# - <src_package_name>: name of the source package
#
#######################################################################################################################
#
# Usage: example
# -----
#
# apt-get-src-package-version.sh qemu
#
########################################################################################################################
# set -x

src_package_name=$1
PARAMETERS_NUMBER=1

case "$#" in
        ${PARAMETERS_NUMBER})
                ;;
        *)
                echo -e ''$_{1..180}'\b-'
                echo Wrong number of parameters: $(basename $0) $@
                echo -e ''$_{1..180}'\b-'
                exit 1
                ;;
esac

if [[ ! $(apt-cache showsrc "$src_package_name" 2>&1) =~ 'Unable to locate package' ]]; then
        apt-cache showsrc "$src_package_name" | grep -P ^[[:blank:]]*Version:[[:blank:]]+ | awk '{print $2}' | sort -V | tail -n 1
fi
exit $?