blob: 9a1951b7d8a635c7ae7a768adfaeb63abda34663 (
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
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
|
#!/bin/bash
#
# arch2parabola - converts an Arch GNU/Linux system to Parabola GNU/Linux-libre
#
# Copyright © 2010 Joshua Ismael Haase Hernández
# Copyright © 2011 Joseph Graham
# ^^^ Lies, it's a TaylanUB rewrite !
# Copyright © 2011 Taylan Ulrich Bayırlı
#
# ---------- GNU General Public License 3 ----------
#
# This file is part of Parabola.
#
# Parabola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Parabola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
#
blacklist='http://repo.parabolagnulinux.org/docs/blacklist.txt'
mirrorlist='http://repo.parabolagnulinux.org/files/mirrorlist'
kernel_pkgname='kernel26'
logfile="$(pwd)/arch2parabola-$$.log"
Usage ()
{
echo >&2 'arch2parabola [-c|--check-nonfree]'
}
Log ()
{
printf '%s\n' "$@"
printf '%s\n' "$@" >> "$logfile"
}
# Sets $section
Section ()
{
section=$1
Log '' "--- $section ---"
}
Abort ()
{
Log >&2 "$@"
Log >&2 "Aborted in section: $section"
echo >&2 "Log saved to: $logfile"
exit 1
}
# Sets $ans
Ask ()
{
unset ans
while true
do
printf '%s' "$1" >&2
read -r ans; ans=${ans,}
[[ $ans == [yn] ]] && break
echo '("y" for yes, "n" for no)' >&2
done
}
CheckAns ()
{
case $ans in
y) ;;
n) Abort 'Cancelled by user.' ;;
*) echo >&2 'What the fuck?'
esac
}
Download ()
{
wget -nv -O- 2>> "$logfile"
}
# Sets $nonfree_pkgs and $replacements
CheckNonfree ()
while IFS=: read -r pkg repl _
do
if pacman -Q "$pkg" > /dev/null 2>&1
then
nonfree_pkgs+=("$pkg")
replacements+=("$repl")
echo "$pkg, replacement: ${repl:-NONE!}"
fi
done <<< $(Download "$blacklist" | sort || Abort 'Download failed.')
case $# in
0) ;;
1)
case $1 in
-c|--check-nonfree) CheckNonfree; exit ;;
*) Usage; exit 1
esac
;;
*) Usage; exit 1
esac
Section 'Sanity check'
if ! [[ -w / ]]
then
echo >&2 'This script must be run as root.'
exit 1
fi
if ! pacman -Q "$kernel_pkgname" > /dev/null 2>&1
then
echo >&2 'The system is running a custom kernel.'
echo >&2 'Please uninstall it before re-running this script.'
echo >&2
echo >&2 'You can find a PKGBUILD for a linux-libre kernel at'
echo >&2
echo >&2 'http://repo.parabolagnulinux.org/pkgbuilds/'
exit 1
fi
if [[ -e $logfile ]]
then
Abort "The file '$logfile' already exists, not overwriting."
else
> "$logfile" || Abort "Can't touch '$logfile'!"
echo "Logging to: $logfile"
fi
Section 'Non-free packages revision'
echo '* Downloading blacklist and searching for proprietary software on the system.'
CheckNonfree | tee -a "$logfile"
Section 'Pacman mirrorlist replacement'
echo '* Pacman will be synced. (pacman -S pacman)'
echo '* /etc/pacman.d/mirrorlist will be replaced by the Parabola mirrorlist.'
echo '* Package databases will be forced to sync, to make the mirrorlist take effect. (pacman -Syy)'
echo
Ask 'Do you wish to continue? [y/n] '
CheckAns
pacman -S --noconfirm pacman 2>&1 | tee -a "$logfile" || Abort 'Syncing pacman failed.'
Ask 'Shall the mirrorlist be run through rankmirrors? [y/n] '
case $ans in
y) Download "$mirrorlist" | rankmirrors - > /etc/pacman.d/mirrorlist ;;
n) Download "$mirrorlist" > /etc/pacman.d/mirrorlist ;;
*) echo 'What the fuck?'
esac
pacman -Syy --noconfirm 2>&1 | tee -a "$logfile" || Abort 'Syncing databases failed.'
Section 'Package replacement and removal'
echo '* Replacements will be installed when possible.'
echo '* Non-free packages will be removed.'
echo ' Packages rendered useless by this will be removed.'
echo ' (pacman -Rnsc ...) (Will let pacman prompt you once more!)'
echo '* Pacman cache will be cleared to purge the old non-free packages. (pacman -Sc)'
echo
Ask 'Do you wish to continue? [y/n] '
CheckAns
i=0
while pkg=${nonfree_pkgs[$i]}; repl=${replacements[$i]}; (( ++i < ${#nonfree_pkgs[@]} ))
do
if [[ $repl ]]
then
if ! pacman -Q "$repl" > /dev/null 2>&1 &&
pacman -Si "$repl" > /dev/null 2>&1
then
pacman -S --noconfirm "$pkg" 2>&1 | tee -a "$logfile" ||
Abort "Installation of '$repl' failed."
else
Log "The replacement '$repl' for '$pkg' was not found in the repos."
fi
else
Log "There is no known replacement for '$pkg'."
fi
# The replacement might have caused removal already
if pacman -Q "$pkg" > /dev/null 2>&1
then
pacman -Rnsc "$pkg" 2>&1 | tee -a "$logfile" || Abort "Removal of '$pkg' failed."
fi
done
Section 'You are now on Parabola GNU/Linux-libre !'
echo 'Welcome to Freedom.'
echo '* You have to manually remove any non-free packages you installed from the AUR.'
echo
Ask 'Do you wish to keep the log? [y/n] '
case $ans in
y) echo "The log is at: $logfile" ;;
n) rm -f "$logfile" ;;
*) echo >&2 'What the fuck?'
esac
|