Skip to content

Commit

Permalink
feat(snap): add git as craft.git to snapcraft
Browse files Browse the repository at this point in the history
Signed-off-by: Dariusz Duda <[email protected]>
  • Loading branch information
dariuszd21 committed Nov 19, 2024
1 parent cf70893 commit d8d3ed0
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
16 changes: 16 additions & 0 deletions snap/local/craft.git
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Copyright 2024 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

GIT_EXEC_PATH="${SNAP}/usr/lib/git-core" exec "${SNAP}/usr/lib/git-core/git" "$@"
23 changes: 23 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ parts:
stage:
- snapcraft-completion

snapcraft-scripts:
source: snap/local
plugin: dump
organize:
craft.git: libexec/snapcraft/craft.git
stage:
- "libexec/"

git:
plugin: nil
stage-packages: [git]
build-attributes:
- enable-patchelf
prime:
- "-usr/bin"
- "-usr/share/doc"
- "-usr/share/man"
# perl is part of the core22 / core24
- "-usr/share/perl"
- "-usr/lib/x86_64-linux-gnu/perl"
- "-usr/lib/x86_64-linux-gnu/libperl*"
- "-usr/lib/x86_64-linux-gnu/libgdbm*"

patchelf:
plugin: autotools
source: https://github.com/canonical/patchelf
Expand Down
23 changes: 23 additions & 0 deletions tests/spread/core24/craftgit/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: craftgit-test
base: core24
version: '0.1'
summary: Echo
description: Just a dummy build to check if craft.git from package works
confinement: strict

parts:
craftgit-test:
plugin: nil
override-pull: |
echo "checking if craft.git from snap is available during pull"
which craft.git | grep "$SNAP/libexec/snapcraft/craft.git"
craft.git clone --depth 1 https://git.launchpad.net/ubuntu/+source/hello
override-build: |
echo "checking if craft.git from snap is available during build"
which craft.git | grep "$SNAP/libexec/snapcraft/craft.git"
override-stage: |
echo "checking if craft.git from snap is available during stage"
which craft.git | grep "$SNAP/libexec/snapcraft/craft.git"
override-prime: |
echo "checking if craft.git from snap is available during prime"
which craft.git | grep "$SNAP/libexec/snapcraft/craft.git"
8 changes: 8 additions & 0 deletions tests/spread/core24/craftgit/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Pack a snap that uses craft.git

restore: |
snapcraft clean
rm -f ./*.snap
execute: |
snapcraft pack

0 comments on commit d8d3ed0

Please sign in to comment.