Skip to content

Commit

Permalink
feat(core): add base image to /etc/ubo_base_image and about page
Browse files Browse the repository at this point in the history
  • Loading branch information
sassanh committed Aug 20, 2024
1 parent 94b9d82 commit a40c3e6
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 10 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/integration_delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,18 @@ jobs:
- name: Generate Image URL and Checksum
id: generate-image-url
run: |
SUFFIX=""
if [ -n "${{ matrix.suffix }}" ]; then
SUFFIX="_${{ matrix.suffix }}"
else
SUFFIX="${{ matrix.suffix }}"
fi
DASHED_SUFFIX=$(echo $SUFFIX | sed 's/_/-/g')
IMAGE_URL="https://downloads.raspberrypi.com/raspios${SUFFIX}_arm64/images/raspios${SUFFIX}_arm64-2024-07-04/2024-07-04-raspios-bookworm-arm64${DASHED_SUFFIX}.img.xz"
IMAGE_NAME="2024-07-04-raspios-bookworm-arm64${DASHED_SUFFIX}"
IMAGE_URL="https://downloads.raspberrypi.com/raspios${SUFFIX}_arm64/images/raspios${SUFFIX}_arm64-2024-07-04/${IMAGE_NAME}.img.xz"
CHECKSUM_URL="${IMAGE_URL}.sha256"
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
echo "dashed_suffix=$DASHED_SUFFIX" >> "$GITHUB_OUTPUT"
echo "image_url=$IMAGE_URL" >> "$GITHUB_OUTPUT"
echo "image_name=$IMAGE_NAME" >> "$GITHUB_OUTPUT"
echo "image_checksum_url=$CHECKSUM_URL" >> "$GITHUB_OUTPUT"
IMAGE_SIZE_GB=${{ matrix.suffix == 'lite' && '4.25' || matrix.suffix == '' && '6.5' || '13' }}
IMAGE_SIZE=$(awk -v IMAGE_SIZE_GB=$IMAGE_SIZE_GB 'BEGIN {printf "%.0f", IMAGE_SIZE_GB * 1024 ^ 3}')
Expand All @@ -384,6 +385,7 @@ jobs:
env:
PKR_VAR_ubo_app_version: ${{ needs.build.outputs.version }}
PKR_VAR_image_url: ${{ steps.generate-image-url.outputs.image_url }}
PKR_VAR_image_name: ${{ steps.generate-image-url.outputs.image_name }}
PKR_VAR_image_checksum_url:
${{ steps.generate-image-url.outputs.image_checksum_url }}
PKR_VAR_target_image_size:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 0.15.8

- fix(wifi): improve the logic of wifi onboarding notification
- feat(core): add base image to `/etc/ubo_base_image` and about page

## Version 0.15.7

Expand Down
5 changes: 5 additions & 0 deletions scripts/packer/image.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ variable "image_url" {
type = string
}

variable "image_name" {
type = string
}

variable "image_checksum_url" {
type = string
}
Expand Down Expand Up @@ -69,6 +73,7 @@ build {

provisioner "shell" {
inline = [
"echo \"${var.image_name}\" > /etc/ubo_base_image",
"chmod +x /install.sh",
"/install.sh --in-packer --with-docker --source=/ubo_app-${var.ubo_app_version}-py3-none-any.whl",
"rm /install.sh /ubo_app-${var.ubo_app_version}-py3-none-any.whl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
}
],
"placeholder": null,
"sub_heading": "A universal dashboard for your Raspberry Pi",
"sub_heading": "Base image: [unknown]\n",
"title": "About"
}
}
Expand Down Expand Up @@ -280,6 +280,7 @@
"icons": []
},
"update_manager": {
"base_image_variant": "[unknown]",
"current_version": "0.0.0",
"is_update_service_active": false,
"latest_version": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
}
],
"placeholder": null,
"sub_heading": "A universal dashboard for your Raspberry Pi",
"sub_heading": "Base image: [unknown]\n",
"title": "About"
}
}
Expand Down Expand Up @@ -280,6 +280,7 @@
"icons": []
},
"update_manager": {
"base_image_variant": "[unknown]",
"current_version": "0.0.0",
"is_update_service_active": false,
"latest_version": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
}
],
"placeholder": null,
"sub_heading": "A universal dashboard for your Raspberry Pi",
"sub_heading": "Base image: [unknown]\n",
"title": "About"
}
}
Expand Down Expand Up @@ -752,6 +752,7 @@
]
},
"update_manager": {
"base_image_variant": "[unknown]",
"current_version": "0.0.0",
"is_update_service_active": false,
"latest_version": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
}
],
"placeholder": null,
"sub_heading": "A universal dashboard for your Raspberry Pi",
"sub_heading": "Base image: [unknown]\n",
"title": "About"
}
}
Expand Down Expand Up @@ -752,6 +752,7 @@
]
},
"update_manager": {
"base_image_variant": "[unknown]",
"current_version": "0.0.0",
"is_update_service_active": false,
"latest_version": "0.0.0",
Expand Down
5 changes: 5 additions & 0 deletions ubo_app/services/030-wifi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ async def init_service() -> None:
options=AutorunOptions(default_value=None),
)
def check_onboarding(is_connected: bool | None) -> None:
try:
_ = check_onboarding
except NameError:
return

if is_connected is False and not read_from_persistent_store(
key='wifi_has_visited_onboarding',
default=False,
Expand Down
8 changes: 6 additions & 2 deletions ubo_app/store/core/_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
NotificationDisplayType,
NotificationsDisplayEvent,
)
from ubo_app.store.update_manager.utils import CURRENT_VERSION, about_menu_items
from ubo_app.store.update_manager.utils import (
BASE_IMAGE,
CURRENT_VERSION,
about_menu_items,
)

if TYPE_CHECKING:
from collections.abc import Sequence
Expand Down Expand Up @@ -80,7 +84,7 @@
sub_menu=HeadedMenu(
title='About',
heading=f'Ubo v{CURRENT_VERSION}',
sub_heading='A universal dashboard for your Raspberry Pi',
sub_heading=f'Base image: {BASE_IMAGE[:11]}\n{BASE_IMAGE[11:]}',
items=about_menu_items,
),
),
Expand Down
4 changes: 3 additions & 1 deletion ubo_app/store/update_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class UpdateManagerAction(BaseAction): ...

class UpdateManagerSetVersionsAction(UpdateManagerAction):
flash_notification: bool
latest_version: str
current_version: str
base_image_variant: str
latest_version: str
serial_number: str


Expand Down Expand Up @@ -51,6 +52,7 @@ class UpdateManagerState(Immutable):

serial_number: str | None = None
current_version: str | None = None
base_image_variant: str | None = None
latest_version: str | None = None
update_status: UpdateStatus = UpdateStatus.CHECKING
is_update_service_active: bool = False
1 change: 1 addition & 0 deletions ubo_app/store/update_manager/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def reducer(
state = replace(
state,
current_version=action.current_version,
base_image_variant=action.base_image_variant,
latest_version=action.latest_version,
serial_number=action.serial_number,
)
Expand Down
18 changes: 18 additions & 0 deletions ubo_app/store/update_manager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@
UpdateManagerState,
UpdateStatus,
)
from ubo_app.utils import IS_RPI
from ubo_app.utils.eeprom import read_serial_number

CURRENT_VERSION = importlib.metadata.version('ubo_app')
if IS_RPI:
try:
BASE_IMAGE = Path('/etc/ubo_base_image').read_text()
except FileNotFoundError:
BASE_IMAGE = '[unknown]'
else:
BASE_IMAGE = '[unknown]'
BASE_IMAGE_VARIANT = (
BASE_IMAGE == '[unknown]'
and '[unknown]'
or BASE_IMAGE.endswith('-lite')
and 'lite'
or BASE_IMAGE.endswith('-full')
and 'full'
or 'desktop'
)


async def check_version() -> None:
Expand Down Expand Up @@ -67,6 +84,7 @@ async def check_version() -> None:
flash_notification=state is None
or state.main.path[:2] != ['main', 'about'],
current_version=CURRENT_VERSION,
base_image_variant=BASE_IMAGE_VARIANT,
latest_version=latest_version,
serial_number=serial_number,
),
Expand Down

0 comments on commit a40c3e6

Please sign in to comment.