Skip to content
Merged
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
102 changes: 36 additions & 66 deletions system_files/shared/usr/share/ublue-os/just/system.just
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,33 @@ devmode:
[group('System')]
toggle-devmode:
#!/usr/bin/env bash
CURRENT_IMAGE=$(rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"')
if grep -q "/var/ublue-os/image" <<< $CURRENT_IMAGE ; then
bash -c "cat <<EOF
Before we can switch to the Aurora Developer Experience
the current system needs an update. Please run 'ujust update'
and reboot your system when the update is finished
EOF"
exit
fi
if /bin/grep -q "\-dx" <<< $CURRENT_IMAGE ; then
CURRENT_STATE="enabled"
else
CURRENT_STATE="disabled"
fi
echo "Developer mode is currently ${CURRENT_STATE}"
echo "Enable or Disable developer mode"
OPTION=$(gum choose "Enable" "Disable")
if [[ "${OPTION,,}" =~ ^enable ]]; then
if [ "$CURRENT_STATE" = "enabled" ] ; then
echo "You are already on a developer image"
exit 0
fi
echo "Rebasing to a developer image"
NEW_IMAGE=$(sed "s/aurora/aurora-dx/" <<< $CURRENT_IMAGE)
rpm-ostree rebase $NEW_IMAGE
echo -e "\nUse `ujust dx-group` to add your user to the correct groups and complete the installation"
fi
if [[ "${OPTION,,}" =~ ^disable ]]; then
if [ "$CURRENT_STATE" != "enabled" ]; then
echo "You are currently not on a developer image"
exit 0
fi
set -e
IMAGE_INFO_FILE="${IMAGE_INFO_FILE:-/usr/share/ublue-os/image-info.json}"
IMAGE_NAME="$(jq -rc '."image-name"' "${IMAGE_INFO_FILE}")"
IMAGE_REF="$(jq -rc '."image-ref"' "${IMAGE_INFO_FILE}" | sed "s/.*ghcr/ghcr/")"
CURRENT_IMAGE="${IMAGE_REF}:$(jq -rc '."image-tag"' "${IMAGE_INFO_FILE}")"
IMAGE_BASE_NAME="$(cut -f1 -d\- <<< "${IMAGE_NAME}")"
set +e

if grep -q -- "-dx" <<< "${IMAGE_NAME}"; then
gum confirm "Would you like to disable developer mode?" || exit 0
echo "Rebasing to a non developer image"
# Remove -dx suffix from image, specifies ":" to mark the end of the image name
NEW_IMAGE=$(sed "s/\-dx//" <<< $CURRENT_IMAGE)
rpm-ostree rebase $NEW_IMAGE
NEW_IMAGE="$(sed "s/\-dx//" <<< $CURRENT_IMAGE)"
pkexec bootc switch --enforce-container-sigpolicy "${NEW_IMAGE}"
exit 0
fi

gum confirm "Would you like to enable developer mode?" || exit 0
echo "Rebasing to a developer image"
NEW_IMAGE="$(sed "s/${IMAGE_BASE_NAME}/${IMAGE_BASE_NAME}-dx/" <<< "${CURRENT_IMAGE}")"
pkexec bootc switch --enforce-container-sigpolicy "${NEW_IMAGE}"
if gum confirm "Do you want to also install the default development flatpaks?" ; then
ujust install-system-flatpaks 1
ADD_DEVMODE=1 ujust install-system-flatpaks 0 1
fi
if gum confirm "Do you want to install extra fonts?" ; then
ujust install-fonts
if gum confirm "Do you want to install extra monospace fonts?" ; then
brew bundle install --file=/usr/share/ublue-os/homebrew/fonts.Brewfile
fi
echo "Use ujust dx-group to add your user to the correct groups and complete the installation after rebooting into the development image"

# Ptyxis terminal transparency
[group('System')]
Expand Down Expand Up @@ -140,36 +124,22 @@ dx-group:

# Install system flatpaks for rebasers
[group('System')]
install-system-flatpaks $dx="dynamic":
install-system-flatpaks $confirm="1" $dx_only="0":
#!/usr/bin/env bash
TARGET_FLATPAK_FILE="${TARGET_FLATPAK_FILE:-/etc/ublue-os/system-flatpaks.list}"
TARGET_DEVMODE_FILE="${TARGET_DEVMODE_FILE:-/etc/ublue-os/system-flatpaks-dx.list}"
case "$dx" in
"0"|"1")
ADD_DEVMODE="$dx"
;;
"dynamic")
if [[ $(jq '."image-flavor"' /usr/share/ublue-os/image-info.json) =~ dx ]] ; then
ADD_DEVMODE=1
fi
;;
*)
echo "Unsupported option"
exit 1
;;
esac

flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo
# Disable Fedora Flatpak remotes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you intend to delete this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of, I just aligned with bluefins and i think they never had this part.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's fine to remove, we should probably add the fedora flaptak stuff to the alternate installation guide then, so we at least can point to somewhere.

for remote in fedora fedora-testing; do
if flatpak remote-list | grep -q "$remote"; then
flatpak remote-delete "$remote"
fi
done
xargs flatpak --system -y install --reinstall --or-update < $TARGET_FLATPAK_FILE
if [ "$ADD_DEVMODE" == "1" ] ; then
xargs flatpak --system -y install --reinstall --or-update < $TARGET_DEVMODE_FILE
if [[ "$(jq '."image-flavor"' /usr/share/ublue-os/image-info.json)" =~ dx ]] ; then
ADD_DEVMODE="${ADD_DEVMODE:-1}"
fi
if [ "${ADD_DEVMODE:-0}" == "1" ] ; then
if [ "$confirm" != 0 ] ; then
gum confirm "Install development flatpaks?" || exit 0
fi
brew bundle --file="${TARGET_FLATPAK_FILE:-/usr/share/ublue-os/homebrew/system-dx-flatpaks.Brewfile}"
fi
[ "$dx_only" == 1 ] && exit 0
if [ "$confirm" != 0 ] ; then
gum confirm "Install system flatpaks?" || exit 0
fi
brew bundle --file="${TARGET_FLATPAK_FILE:-/usr/share/ublue-os/homebrew/system-flatpaks.Brewfile}"

alias switch-stream := rebase-helper
alias switch-streams := rebase-helper
Expand Down