More fixes for update

This commit is contained in:
2026-10-19 14:01:00 -06:00
parent a65f07c22e
commit f10463b89c
5 changed files with 37 additions and 10 deletions
+5 -5
View File
@@ -48,16 +48,16 @@ else
git clone https://gitea.federated.computer/david/coredesktop.git ~/.local/share/coredesktop
fi
# Install the refresh and update management scripts to the user's bin
mkdir -p ~/.local/bin
sudo cp ~/.local/share/coredesktop/refresh ~/.local/bin/refresh
sudo cp ~/.local/share/coredesktop/update ~/.local/bin/update
cd ~/.local/share/coredesktop
# Source utility functions (provides install_packages and other helpers)
source utils.sh
# Install the refresh and update management scripts to the user's bin
mkdir -p ~/.local/bin
install_script ~/.local/share/coredesktop/refresh ~/.local/bin/refresh
install_script ~/.local/share/coredesktop/update ~/.local/bin/update
# Source the package list (defines SYSTEM_UTILS, DEV_TOOLS, DESKTOP, etc. arrays)
if [ ! -f "packages.conf" ]; then
echo "Error: packages.conf not found!"
+6
View File
@@ -1,5 +1,9 @@
#!/bin/bash
# Wrapped in { ...; exit; } so bash reads the whole script up front; install.sh
# replaces this file while it runs.
{
# Print the logo
print_logo() {
cat << "EOF"
@@ -21,3 +25,5 @@ clear
print_logo
bash ~/.local/share/coredesktop/install.sh
exit
}
+15 -3
View File
@@ -1,5 +1,16 @@
#!/bin/bash
# The whole script is wrapped in { ...; exit; } so bash parses all of it before
# running anything. That way, replacing this file mid-run (e.g. by git pull and
# the copy below) can't make the running copy read a mix of old and new text.
{
# Install a script atomically (copy to a temp file, then rename over the target)
install_script() {
local tmp
tmp="$(mktemp "$2.XXXXXX")" && cp "$1" "$tmp" && chmod 755 "$tmp" && mv -f "$tmp" "$2"
}
# Print the logo
print_logo() {
cat << "EOF"
@@ -28,9 +39,8 @@ if [[ -z "$UPDATE_REEXECED" ]] && ! git -C "$COREDESKTOP" pull; then
export UPDATE_PULL_FAILED=1
fi
mkdir -p "$COREDESKTOP/updates.d"
# --remove-destination replaces copies left root-owned by older versions of this script
cp --remove-destination "$COREDESKTOP/update" ~/.local/bin/update
cp --remove-destination "$COREDESKTOP/refresh" ~/.local/bin/refresh
install_script "$COREDESKTOP/update" ~/.local/bin/update
install_script "$COREDESKTOP/refresh" ~/.local/bin/refresh
if [[ -z "$UPDATE_REEXECED" ]]; then
export UPDATE_REEXECED=1
@@ -63,3 +73,5 @@ if (( ${#FAILED[@]} > 0 )); then
fi
echo "Done."
exit 0
}
+4 -2
View File
@@ -2,14 +2,16 @@
COREDESKTOP="$HOME/.local/share/coredesktop"
source "$COREDESKTOP/utils.sh"
if [ -f ~/.local/bin/coreupdate ]; then
echo "Migrating coreupdate -> update..."
cp --remove-destination "$COREDESKTOP/update" ~/.local/bin/update
install_script "$COREDESKTOP/update" ~/.local/bin/update
sudo rm -f ~/.local/bin/coreupdate
fi
if [ -f ~/.local/bin/corerefresh ]; then
echo "Migrating corerefresh -> refresh..."
cp --remove-destination "$COREDESKTOP/refresh" ~/.local/bin/refresh
install_script "$COREDESKTOP/refresh" ~/.local/bin/refresh
sudo rm -f ~/.local/bin/corerefresh
fi
+7
View File
@@ -72,3 +72,10 @@ enable_services() {
fi
done
}
# Install a script atomically (copy to a temp file, then rename over the target)
# so a copy of it that is running right now keeps reading the old file
install_script() {
local tmp
tmp="$(mktemp "$2.XXXXXX")" && cp "$1" "$tmp" && chmod 755 "$tmp" && mv -f "$tmp" "$2"
}