Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.raw
*.img
*.erofs
43 changes: 43 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,46 @@ tree IMAGE="localhost/bluefin-common:latest":
podman run --rm tree-temp
rm TreeContainerfile
podman rmi tree-temp

overlay $BLUEFIN_MERGE="1" $SOURCE="dir":
#!/usr/bin/env bash
ROOTFS_DIR="$(mktemp -d --tmpdir="${ROOTFS_BASE:-/tmp}")"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The script should be configured to exit immediately if any command fails. Without this, an error in one of the steps (e.g., crane export failing) would be ignored, and the script would continue executing, potentially resulting in a corrupt or incomplete image. Adding set -euo pipefail is a best practice for writing robust shell scripts.

  • set -e: Exits the script if any command fails.
  • set -u: Treats unset variables as an error.
  • set -o pipefail: Ensures that a pipeline's exit code is the exit code of the last command to exit with a non-zero status, which is crucial for the crane | tar command on line 42.
    set -euo pipefail
    ROOTFS_DIR="$(mktemp -d --tmpdir="${ROOTFS_BASE:-/tmp}")"

trap 'rm -rf "${ROOTFS_DIR}"' EXIT
NAME_TRIMMED=bfincommon

if [ "$SOURCE" == "dir" ] ; then
cp -a ./system_files/shared/. "${ROOTFS_DIR}"
if [ "${BLUEFIN_MERGE}" == "1" ] ; then
cp -a ./system_files/bluefin/. "${ROOTFS_DIR}"
fi
elif [ "$SOURCE" == "image" ] ; then
podman export "$(podman create ghcr.io/projectbluefin/common:latest)" -o - | tar -xvf - -C "${ROOTFS_DIR}"
fi

install -d -m0755 "${ROOTFS_DIR}/usr/lib/extension-release.d"
tee "${ROOTFS_DIR}/usr/lib/extension-release.d/extension-release.${NAME_TRIMMED}" <<EOF
ID="_any"
ARCHITECTURE="$(sed 's/_/-/g' <<< "$(arch)")"
EOF

if [ -e "${ROOTFS_DIR}/system_files" ] ; then
cp -a "${ROOTFS_DIR}/system_files/shared/." "${ROOTFS_DIR}"
if [ "${BLUEFIN_MERGE}" == "1" ] ; then
cp -a "${ROOTFS_DIR}/system_files/bluefin/." "${ROOTFS_DIR}"
fi
rm -r "${ROOTFS_DIR}/system_files"
fi

if [ -d "${ROOTFS_DIR}/etc" ] ; then
mv --no-clobber "${ROOTFS_DIR}/etc" "${ROOTFS_DIR}/usr/etc"
fi
Comment on lines +66 to +68
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The mv command used here is incorrect if ${ROOTFS_DIR}/usr/etc already exists. It would move the etc directory inside usr/etc, creating ${ROOTFS_DIR}/usr/etc/etc, which is not the intended behavior.

To correctly merge the contents of ${ROOTFS_DIR}/etc into ${ROOTFS_DIR}/usr/etc, it's better to use cp to copy the contents and then rm to delete the source directory. This ensures the directory structure is correct.

    if [ -d "${ROOTFS_DIR}/etc" ] ; then
        install -d "${ROOTFS_DIR}/usr/etc"
        cp -a "${ROOTFS_DIR}/etc/." "${ROOTFS_DIR}/usr/etc/"
        rm -rf "${ROOTFS_DIR}/etc"
    fi


for dir in "var" "run"; do
if [ -d "${ROOTFS_DIR}"/"${dir}" ] ; then
rm -r "${ROOTFS_DIR:?}/${dir}"
fi
done
filecontexts="/etc/selinux/targeted/contexts/files/file_contexts"
sudo setfiles -r "${ROOTFS_DIR}" "${filecontexts}" "${ROOTFS_DIR}"
sudo chcon --user=system_u --recursive "${ROOTFS_DIR}"
mkfs.erofs "${NAME_TRIMMED}.raw" "${ROOTFS_DIR}"
1 change: 1 addition & 0 deletions system_files/bluefin/usr/share/ublue-os/just/00-entry.just
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ _default:
ujust --list --list-heading $'Available commands:\n' --list-prefix $' - '

# Imports

import "/usr/share/ublue-os/just/apps.just"
import "/usr/share/ublue-os/just/changelog.just"
import "/usr/share/ublue-os/just/default.just"
Expand Down
1 change: 1 addition & 0 deletions system_files/bluefin/usr/share/ublue-os/just/system.just
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ install-system-flatpaks $confirm="1" $dx_only="0":
brew bundle --file="${TARGET_FLATPAK_FILE:-/usr/share/ublue-os/homebrew/system-flatpaks.Brewfile}"

# Install default system flatpaks (alias for install-system-flatpaks)

# For additional applications, use: ujust bbrew
[group('System')]
bluefin-apps:
Expand Down
1 change: 0 additions & 1 deletion system_files/shared/usr/share/ublue-os/just/apps.just
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ install-jetbrains-toolbox:
brew tap ublue-os/homebrew-tap
brew install --cask jetbrains-toolbox-linux


# Install OpenTabletDriver, an open source, cross-platform, user-mode tablet driver
[group('Apps')]
install-opentabletdriver:
Expand Down
Loading