This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
/
add_repositories
173 lines (166 loc) · 5.37 KB
/
add_repositories
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
#!/bin/bash
# Add RPM Repo
#
# ${1} = name
# ${2} = baseurl
# ${3} = gpgkey
# ${4} = return_function
function add_rpm_repo() {
echo_message header "Starting 'add_rpm_repo' function"
# Check if repo is already added
if [ -e /etc/yum.repos.d/${1,,}.repo ]; then
echo_message info "${1} repository already added."
whiptail --msgbox "The ${1} RPM repository is already added." 8 56
${4}
else
# Add repository
echo_message info "Creating temporary repository file for ${1}..."
# create temporary repo file
touch /tmp/${1,,}.repo
# write lines to repo file
echo -e "[${1}]" >> /tmp/${1,,}.repo
echo -e "name=${1}" >> /tmp/${1,,}.repo
echo -e "baseurl=${2}" >> /tmp/${1,,}.repo
echo -e "gpgkey=${3}" >> /tmp/${1,,}.repo
# Draw window
if (eval `resize` && whiptail \
--title "Adding ${1^} Repository" \
--yesno "Newly created repository file for ${1}: \n\n$(cat /tmp/${1,,}.repo) \n\nWould you like to proceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext \
3>&1 1>&2 2>&3) then
# Move temporary repo file to /etc/yum.repos.d/
echo_message info "Moving temporary repository file..."
superuser_do mv /tmp/${1,,}.repo /etc/yum.repos.d/
# Refresh dnf
echo_message info "Refreshing repository metadata..."
superuser_do dnf refresh
# Finished
echo_message success "Repository added."
whiptail --title "Finished" --msgbox "The '${1}' RPM repository has been added." 8 56
${4}
else
# delete temporary repo file
rm /tmp/${1,,}.repo
# Cancelled
echo_message info "Addition of ${1} repository cancelled."
${4}
fi
fi
}
# Add Flatpak Repo
#
# ${1} = remote
# ${2} = https://remote.example.com/
# ${3} = return_function
function add_flatpak_repo() {
echo_message header "Starting 'add_flatpak_repo' function"
# Check if repo is already added
if [ $(flatpak remotes | grep ${1} &> /dev/null; echo $?) = 0 ]; then
echo_message info "Repository already added."
whiptail --msgbox "The ${1} Flatpak repository is already added." 8 56
${3}
else
# Add repository
echo_message info "Adding flatpak repository..."
flatpak remote-add --if-not-exists ${1} ${2}
echo_message success "Repository added."
whiptail --title "Finished" --msgbox "The '${1}' Flatpak repository has been added." 8 56
${3}
fi
}
# Add RPM Fusion repository
#
# ${1} = free or nonfree
# ${2} = return_function
function add_rpmfusion() {
echo_message header "Starting 'add_rpmfusion' function"
# Check if valid RPM Fusion repository
if [[ "${1}" = "free" ]] || [[ "${1}" = "nonfree" ]] ; then
# Check if already present
if [ -e /etc/yum.repos.d/rpmfusion-${1}.repo ]; then
echo_message info "RPM Fusion (${1^}) repository already added."
whiptail --msgbox "The RPM Fusion (${1^}) repository is already added." 8 56
${2}
else
# Add repository
if (eval `resize` && whiptail \
--title "Add RPM Fusion (${1^}) Repository?" \
--yesno "The RPM Fusion (${1^}) repository is required for this installation.\n\nAre you sure you want to proceed?" \
10 60) then
# Add repository
echo_message info "Downloading RPM Fusion (${1}) repository package..."
superuser_do "dnf install -y https://download1.rpmfusion.org/${1}/fedora/rpmfusion-${1}-release-$(rpm -E %fedora).noarch.rpm"
# Finished
echo_message success "RPM Fusion (${1^}) repository has been added."
whiptail --title "Finished" --msgbox "RPM Fusion (${1^}) repository has been added." 8 56
${2}
else
# Cancelled
echo_message info "Addition of RPM Fusion (${1^}) repository was cancelled."
${2}
fi
fi
else
# If there is an error
echo_message error "Not a valid RPM Fusion repository. Aborting..."
whiptail --msgbox "Not a valid RPM Fusion repository. Sorry, try again." --title "Oops" 8 56
${2}
fi
}
# Add Repositories
function add_repositories {
echo_message header "Starting 'add_repositories' function"
NAME="Third-Party Repositories"
echo_message title "Starting addition of ${NAME,,}..."
# Draw window
REPOS=$(eval `resize` && whiptail \
--notags \
--title "$NAME" \
--menu "\nWhat ${NAME,,} would you like to add?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
"rpmfusion_free" "RPM Fusion (Free)" \
"rpmfusion_nonfree" "RPM Fusion (Non-free)" \
"flatpak_flathub" "FlatHub" \
"flatpak_gnome" "GNOME" \
"flatpak_gnome_nightly" "GNOME Nightly" \
"flatpak_gnome_apps_nightly" "GNOME Apps Nightly" \
3>&1 1>&2 2>&3)
# check exit status
while [ $? -eq 0 ]; do
case "${REPOS}" in
# RPM Fusion Free
rpmfusion_free)
add_rpmfusion "free" add_repositories
;;
# RPM Fusion Non-free
rpmfusion_nonfree)
add_rpmfusion "nonfree" add_repositories
;;
# FlatHub
flatpak_flathub)
add_flatpak_repo "flathub" "https://dl.flathub.org/repo/flathub.flatpakrepo" add_repositories
;;
# GNOME
flatpak_gnome)
add_flatpak_repo "gnome" "https://sdk.gnome.org/gnome.flatpakrepo" add_repositories
;;
# GNOME
flatpak_gnome_nightly)
add_flatpak_repo "gnome-nightly" "https://sdk.gnome.org/gnome-nightly.flatpakrepo" add_repositories
;;
# GNOME
flatpak_gnome_apps_nightly)
add_flatpak_repo "gnome-apps-nightly" "https://sdk.gnome.org/gnome-apps-nightly.flatpakrepo" add_repositories
;;
# Go Back
*)
# Cancelled
echo_message info "Addition of ${NAME,,} cancelled."
main
;;
esac
done
}