-
Notifications
You must be signed in to change notification settings - Fork 5
/
eos-pkg-changelog
executable file
·180 lines (165 loc) · 10.4 KB
/
eos-pkg-changelog
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/bash
# Show the changelog of the given EndeavourOS package-name.
echo2() { echo -e "$@" >&2; }
INFO() { echo2 "==> $progname: info: $1"; }
WARN() { echo2 "==> $progname: warning: $1"; }
DIE() { echo2 "\n==> $progname: error: $1\n"; Usage 1; }
Usage() {
cat <<EOF >&2
Usage: $progname [options] package-name
Options: --help, -h This help.
--github Uses github for showing the changelog.
--gitlab Uses gitlab for showing the changelog.
--parameters Show supported package names and options.
--clfile=X, -c=X Replace PKG_CHANGELOGS array with a new one in (bash) file 'X'.
--detect-clfile, -d Detects possible changelog file at '$clfile_def'.
--url, -u Simply print the changelog URL instead of opening it in a browser.
EOF
[ "$1" ] && exit $1
}
Parameters() {
local sopts="c:dhu"
local lopts="help,github,gitlab,parameters,clfile:,detect-clfile,url"
local opts=""
opts="$(/usr/bin/getopt -o="$sopts" --longoptions "$lopts" --name "$progname" -- "$@")" || Usage 1
eval set -- "$opts"
while [ "$1" ] ; do
case "$1" in
--clfile | -c)
clfile="$2"
shift
source "$clfile" || DIE "reading $clfile failed" # get new PKG_CHANGELOGS and REPONAME
;;
--detect-clfile | -d)
clfile="$clfile_def"
if [ -e "$clfile" ] ; then
INFO "reading $clfile..."
source "$clfile" || DIE "reading $clfile failed"
else
case "$REPONAME" in
endeavouros) WARN "$clfile not found" ;;
"") INFO "using prefedined EndeavourOS changelog definitions" ;;
*) DIE "$clfile not found" ;;
esac
fi
;;
--parameters)
# Dump names of supported packages and options.
declare -p PKG_CHANGELOGS | sed 's|\[|\n\[|g' | grep "^\[" | sed -E 's|^\[([^]]*).*|\1|'
local sopts2=${sopts//:/}
local lopts2=${lopts//:/}
printf "%s\n" ${sopts2//?/-& }--${lopts2//,/ --}
exit 0
;;
--github | --gitlab) preferred_site=${1:2} ;;
--url | -u) return_url=yes ;;
--help | -h) Usage 0 ;;
--) shift; break ;;
esac
shift
done
pkgname="$1"
[ "$2" ] && INFO "parameter '$2' and later ignored"
[ "$REPONAME" ] || REPONAME=endeavouros
}
Changelog() {
local -r progname=${0##*/}
local -r progpath=${0}
local pkgname=""
local changelog_url=""
local preferred_site=gitlab # github or gitlab
local clfile="" # for option -c; if given, contains PKG_CHANGELOGS
local -r clfile_def="./changelogs.conf" # for option -d
local REPONAME=""
local return_url=no # no=open URL, yes=return URL
# Known package-names:
declare -A PKG_CHANGELOGS=( # for EndeavourOS
akm "https://github.com/endeavouros-team/PKGBUILDS/commits/master/akm"
arc-gtk-theme-eos "https://github.com/endeavouros-team/PKGBUILDS/commits/master/arc-gtk-theme-eos"
bashdb "https://aur.archlinux.org/cgit/aur.git/log/?h=bashdb"
calamares "https://github.com/endeavouros-team/PKGBUILDS/commits/master/calamares"
ckbcomp "https://salsa.debian.org/installer-team/console-setup/commits"
downgrade "https://github.com/archlinux-downgrade/downgrade/blob/main/CHANGELOG.md"
endeavouros-branding "https://github.com/endeavouros-team/Branding/commits"
endeavouros-keyring "https://github.com/endeavouros-team/keyring/commits"
endeavouros-mirrorlist "https://github.com/endeavouros-team/PKGBUILDS/commits/master/endeavouros-mirrorlist"
endeavouros-theming "https://github.com/endeavouros-team/endeavouros-theming/commits"
endeavouros-xfce4-terminal-colors "https://github.com/endeavouros-team/endeavouros-xfce4-terminal-colors/commits"
eos-apps-info "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-apps-info"
eos-bash-shared "https://github.com/endeavouros-team/eos-bash-shared/commits"
eos-breeze-sddm "https://github.com/endeavouros-team/eos-breeze-sddm/commits"
eos-downgrade "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-downgrade"
eos-dracut "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-dracut"
eos-hooks "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-hooks"
eos-lightdm-gtk-theme "https://github.com/endeavouros-arm/PKGBUILDS/commits/master/eos-lightdm-gtk-theme" #??
eos-lightdm-slick-theme "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-lightdm-slick-theme"
eos-log-tool "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-log-tool"
eos-lxdm-gtk3 "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-lxdm-gtk3"
eos-packagelist "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-packagelist"
eos-plasma-sddm-config "https://github.com/endeavouros-team/eos-plasma-sddm-config/commits"
eos-qogir-icons "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-qogir-icons"
eos-quickstart "https://github.com/endeavouros-team/eos-quickstart/commits"
eos-rankmirrors "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-rankmirrors"
eos-sddm-theme "https://github.com/endeavouros-team/eos-sddm-theme/commits"
eos-settings-budgie "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-settings-budgie"
eos-settings-cinnamon "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-settings-cinnamon"
eos-settings-gnome "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-settings-gnome"
eos-settings-i3wm "https://github.com/endeavouros-team/endeavouros-i3wm-setup/commits"
eos-settings-lxde "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-settings-lxde"
eos-settings-lxqt "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-settings-lxqt"
eos-settings-mate "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-settings-mate"
eos-settings-plasma "https://github.com/endeavouros-team/eos-settings-plasma/commits"
eos-settings-xfce4 "https://github.com/endeavouros-team/endeavouros-xfce4-theming/commits"
eos-translations "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-translations"
eos-update-notifier "https://github.com/endeavouros-team/PKGBUILDS/commits/master/eos-update-notifier"
filesystem "https://gitlab.archlinux.org/archlinux/packaging/packages/filesystem/-/commits"
kernel-install-for-dracut "https://gitlab.com/dalto.8/kernel-install-for-dracut/commits"
keyserver-rank "https://github.com/endeavouros-team/PKGBUILDS/commits/master/keyserver-rank"
lsb-release "https://gitlab.archlinux.org/archlinux/packaging/packages/lsb-release/-/commits"
mkinitcpio-openswap "https://aur.archlinux.org/cgit/aur.git/log/?h=mkinitcpio-openswap"
nvidia-hook "https://github.com/endeavouros-team/PKGBUILDS/commits/master/nvidia-hook"
nvidia-inst "https://github.com/endeavouros-team/PKGBUILDS/commits/master/nvidia-inst"
pahis "https://github.com/endeavouros-team/PKGBUILDS/commits/master/pahis"
paru "https://github.com/Morganamilo/paru/releases"
rate-mirrors "https://github.com/westandskif/rate-mirrors/commits"
reflector-bash-completion "https://github.com/endeavouros-team/PKGBUILDS/commits/master/reflector-bash-completion"
reflector-simple "https://github.com/endeavouros-team/PKGBUILDS/commits/master/reflector-simple"
welcome "https://github.com/endeavouros-team/welcome/commits"
yad "https://github.com/v1cont/yad/blob/master/NEWS"
yay "https://github.com/Jguer/yay/releases"
zfs-dkms "https://github.com/openzfs/zfs/releases"
zfs-utils "https://github.com/openzfs/zfs/releases"
)
Parameters "$@"
[ "$pkgname" ] || DIE "please give the name of a package, for example: $progname akm"
changelog_url="${PKG_CHANGELOGS[$pkgname]}"
[ "$changelog_url" ] || DIE "package name '$pkgname' is not supported"
if [ "$REPONAME" = endeavouros ] ; then
case "$preferred_site" in
gitlab)
if [ "${changelog_url/github.com\/endeavouros-team/}" != "$changelog_url" ] ; then
local url_gitlab="$changelog_url"
changelog_url=$(eos-github2gitlab "$changelog_url")
if [ -z "$changelog_url" ] || [ "$changelog_url" = "$url_gitlab" ] ; then
DIE "package name '$pkgname' was not found"
fi
fi
;;
github | *)
;;
esac
fi
# show the URL
if [ $return_url = yes ] ; then
echo "$changelog_url"
else
# use mime binding to open the URL with a browser; if needed, fallback to firefox
for app in exo-open xdg-open kde-open firefox ; do
if [ -x /bin/$app ] ; then
$app "$changelog_url"
return
fi
done
fi
}
Changelog "$@"