Last active 2 days ago

anduin's Avatar anduin revised this gist 2 days ago. Go to revision

1 file changed, 19 insertions, 10 deletions

ubuntu_to_aos.sh

@@ -159,16 +159,25 @@ cut -d' ' -f1 "$MANIFEST_FILE" \
159 159 if [ ! -s "$PKG_TEMP_FILE" ]; then
160 160 print_ok "No missing packages to install."
161 161 else
162 - print_ok "Installing missing packages from the new release (fast mode)..."
163 - if xargs sudo apt install --no-install-recommends -y < "$PKG_TEMP_FILE"; then
164 - print_ok "Fast mode installation successful."
165 - else
166 - print_warn "Fast mode failed. Retrying one by one (robust mode)..."
167 - while read -r pkg; do
168 - [ -n "$pkg" ] && sudo apt install --no-install-recommends -y "$pkg" || true
169 - done < "$PKG_TEMP_FILE"
170 - print_ok "Robust mode finished."
171 - fi
162 + print_warn "Fast mode failed. Retrying one by one (robust mode)..."
163 + print_ok "This may take 5-10 minutes. Only errors will be displayed."
164 +
165 + PKG_INSTALL_LOG="/tmp/anduinos-pkg-install.log"
166 +
167 + while read -r pkg; do
168 + if [ -n "$pkg" ]; then
169 + if sudo apt install --no-install-recommends -y "$pkg" > "$PKG_INSTALL_LOG" 2>&1; then
170 + : # Bash的 "no-op" (空操作)
171 + else
172 + print_warn "Failed to install package: '$pkg'. Details:"
173 + cat "$PKG_INSTALL_LOG"
174 + echo -e "${Red}-----------------------------------------------------${Font}"
175 + fi
176 + fi
177 + done < "$PKG_TEMP_FILE"
178 +
179 + rm -f "$PKG_INSTALL_LOG"
180 + print_ok "Robust missing package install mode finished."
172 181 fi
173 182 judge "Install missing packages"
174 183

anduin's Avatar anduin revised this gist 2 days ago. Go to revision

1 file changed, 25 insertions, 33 deletions

ubuntu_to_aos.sh

@@ -1,14 +1,11 @@
1 1 #!/bin/bash
2 - #==========================
3 - # Set up the environment
4 - #==========================
5 - set -e # exit on error
6 - set -o pipefail # exit on pipeline error
7 - set -u # treat unset variable as error
8 -
9 - #==========================
10 - # Color
11 - #==========================
2 + set -e
3 + set -o pipefail
4 + set -u
5 +
6 + PKG_TEMP_FILE=$(mktemp)
7 + trap 'rm -f "$PKG_TEMP_FILE"' EXIT
8 +
12 9 Green="\033[32m"
13 10 Red="\033[31m"
14 11 Yellow="\033[33m"
@@ -20,9 +17,6 @@ OK="${Green}[ OK ]${Font}"
20 17 ERROR="${Red}[FAILED]${Font}"
21 18 WARNING="${Yellow}[ WARN ]${Font}"
22 19
23 - #==========================
24 - # Print Colorful Text
25 - #==========================
26 20 function print_ok() {
27 21 echo -e "${OK} ${Blue} $1 ${Font}"
28 22 }
@@ -35,9 +29,6 @@ function print_warn() {
35 29 echo -e "${WARNING} ${Yellow} $1 ${Font}"
36 30 }
37 31
38 - #==========================
39 - # Judge function
40 - #==========================
41 32 function judge() {
42 33 if [[ 0 -eq $? ]]; then
43 34 print_ok "$1 succeeded"
@@ -47,12 +38,7 @@ function judge() {
47 38 exit 1
48 39 fi
49 40 }
50 - #==========================
51 -
52 - # Clean up function
53 - #==========================
54 41 function clean_up() {
55 - # Clean up
56 42 print_ok "Cleaning up old files..."
57 43 sudo umount /mnt/anduinos_squashfs >/dev/null 2>&1 || true
58 44 sudo umount /mnt/anduinos_iso >/dev/null 2>&1 || true
@@ -82,7 +68,6 @@ print_ok "Installing required packages (aria2, curl, lsb-release)..."
82 68 sudo apt install -y aria2 curl lsb-release
83 69 judge "Install required packages"
84 70
85 - # $LANG maybe en_US.UTF-8, so we use only the `en_US` part
86 71 CURRENT_LANG=${LANG%%.*}
87 72 DOWNLOAD_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}.torrent"
88 73 HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}.sha256"
@@ -90,14 +75,12 @@ HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-${CURRENT_LANG}
90 75 print_ok "Current system language detected: ${CURRENT_LANG}"
91 76 print_ok "Attempting to download with URL: ${DOWNLOAD_URL}"
92 77
93 - # If download URL is not reachable, fallback to en_US
94 78 if ! curl --head --silent --fail "$DOWNLOAD_URL" >/dev/null; then
95 79 print_warn "Language pack for ${CURRENT_LANG} not found, falling back to en_US"
96 80 DOWNLOAD_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-en_US.torrent"
97 81 HASH_URL="https://download.anduinos.com/1.4/1.4.0/AnduinOS-1.4.0-en_US.sha256"
98 82 fi
99 83
100 - # Ensure download URL is reachable
101 84 if ! curl --head --silent --fail "$DOWNLOAD_URL" >/dev/null; then
102 85 print_error "Download URL is not reachable. Please check your network connection."
103 86 exit 1
@@ -154,32 +137,41 @@ curl -s https://gitlab.aiursoft.cn/anduin/init-server/-/raw/master/mirror.sh?ref
154 137 sudo apt update
155 138 judge "Update package mirrors"
156 139
157 - # Reset apt settings
158 140 print_ok "Resetting APT configuration files..."
159 141 sudo rm /etc/apt/preferences.d/* >/dev/null 2>&1 || true
160 142 judge "Reset APT configuration files"
161 143
162 - # Add Mozilla Team PPA
163 144 print_ok "Updating Mozilla Team PPA..."
164 145 sudo rm -f /etc/apt/sources.list.d/mozillateam*
165 146 sudo rsync -Aax /mnt/anduinos_squashfs/etc/apt/sources.list.d/mozillateam* /etc/apt/sources.list.d/
166 147 sudo apt update
167 148 judge "Update Mozilla Team PPA"
168 149
169 - # Install missing package.
170 - print_ok "Installing missing packages from the new release..."
150 + print_ok "Generating package list for upgrade..."
171 151 MANIFEST_FILE="/mnt/anduinos_iso/casper/filesystem.manifest-desktop"
152 +
172 153 cut -d' ' -f1 "$MANIFEST_FILE" \
173 154 | grep -v '^linux-' \
174 155 | grep -v '^lib' \
175 156 | grep -v '^plymouth-' \
176 - | grep -v '^software-properties-' \
177 - | while read -r pkg; do
178 - [ -n "$pkg" ] && sudo apt install --no-install-recommends -y "$pkg" || true
179 - done
157 + | grep -v '^software-properties-' > "$PKG_TEMP_FILE"
158 +
159 + if [ ! -s "$PKG_TEMP_FILE" ]; then
160 + print_ok "No missing packages to install."
161 + else
162 + print_ok "Installing missing packages from the new release (fast mode)..."
163 + if xargs sudo apt install --no-install-recommends -y < "$PKG_TEMP_FILE"; then
164 + print_ok "Fast mode installation successful."
165 + else
166 + print_warn "Fast mode failed. Retrying one by one (robust mode)..."
167 + while read -r pkg; do
168 + [ -n "$pkg" ] && sudo apt install --no-install-recommends -y "$pkg" || true
169 + done < "$PKG_TEMP_FILE"
170 + print_ok "Robust mode finished."
171 + fi
172 + fi
180 173 judge "Install missing packages"
181 174
182 - # Remove obsolete packages.
183 175 print_ok "Removing obsolete packages..."
184 176 sudo apt autoremove -y \
185 177 distro-info \

anduin's Avatar anduin revised this gist 2 days ago. Go to revision

1 file changed, 1 insertion, 1 deletion

ubuntu_to_aos.sh

@@ -175,7 +175,7 @@ cut -d' ' -f1 "$MANIFEST_FILE" \
175 175 | grep -v '^plymouth-' \
176 176 | grep -v '^software-properties-' \
177 177 | while read -r pkg; do
178 - [ -n "$pkg" ] && sudo apt install -y "$pkg" || true
178 + [ -n "$pkg" ] && sudo apt install --no-install-recommends -y "$pkg" || true
179 179 done
180 180 judge "Install missing packages"
181 181

anduin's Avatar anduin revised this gist 2 days ago. Go to revision

1 file changed, 3 insertions, 1 deletion

ubuntu_to_aos.sh

@@ -174,7 +174,9 @@ cut -d' ' -f1 "$MANIFEST_FILE" \
174 174 | grep -v '^lib' \
175 175 | grep -v '^plymouth-' \
176 176 | grep -v '^software-properties-' \
177 - | xargs sudo apt install -y
177 + | while read -r pkg; do
178 + [ -n "$pkg" ] && sudo apt install -y "$pkg" || true
179 + done
178 180 judge "Install missing packages"
179 181
180 182 # Remove obsolete packages.

anduin's Avatar anduin revised this gist 2 days ago. Go to revision

1 file changed, 2 insertions, 1 deletion

ubuntu_to_aos.sh

@@ -163,6 +163,7 @@ judge "Reset APT configuration files"
163 163 print_ok "Updating Mozilla Team PPA..."
164 164 sudo rm -f /etc/apt/sources.list.d/mozillateam*
165 165 sudo rsync -Aax /mnt/anduinos_squashfs/etc/apt/sources.list.d/mozillateam* /etc/apt/sources.list.d/
166 + sudo apt update
166 167 judge "Update Mozilla Team PPA"
167 168
168 169 # Install missing package.
@@ -271,4 +272,4 @@ judge "Apply dconf settings patch"
271 272 print_ok "Upgrade completed! Please reboot your system to apply all changes."
272 273
273 274 print_ok "Starting cleanup..."
274 - clean_up
275 + clean_up

anduin's Avatar anduin revised this gist 3 days ago. Go to revision

1 file changed, 17 insertions, 12 deletions

ubuntu_to_aos.sh

@@ -72,6 +72,12 @@ if [[ "$codename" != "questing" ]] then
72 72 fi
73 73 judge "System compatibility check"
74 74
75 + print_ok "Ensure current user is not root..."
76 + if [[ "$(id -u)" -eq 0 ]]; then
77 + print_error "This script must not be run as root. Please run as a normal user with sudo privileges."
78 + exit 1
79 + fi
80 +
75 81 print_ok "Installing required packages (aria2, curl, lsb-release)..."
76 82 sudo apt install -y aria2 curl lsb-release
77 83 judge "Install required packages"
@@ -167,7 +173,7 @@ cut -d' ' -f1 "$MANIFEST_FILE" \
167 173 | grep -v '^lib' \
168 174 | grep -v '^plymouth-' \
169 175 | grep -v '^software-properties-' \
170 - | xargs sudo apt install -y # <-- 让 xargs 自己调用 apt
176 + | xargs sudo apt install -y
171 177 judge "Install missing packages"
172 178
173 179 # Remove obsolete packages.
@@ -226,6 +232,10 @@ print_ok "Upgrading pixmaps..."
226 232 sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/pixmaps/ /usr/share/pixmaps/
227 233 judge "Upgrade pixmaps"
228 234
235 + print_ok "Upgrading /etc/skel/ files..."
236 + sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/etc/skel/ /etc/skel/
237 + judge "Upgrade /etc/skel/ files"
238 +
229 239 print_ok "Upgrading python-apt templates and distro info..."
230 240 sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/python-apt/templates/ /usr/share/python-apt/templates/
231 241 sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/distro-info/ /usr/share/distro-info/
@@ -247,20 +257,15 @@ sudo rsync -Aax /mnt/anduinos_squashfs/etc/os-release /etc/os-release
247 257 sudo rsync -Aax /mnt/anduinos_squashfs/usr/lib/os-release /usr/lib/os-release
248 258 sudo rsync -Aax /mnt/anduinos_squashfs/etc/legal /etc/legal
249 259 sudo rsync -Aax /mnt/anduinos_squashfs/etc/sysctl.d/20-apparmor-donotrestrict.conf /etc/sysctl.d/20-apparmor-donotrestrict.conf
260 + sudo rsync -Aax /mnt/anduinos_squashfs/var/lib/flatpak/repo/config /var/lib/flatpak/repo/config
261 + sudo rsync -Aax /mnt/anduinos_squashfs/usr/share/plymouth/themes/spinner/bgrt-fallback.png /usr/share/plymouth/themes/spinner/bgrt-fallback.png
262 + sudo rsync -Aax /mnt/anduinos_squashfs/usr/share/plymouth/themes/spinner/watermark.png /usr/share/plymouth/themes/spinner/watermark.png
263 + sudo rsync -Aax /mnt/anduinos_squashfs/usr/share/plymouth/ubuntu-logo.png /usr/share/plymouth/ubuntu-logo.png
250 264 judge "Update system version information"
251 265
252 266 print_ok "Applying dconf settings patch..."
253 - VERSION=$(grep -oP "VERSION_ID=\"\\K\\d+\\.\\d+" /etc/os-release)
254 - PATCH_URL="https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/$VERSION/src/mods/35-dconf-patch/dconf.ini?ref_type=heads"
255 - COMMAND_TO_RUN="set -o pipefail; curl -sL '$PATCH_URL' | dconf load /org/gnome/"
256 - if [[ -n "${SUDO_USER-}" ]]; then
257 - print_ok "Applying dconf patch for user: $SUDO_USER"
258 - sudo -u "$SUDO_USER" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u $SUDO_USER)/bus" \
259 - bash -c "$COMMAND_TO_RUN"
260 - else
261 - print_warn "Running as root without sudo context. Skipping user dconf patch."
262 - true
263 - fi
267 + PATCH_URL="https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/1.4/src/mods/35-dconf-patch/dconf.ini?ref_type=heads"
268 + curl -sL "$PATCH_URL" | dconf load /org/gnome/
264 269 judge "Apply dconf settings patch"
265 270
266 271 print_ok "Upgrade completed! Please reboot your system to apply all changes."

anduin's Avatar anduin revised this gist 6 days ago. Go to revision

1 file changed, 10 insertions

ubuntu_to_aos.sh

@@ -199,6 +199,16 @@ print_ok "Upgrading GNOME Shell extensions..."
199 199 sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/gnome-shell/extensions/ /usr/share/gnome-shell/extensions/
200 200 judge "Upgrade GNOME Shell extensions"
201 201
202 + print_ok "Upgrading icon and theme files..."
203 + sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/icons/ /usr/share/icons/
204 + sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/usr/share/themes/ /usr/share/themes/
205 + judge "Upgrade icon and theme files"
206 +
207 + print_ok "Upgrading desktop backgrounds..."
208 + sudo rsync -Aax --update /mnt/anduinos_squashfs/usr/share/backgrounds/ /usr/share/backgrounds/
209 + sudo rsync -Aax --update /mnt/anduinos_squashfs/usr/share/gnome-background-properties/ /usr/share/gnome-background-properties/
210 + judge "Upgrade desktop backgrounds"
211 +
202 212 print_ok "Upgrading APT configuration files..."
203 213 sudo rsync -Aax --update --delete /mnt/anduinos_squashfs/etc/apt/apt.conf.d/ /etc/apt/apt.conf.d/
204 214 judge "Upgrade APT configuration files"

anduin's Avatar anduin revised this gist 6 days ago. Go to revision

1 file changed, 4 insertions, 4 deletions

ubuntu_to_aos.sh

@@ -242,14 +242,14 @@ judge "Update system version information"
242 242 print_ok "Applying dconf settings patch..."
243 243 VERSION=$(grep -oP "VERSION_ID=\"\\K\\d+\\.\\d+" /etc/os-release)
244 244 PATCH_URL="https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/$VERSION/src/mods/35-dconf-patch/dconf.ini?ref_type=heads"
245 -
246 245 COMMAND_TO_RUN="set -o pipefail; curl -sL '$PATCH_URL' | dconf load /org/gnome/"
247 -
248 - if [[ -n "$SUDO_USER" ]]; then
246 + if [[ -n "${SUDO_USER-}" ]]; then
247 + print_ok "Applying dconf patch for user: $SUDO_USER"
249 248 sudo -u "$SUDO_USER" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u $SUDO_USER)/bus" \
250 249 bash -c "$COMMAND_TO_RUN"
251 250 else
252 - bash -c "$COMMAND_TO_RUN"
251 + print_warn "Running as root without sudo context. Skipping user dconf patch."
252 + true
253 253 fi
254 254 judge "Apply dconf settings patch"
255 255

anduin's Avatar anduin revised this gist 6 days ago. Go to revision

1 file changed, 4 insertions, 2 deletions

ubuntu_to_aos.sh

@@ -243,11 +243,13 @@ print_ok "Applying dconf settings patch..."
243 243 VERSION=$(grep -oP "VERSION_ID=\"\\K\\d+\\.\\d+" /etc/os-release)
244 244 PATCH_URL="https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/$VERSION/src/mods/35-dconf-patch/dconf.ini?ref_type=heads"
245 245
246 + COMMAND_TO_RUN="set -o pipefail; curl -sL '$PATCH_URL' | dconf load /org/gnome/"
247 +
246 248 if [[ -n "$SUDO_USER" ]]; then
247 249 sudo -u "$SUDO_USER" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u $SUDO_USER)/bus" \
248 - bash -c "curl -sL '$PATCH_URL' | dconf load /org/gnome/"
250 + bash -c "$COMMAND_TO_RUN"
249 251 else
250 - bash -c "curl -sL '$PATCH_URL' | dconf load /org/gnome/"
252 + bash -c "$COMMAND_TO_RUN"
251 253 fi
252 254 judge "Apply dconf settings patch"
253 255

anduin's Avatar anduin revised this gist 6 days ago. Go to revision

1 file changed, 5 deletions

ubuntu_to_aos.sh

@@ -5,11 +5,6 @@
5 5 set -e # exit on error
6 6 set -o pipefail # exit on pipeline error
7 7 set -u # treat unset variable as error
8 - export DEBIAN_FRONTEND=noninteractive
9 - export LATEST_VERSION="1.1.10"
10 - export CODE_NAME="noble"
11 - export OS_ID="AnduinOS"
12 - export CURRENT_VERSION=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f 2)
13 8
14 9 #==========================
15 10 # Color
Newer Older