diff --git a/Vedvfile b/Vedvfile index d6ac5b1..b68374b 100644 --- a/Vedvfile +++ b/Vedvfile @@ -2,17 +2,14 @@ FROM admin@manjaro/manjaro-gnome-22.1.3-x86_64 WORKDIR /home/vedv/ydf -RUN sudo pacman-mirrors --fasttrack && \ - sudo pacman -Syu --noconfirm --needed make +RUN sudo pacman-mirrors --fasttrack -COPY packages.env . +# install gnome base system +RUN sudo -H flatpak install --assumeyes --noninteractive io.github.andreibachim.shortcut RUN mkdir tools COPY tools/install-run-manjaro tools COPY tools/install-dev-manjaro.vedv tools +COPY packages.env . 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 . . diff --git a/src/usr/lib/ydf/components/package/ydf-package-service.bash b/src/usr/lib/ydf/components/package/ydf-package-service.bash index 2b193eb..e83800c 100644 --- a/src/usr/lib/ydf/components/package/ydf-package-service.bash +++ b/src/usr/lib/ydf/components/package/ydf-package-service.bash @@ -29,7 +29,7 @@ fi # readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_UBUNTU="preinstall apt install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}" readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON='' -readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_MANJARO="preinstall install @pacman @yay @flatpak postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}" +readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_MANJARO="preinstall install @pacman @yay @flatpak @snap postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}" # readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_UBUNTU="preinstall install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}" # @@ -158,6 +158,23 @@ ydf::package_service::__instruction_@flatpak() { sudo -H flatpak install --assumeyes --noninteractive flathub "${flatpak_pkg_name:-"$pkg_name"}" } +# +# Execute @snap instruction +# +# Arguments: +# pkg_name string package name +# +# Returns: +# 0 on success, non-zero on error. +# +ydf::package_service::__instruction_@snap() { + local -r pkg_name="$1" + # select the first no empty line + local -r snap_pkg_name="$(ydf::utils::print_1line <@snap)" + # eval allows include options along with package name + eval sudo -H snap install "${snap_pkg_name:-"$pkg_name"}" +} + # # Install a ydotfile package from a directory # diff --git a/tests/fixtures/packages/8go@snap/@snap b/tests/fixtures/packages/8go@snap/@snap new file mode 100644 index 0000000..e9db760 --- /dev/null +++ b/tests/fixtures/packages/8go@snap/@snap @@ -0,0 +1 @@ +--classic go diff --git a/tests/fixtures/packages/8go@snap/install b/tests/fixtures/packages/8go@snap/install new file mode 100644 index 0000000..5575498 --- /dev/null +++ b/tests/fixtures/packages/8go@snap/install @@ -0,0 +1 @@ +echo '8go@snap: install succeed' diff --git a/tests/fixtures/packages/8go@snap/postinstall b/tests/fixtures/packages/8go@snap/postinstall new file mode 100644 index 0000000..f3c00cd --- /dev/null +++ b/tests/fixtures/packages/8go@snap/postinstall @@ -0,0 +1 @@ +echo '8go@snap: postinstall succeed' diff --git a/tests/fixtures/packages/8go@snap/preinstall b/tests/fixtures/packages/8go@snap/preinstall new file mode 100644 index 0000000..a3cd3f8 --- /dev/null +++ b/tests/fixtures/packages/8go@snap/preinstall @@ -0,0 +1 @@ +echo '8go@snap: preinstall succeed' diff --git a/tests/fixtures/packages/multipass/@snap b/tests/fixtures/packages/multipass/@snap new file mode 100644 index 0000000..e69de29 diff --git a/tests/usr/lib/ydf/components/package/ydf-package-command.f.bats b/tests/usr/lib/ydf/components/package/ydf-package-command.f.bats index 84e6f6c..10c63ba 100644 --- a/tests/usr/lib/ydf/components/package/ydf-package-command.f.bats +++ b/tests/usr/lib/ydf/components/package/ydf-package-command.f.bats @@ -220,3 +220,35 @@ com.github.tchx84.Flatseal: postinstall succeed" assert_success assert_output --partial "com.github.tchx84.Flatseal" } + +# Tests for ydf package install ../8go@snap +@test "ydf package install ../8go@snap, Should succeed" { + local -r _package_dir="${TEST_FIXTURES_DIR}/packages/8go@snap" + + run ydf package install "$_package_dir" + + assert_success + assert_output --regexp "8go@snap: preinstall succeed +8go@snap: install succeed +.* +8go@snap: postinstall succeed" + + run command -v go + + assert_success + assert_output --partial "/bin/go" +} + +@test "ydf package install ../multipass, Should succeed Without package name in @snap" { + local -r _package_dir="${TEST_FIXTURES_DIR}/packages/multipass" + + run ydf package install "$_package_dir" + + assert_success + assert_output --regexp "multipass .* installed" + + run command -v multipass + + assert_success + assert_output --partial "/bin/multipass" +} diff --git a/tests/usr/lib/ydf/components/package/ydf-package-service.bats b/tests/usr/lib/ydf/components/package/ydf-package-service.i.bats similarity index 94% rename from tests/usr/lib/ydf/components/package/ydf-package-service.bats rename to tests/usr/lib/ydf/components/package/ydf-package-service.i.bats index 1b6dd00..e6cf894 100644 --- a/tests/usr/lib/ydf/components/package/ydf-package-service.bats +++ b/tests/usr/lib/ydf/components/package/ydf-package-service.i.bats @@ -246,3 +246,20 @@ postinstall" assert_success assert_output --partial "io.missioncenter.MissionCenter/x86_64/stable" } + +# Tests for ydf::package_service::__instruction_@snap() +@test "ydf::package_service::__instruction_@snap() Should succeed" { + + cd "${TEST_FIXTURES_DIR}/packages/8go@snap" + + run ydf::package_service::__instruction_@snap '8go@snap' + + assert_success + assert_output --partial "go" + + run command -v go + + assert_success + + assert_output --partial 'bin/go' +} diff --git a/tools/ct-clean-exec b/tools/ct-clean-exec index 61def13..0683d71 100755 --- a/tools/ct-clean-exec +++ b/tools/ct-clean-exec @@ -32,6 +32,7 @@ if ! vedv container ls --all | grep -q "$VEDV_CONTAINER_NAME"; then vedv container create --name "$VEDV_CONTAINER_NAME" "$VEDV_IMAGE_NAME" echo ">> Container created" + echo echo ">> Starting container" vedv container start --wait "$VEDV_CONTAINER_NAME" echo ">> Container started" diff --git a/tools/install-run-manjaro b/tools/install-run-manjaro index 4a66b31..c89dde8 100755 --- a/tools/install-run-manjaro +++ b/tools/install-run-manjaro @@ -10,3 +10,16 @@ set -eu sudo pacman -Syu --noconfirm --needed yay yay -Sy --noconfirm --needed "${PKG_RUN_MANJARO_YAY[@]}" + +# Install snap +sudo pacman -S --noconfirm --needed snapd + +sudo systemctl enable apparmor --now +sudo systemctl enable snapd.apparmor --now +sudo systemctl enable snapd --now + +sudo ln -vs /var/lib/snapd/snap /snap + +echo ">>Attention: log out and back in again, or restart your system, to ensure snap’s paths are updated correctly" + +# sudo snap install core