Skip to content

Commit

Permalink
feat(package): add an instruction to install flatpak apps
Browse files Browse the repository at this point in the history
  • Loading branch information
yunielrc committed Sep 14, 2023
1 parent d2445da commit b94a556
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Vedvfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ COPY tools/install-run-manjaro tools
COPY tools/install-dev-manjaro.vedv tools

RUN tools/install-run-manjaro && tools/install-dev-manjaro.vedv
# install gnome base system
RUN sudo -H flatpak install --assumeyes --noninteractive io.github.andreibachim.shortcut

COPY . .
21 changes: 21 additions & 0 deletions src/usr/lib/ydf/components/package/ydf-package-service.bash
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,27 @@ ydf::package_service::__instruction_@yay() {
sudo yay -Syu --noconfirm --needed "${yay_pkg_name:-"$pkg_name"}"
}

#
# Execute @flatpak instruction
#
# Arguments:
# pkg_name string package name
#
# Returns:
# 0 on success, non-zero on error.
#
ydf::package_service::__instruction_@flatpak() {
if [[ ! -f ./@flatpak ]]; then
return 0
fi

local -r pkg_name="$1"
# select the first no empty line
local -r flatpak_pkg_name="$(ydf::utils::print_1line <@flatpak)"

sudo -H flatpak install --assumeyes --noninteractive flathub "${flatpak_pkg_name:-"$pkg_name"}"
}

#
# Install a ydotfile package from a directory
#
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/packages/7micenter@flathub/@flatpak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.missioncenter.MissionCenter
1 change: 1 addition & 0 deletions tests/fixtures/packages/7micenter@flathub/@pacman
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '7micenter@flathub: @pacman succeed'
1 change: 1 addition & 0 deletions tests/fixtures/packages/7micenter@flathub/@yay
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '7micenter@flathub: @yay succeed'
1 change: 1 addition & 0 deletions tests/fixtures/packages/7micenter@flathub/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '7micenter@flathub: install succeed'
1 change: 1 addition & 0 deletions tests/fixtures/packages/7micenter@flathub/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '7micenter@flathub: postinstall succeed'
1 change: 1 addition & 0 deletions tests/fixtures/packages/7micenter@flathub/preinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '7micenter@flathub: preinstall succeed'
21 changes: 21 additions & 0 deletions tests/usr/lib/ydf/components/package/ydf-package-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,24 @@ preinstall"
assert_success
assert_output --regexp "nnn"
}

# Tests for ydf::package_service::__instruction_@flatpak()
@test "ydf::package_service::__instruction_@flatpak() Should succeed Without instruction file" {

cd "${TEST_FIXTURES_DIR}/packages/0empty"

run ydf::package_service::__instruction_@flatpak

assert_success
assert_output ""
}

@test "ydf::package_service::__instruction_@flatpak() Should succeed" {

cd "${TEST_FIXTURES_DIR}/packages/7micenter@flathub"

run ydf::package_service::__instruction_@flatpak '7micenter@flathub'

assert_success
assert_output --partial "Installing app/io.missioncenter.MissionCenter/x86_64/stable"
}

0 comments on commit b94a556

Please sign in to comment.