Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(snap): add git as craft.git to snapcraft #5149

Merged
merged 5 commits into from
Nov 21, 2024
Merged
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
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" "$@"
25 changes: 25 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@ 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/lib/git-core"
- "usr/share/git-core"
- "usr/lib/x86_64-linux-gnu/libcurl-gnutls*"
- "usr/lib/x86_64-linux-gnu/libpsl*"
- "usr/lib/x86_64-linux-gnu/librtmp*"
- "usr/lib/x86_64-linux-gnu/libnghttp2*"
- "usr/lib/x86_64-linux-gnu/libldap*"
- "usr/lib/x86_64-linux-gnu/liblber*"
- "usr/lib/x86_64-linux-gnu/libsasl2*"


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: |
mr-cal marked this conversation as resolved.
Show resolved Hide resolved
snapcraft pack
Loading