-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathupgrade-to-trixie
More file actions
215 lines (184 loc) · 7.24 KB
/
Copy pathupgrade-to-trixie
File metadata and controls
215 lines (184 loc) · 7.24 KB
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
#!/bin/bash
# Upgrade script from Debian 12 (Bookworm) to Debian 13 (Trixie)
# Check that script is not running as root
if [ "$EUID" -eq 0 ]; then
echo "Error: This script should not be run as root"
echo "Please run this script as a normal user"
echo "The script will use 'sudo' when elevated privileges are needed"
exit 1
fi
# Check if running Debian
if [ ! -f /etc/debian_version ]; then
echo "Error: This script requires Debian"
exit 1
fi
debian_version=$(cat /etc/debian_version)
# Check if already on Debian 13/Trixie
if echo "$debian_version" | grep -q "^13\." || grep -q "trixie" /etc/os-release 2>/dev/null; then
echo "Already running Debian 13 (Trixie)"
echo "Current version: $debian_version"
exit 0
fi
# Check if we're on a compatible version for upgrade
if ! echo "$debian_version" | grep -q "^12\." && ! grep -q "bookworm" /etc/os-release 2>/dev/null; then
echo "Error: This upgrade script only supports upgrading from Debian 12 (Bookworm)"
echo "Current version: $debian_version"
echo "Please manually upgrade to Debian 13 (Trixie)"
exit 1
fi
echo "Current Debian version: $debian_version"
echo "This script will upgrade your system from Debian 12 (Bookworm) to Debian 13 (Trixie)"
echo ""
echo "WARNING: This is a major system upgrade that may take considerable time"
echo "and could potentially cause issues if interrupted."
echo ""
echo "Please ensure:"
echo "- You have a stable internet connection"
echo "- Your system has sufficient disk space"
echo "- You have time to complete the upgrade without interruption"
echo ""
echo "Would you like to proceed with the upgrade? [y/N]"
read -r response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
echo "Upgrade cancelled by user"
exit 0
fi
echo "Starting upgrade to Debian 13 (Trixie)..."
# hifiberry-audiocontrol declares Breaks: hifiberry-bluetooth (<< 1.0.6), so
# unpacking a newer audiocontrol over an older bluetooth makes dpkg deconfigure
# bluetooth first. Every hifiberry-bluetooth up to 1.0.8 ships a prerm that
# rejects the deconfigure argument and exits 1, which aborts the transaction
# mid-unpack and leaves the system full of unpacked but unconfigured packages.
# dpkg runs the prerm of the *installed* version, so the archive cannot fix
# this for devices already below 1.0.6 -- upgrading the package on its own
# first is what stops dpkg ever having to deconfigure it. This has to happen
# before any apt upgrade step, not just before the full upgrade: a plain
# "apt upgrade" resolves Breaks by deconfiguring too.
preupgrade_hifiberry_bluetooth() {
local status version
status=$(dpkg-query -W -f='${Status}' hifiberry-bluetooth 2>/dev/null) || return 0
case "$status" in
*" ok installed") ;;
*) return 0 ;;
esac
echo "Upgrading hifiberry-bluetooth ahead of the other packages..."
if ! sudo apt install -y --only-upgrade hifiberry-bluetooth; then
echo WARNING: "Pre-upgrade of hifiberry-bluetooth failed; repairing dpkg state"
sudo dpkg --configure -a || true
fi
version=$(dpkg-query -W -f='${Version}' hifiberry-bluetooth 2>/dev/null || true)
if [ -z "$version" ] || ! dpkg --compare-versions "$version" ge 1.0.6; then
echo WARNING: "hifiberry-bluetooth is ${version:-unknown}, still below 1.0.6 --"
echo WARNING: "the upgrade may abort while dpkg deconfigures it."
fi
}
# Backup sources.list
echo "Backing up current package sources..."
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup.$(date +%Y%m%d_%H%M%S)
# Update sources.list to point to trixie
echo "Updating package sources to Trixie..."
sudo sed -i 's/bookworm/trixie/g' /etc/apt/sources.list
sudo sed -i 's/bookworm/trixie/g' /etc/apt/sources.list.d/*.list 2>/dev/null || true
# Update package lists
echo "Updating package lists..."
if ! sudo apt update; then
echo "Error: Failed to update package lists"
echo "Restoring original sources.list..."
sudo cp /etc/apt/sources.list.backup.* /etc/apt/sources.list 2>/dev/null || true
exit 1
fi
preupgrade_hifiberry_bluetooth
# Perform minimal upgrade first
echo "Performing minimal upgrade..."
if ! sudo apt upgrade -y; then
echo "Error: Minimal upgrade failed"
echo "Please check the errors above and try again"
exit 1
fi
echo ""
echo "Minimal upgrade completed successfully."
echo "A reboot is recommended before continuing with the full distribution upgrade."
echo "This helps resolve library conflicts and ensures a clean upgrade process."
echo ""
echo "Would you like to reboot now and continue the upgrade after reboot? [Y/n]"
read -r reboot_response
if [[ ! "$reboot_response" =~ ^[Nn]$ ]]; then
echo ""
echo "Creating upgrade continuation script..."
cat > ~/continue-trixie-upgrade.sh << 'EOF'
#!/bin/bash
echo "Continuing Debian 13 (Trixie) upgrade after reboot..."
# Perform full distribution upgrade
echo "Performing distribution upgrade..."
echo "This may take a long time and will require user interaction for some packages..."
if ! sudo apt full-upgrade -y; then
echo "ERROR: Distribution upgrade failed"
echo "Please check the errors above and resolve manually"
exit 1
fi
# Clean up
echo "Cleaning up..."
sudo apt autoremove -y
sudo apt autoclean
# Verify upgrade
new_version=$(cat /etc/debian_version)
echo ""
echo "Upgrade completed!"
echo "Current version: $new_version"
echo ""
if echo "$new_version" | grep -q "^13\." || grep -q "trixie" /etc/os-release 2>/dev/null; then
echo "SUCCESS: Successfully upgraded to Debian 13 (Trixie)"
echo ""
echo "You can now run the HiFiBerry OS installation:"
echo " ./install-all"
else
echo "WARNING: Upgrade may not have completed successfully"
echo "Please check your system status manually"
fi
# Clean up this script
rm -f ~/continue-trixie-upgrade.sh
EOF
chmod +x ~/continue-trixie-upgrade.sh
echo "After reboot, run the following command to continue the upgrade:"
echo " ~/continue-trixie-upgrade.sh"
echo ""
echo "Rebooting in 10 seconds... (Press Ctrl+C to cancel)"
sleep 10
sudo reboot
exit 0
fi
# If user chose not to reboot, continue with full upgrade
echo ""
echo "Continuing with full upgrade without reboot..."
# Perform full distribution upgrade
echo "Performing distribution upgrade..."
echo "This may take a long time and will require user interaction for some packages..."
if ! sudo apt full-upgrade -y; then
echo "ERROR: Distribution upgrade failed"
echo "Please check the errors above and resolve manually"
echo "You may need to reboot and try again to resolve library conflicts"
exit 1
fi
# Clean up
echo "Cleaning up..."
sudo apt autoremove -y
sudo apt autoclean
# Verify upgrade
new_version=$(cat /etc/debian_version)
echo ""
echo "Upgrade completed!"
echo "Previous version: $debian_version"
echo "Current version: $new_version"
echo ""
if echo "$new_version" | grep -q "^13\." || grep -q "trixie" /etc/os-release 2>/dev/null; then
echo "SUCCESS: Successfully upgraded to Debian 13 (Trixie)"
echo ""
echo "IMPORTANT: Please reboot your system to complete the upgrade:"
echo " sudo reboot"
echo ""
echo "After reboot, you can run the HiFiBerry OS installation:"
echo " ./install-all"
else
echo "WARNING: Upgrade may not have completed successfully"
echo "Please check your system status manually"
fi