Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/u/usysconf-epoch/files/epoch.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Perform the epoch transition
After=network-online.target
Wants=network-online.target

[Service]
EnvironmentFile=-/etc/sysconfig/epoch
ExecStart=/usr/lib64/usysconf/epoch.sh
Type=notify

RemainAfterExit=yes
TimeoutStartSec=60s

[Install]
WantedBy=multi-user.target
186 changes: 186 additions & 0 deletions packages/u/usysconf-epoch/files/epoch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob

EPOCH_ENABLE="${EPOCH_ENABLE:=no}"

STATE_DIR="${STATE_DIR:=/var/solus/usr-merge}"
MERGE_FLAG_FILE="${MERGE_FLAG_FILE:=${STATE_DIR}/merge-complete}"

OLD_REPO="https://cdn.getsol.us/repo/shannon/eopkg-index.xml.xz"
NEW_REPO="https://cdn.getsol.us/repo/polaris/eopkg-index.xml.xz"

export LC_ALL=C

declare -A DESKTOP_FLAG_FILES=(
["budgie"]="/usr/bin/budgie-desktop"
["gnome"]="/usr/bin/gnome-shell"
["kde"]="/usr/bin/startplasma-wayland"
["xfce"]="/usr/bin/xfce4-session"
["mate"]="/usr/bin/mate-about"
)
declare -A DESKTOP_SOFTWARE_CENTRE=(
["budgie"]="discover"
["gnome"]="gnome-software"
["kde"]="discover"
["xfce"]="discover"
["mate"]="discover"
)
declare -A SC_DESKTOP_FILES=(
["discover"]="/usr/share/applications/org.kde.discover.desktop"
["gnome-software"]="/usr/share/applications/org.gnome.Software.desktop"
)

function update_repo() {
local repo=""
local active=""
while read -r line
do
if [[ "${repo}" == "" ]]
then
repo="${line% *}"
active="${line##"${repo}" }"
continue
fi

url="${line## }"
if [[ "${url}" == "${OLD_REPO}" ]]
then
echo "Updating repo ${repo} to ${NEW_REPO}"

eopkg add-repo -y "${repo}" "${NEW_REPO}"

if [[ "${active}" == "[inactive]" ]]
then
eopkg disable-repo "${repo}"
fi
fi

repo=""
done <<< "$(eopkg list-repo --no-color)"
}

function is_installed() {
eopkg info --no-color --short "${1}" | grep -P '^\[inst\]' >/dev/null
}

function desktop_name() {
local field

if [[ "$2" != "" ]]
then
field="^Name\[$2\]="
else
field="^Name="
fi

local name
name="$(grep "${field}" "${SC_DESKTOP_FILES[$1]}" | head -n1 || true)"

echo "${name#*=}"
}

function sc_name() {
local name

for lang in "${LANG%.*}" "${LANG%_*}" ""
do
name="$(desktop_name "$1" "${lang}")"
if [[ "${name}" != "" ]]
then
echo "${name}"
return
fi
done
}

function wait_login() {
while true
do
for path in /run/user/*
do
if [[ "$(basename "$path")" -ge 1000 ]]
then
# wait for the login to complete
sleep 10
return
fi
done

sleep 10
done
}

# Based on StackOverflow post by Fabio A.
# See https://stackoverflow.com/a/49533938
function _notify-send() {
local user

for bus in /run/user/*/bus
do
user="$(stat -c '%U' "${bus}")"
sudo -u "${user}" env DBUS_SESSION_BUS_ADDRESS="unix:path=$bus" notify-send "$@"
done
}

if [[ "${EPOCH_ENABLE}" != "yes" ]]
then
echo "Not enabled, refusing to transition"
exit 0
fi

if [[ ! -e "${MERGE_FLAG_FILE}" ]]
then
echo "Not ready: not usr-merged"
exit 1
fi

if [[ "$(readlink /usr/bin/eopkg)" != "eopkg.bin" ]]
then
echo "Not ready: eopkg is not python3"
exit 1
fi

desktop=""
removed_sc=false

# Install appropriate software centre
for d in "${!DESKTOP_FLAG_FILES[@]}"
do
if [[ -e "${DESKTOP_FLAG_FILES[$d]}" ]]
then
desktop="${d}"
break
fi
done

sc_package="${DESKTOP_SOFTWARE_CENTRE[$desktop]}"
echo "Detected desktop: ${desktop}"

if ! is_installed "${sc_package}"
then
echo "Installing new SC: ${sc_package}"
eopkg install --yes-all "${DESKTOP_SOFTWARE_CENTRE[$desktop]}"
fi

if is_installed solus-sc
then
echo "Removing old SC"
eopkg remove --yes-all solus-sc
removed_sc=true
fi

echo "Checking repository"
update_repo

echo "Finished! Welcome to the new epoch."
systemd-notify --ready

if [[ "${removed_sc}" == "true" ]]
then
wait_login
_notify-send --urgency=critical \
--icon=software \
"Solus Software" \
"Software Center is now '$(sc_name "${sc_package}")'" || true
fi
2 changes: 2 additions & 0 deletions packages/u/usysconf-epoch/files/usysconf-epoch.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enable usr-merge.service
enable epoch.service
11 changes: 5 additions & 6 deletions packages/u/usysconf-epoch/package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name : usysconf-epoch
version : 1.0.0
release : 17
release : 18
source :
# We need something for a source
- https://getsol.us/sources/hotspot.txt : a12b7cb43c9d9134b5bb1b35e9096b66775d9e92e7611d1cc92b02edd6782a87
Expand All @@ -12,10 +12,9 @@
description: |
Temporary package for hosting the epoch script
install : |
install -Dm00755 $pkgfiles/usr-merge.sh -t $installdir/usr/lib64/usysconf/
install -Dm00755 -t $installdir/usr/lib64/usysconf/ $pkgfiles/*.sh
install -Dm00644 -t $installdir/%libdir%/systemd/system/ $pkgfiles/*.service

# Systemd units to run this early in the boot
install -Dm00644 $pkgfiles/usr-merge.service -t $installdir/%libdir%/systemd/system/

install -Ddm00755 $installdir/%libdir%/systemd/system/sysinit.target.wants
install -Ddm00755 $installdir/%libdir%/systemd/system/{sysinit,multi-user}.target.wants
ln -srv $installdir/%libdir%/systemd/system/usr-merge.service $installdir/%libdir%/systemd/system/sysinit.target.wants/usr-merge.service
ln -srv $installdir/%libdir%/systemd/system/epoch.service $installdir/%libdir%/systemd/system/multi-user.target.wants/epoch.service
7 changes: 5 additions & 2 deletions packages/u/usysconf-epoch/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
</Description>
<PartOf>system.base</PartOf>
<Files>
<Path fileType="library">/usr/lib64/systemd/system/epoch.service</Path>
<Path fileType="library">/usr/lib64/systemd/system/multi-user.target.wants/epoch.service</Path>
<Path fileType="library">/usr/lib64/systemd/system/sysinit.target.wants/usr-merge.service</Path>
<Path fileType="library">/usr/lib64/systemd/system/usr-merge.service</Path>
<Path fileType="library">/usr/lib64/usysconf/epoch.sh</Path>
<Path fileType="library">/usr/lib64/usysconf/usr-merge.sh</Path>
</Files>
</Package>
<History>
<Update release="17">
<Date>2024-10-22</Date>
<Update release="18">
<Date>2025-10-04</Date>
<Version>1.0.0</Version>
<Comment>Packaging update</Comment>
<Name>Silke Hofstra</Name>
Expand Down