-
Notifications
You must be signed in to change notification settings - Fork 5
/
eos-pkg-changelog
executable file
·223 lines (206 loc) · 11.9 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/bash
# Show the changelog of the given EndeavourOS package-name.
echo2() { echo -e "$@" >&2; }
INFO() { [ $quiet = no ] && 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(s)
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. Implies option -d.
--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.
--quiet Don't show purely informational messages (but show errors and warnings).
EOF
[ "$1" ] && exit $1
}
DumpPkgnames() {
declare -p PKG_CHANGELOGS | sed 's|\[|\n\[|g' | grep "^\[" | sed -E 's|^\[([^]]*).*|\1|'
}
DumpOptions() {
local sopts2=${sopts//:/}
local lopts2=${lopts//:/}
printf "%s\n" ${sopts2//?/-& }--${lopts2//,/ --}
}
DetectClFile() {
local mode="$1"
clfile="$clfile_def"
if [ -e "$clfile" ] ; then
[ "$mode" = verbose ] && INFO "reading $clfile..."
source "$clfile" || DIE "reading $clfile failed"
else
case "$REPONAME" in
endeavouros | "") ;; # $clfile not found | using predefined EndeavourOS changelog definitions
*) DIE "$clfile not found" ;;
esac
fi
}
Parameters() {
local sopts="c:dhu"
local lopts="help,github,gitlab,parameters,clfile:,detect-clfile,quiet,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)
DetectClFile verbose
;;
--parameters)
DetectClFile
DumpPkgnames
DumpOptions
exit 0
;;
--github | --gitlab) preferred_site=${1:2} ;;
--url | -u) return_url=yes ;;
--quiet) quiet=yes ;;
--help | -h) Usage 0 ;;
--) shift; break ;;
esac
shift
done
pkgnames=("$@")
[ "$REPONAME" ] || REPONAME=endeavouros
}
Changelog() {
local -r progname=${0##*/}
local -r progpath=${0}
local pkgnames=()
local preferred_site=gitlab # github or gitlab
local clfile="" # for option -c; if given, the file contains PKG_CHANGELOGS and REPONAME
local -r clfile_def="./changelogs.conf" # for option -d
local REPONAME=""
local return_url=no # no=open URL, yes=return URL
local quiet=no
# Known package-names:
declare -A PKG_CHANGELOGS=( # for EndeavourOS
# pkgname "URL(s) separated by '|'"
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-gtk-theme "https://github.com/endeavouros-team/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|https://github.com/vinceliuice/Qogir-icon-theme/releases"
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|https://github.com/Morganamilo/paru/commits"
rate-mirrors "https://github.com/westandskif/rate-mirrors/releases|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|https://github.com/v1cont/yad/commits"
yay "https://github.com/Jguer/yay/releases|https://github.com/Jguer/yay/commits"
zfs-dkms "https://github.com/openzfs/zfs/releases"
zfs-utils "https://github.com/openzfs/zfs/releases"
)
Parameters "$@"
HandlePkgnames
}
HandlePkgnames() {
[ "$pkgnames" ] || DIE "please give package-name(s), for example: $progname akm"
local pkgname
local changelog_url=""
local urls_line=""
local URLS=()
local tmp=()
for pkgname in "${pkgnames[@]}" ; do
changelog_url="${PKG_CHANGELOGS[$pkgname]}"
if [ -z "$changelog_url" ] ; then
[ "$quiet" = no ] && DIE "package name '$pkgname' is not supported" || exit 1
fi
if [ "$REPONAME" = endeavouros ] ; then
case "$preferred_site" in
gitlab)
if [ "${changelog_url/github.com\/endeavouros-team/}" != "$changelog_url" ] ; then
# convert a github link to a corresponding gitlab link
local url_github="$changelog_url"
changelog_url=$(eos-github2gitlab "$changelog_url")
if [ -z "$changelog_url" ] || [ "$changelog_url" = "$url_github" ] ; then
DIE "package name '$pkgname' was not found"
fi
fi
;;
github | *)
;;
esac
fi
if [ $return_url = yes ] ; then
[ "$urls_line" ] && urls_line+="|$changelog_url" || urls_line="$changelog_url"
else
readarray -t tmp <<< $(echo "${changelog_url//|/$'\n'}")
URLS+=("${tmp[@]}")
fi
done
if [ "$urls_line" ] ; then
echo "$urls_line" # show the URL(s) separated by '|'
elif [ "$URLS" ] ; then
OPEN_URLS "${URLS[@]}" # open the URL(s)
fi
}
OPEN_URLS() {
# use mime binding to open the URL(s) with a browser; if needed, fallback to firefox
local xx
if [ -x /bin/exo-open ] ; then
exo-open "$@"
elif [ -x /bin/kde-open ] ; then
for xx in "$@" ; do
kde-open "$xx"
done
elif [ -x /bin/xdg-open ] ; then
for xx in "$@" ; do
xdg-open "$xx"
done
elif [ -x /bin/firefox ] ; then
setsid firefox "$@"
fi
}
Changelog "$@"