diff --git a/slices/git.yaml b/slices/git.yaml index b497245dd..08ab26c10 100644 --- a/slices/git.yaml +++ b/slices/git.yaml @@ -1,176 +1,53 @@ package: git -# Note: These slices do not currently include gitweb. essential: - git_copyright slices: bins: - # Pseudo slice to just get all binaries. + # basic functionality including: + # - init + # - config + # - add + # - commit + # - status + # - log + # - checkout + # - blame + # - diff + # - merge essential: - - git_core-bins - - git_net-bins - - core-bins: - essential: - # libc6 libcurl3-gnutls libexpat1 libpcre2-8-0 zlib1g perl liberror-perl git-man - libc6_libs - libpcre2-8-0_libs - zlib1g_libs - # While CA certificates aren't necessarily needed for git, installing contents: - /usr/bin/git: - /usr/bin/git-receive-pack: - /usr/bin/git-shell: - /usr/bin/git-upload-archive: - /usr/bin/git-upload-pack: + /usr/bin/git: {symlink: /usr/lib/git-core/git} /usr/lib/git-core/git: - /usr/lib/git-core/git-add*: - /usr/lib/git-core/git-annotate: - /usr/lib/git-core/git-apply: - /usr/lib/git-core/git-archive: - /usr/lib/git-core/git-bisect*: - /usr/lib/git-core/git-blame: - /usr/lib/git-core/git-branch: - /usr/lib/git-core/git-bugreport: - /usr/lib/git-core/git-bundle: - /usr/lib/git-core/git-cat-file: - /usr/lib/git-core/git-check-*: - /usr/lib/git-core/git-checkout*: - /usr/lib/git-core/git-cherry*: - /usr/lib/git-core/git-clean: - /usr/lib/git-core/git-clone: - /usr/lib/git-core/git-column: - /usr/lib/git-core/git-commit*: - /usr/lib/git-core/git-config: - /usr/lib/git-core/git-count-objects: - /usr/lib/git-core/git-credential*: - /usr/lib/git-core/git-describe: - /usr/lib/git-core/git-diff: - /usr/lib/git-core/git-diff-*: - /usr/lib/git-core/git-difftool: - /usr/lib/git-core/git-difftool--helper: - /usr/lib/git-core/git-env--helper: - /usr/lib/git-core/git-fast-*: - /usr/lib/git-core/git-fetch*: - /usr/lib/git-core/git-filter-branch: - /usr/lib/git-core/git-fmt-merge-msg: - /usr/lib/git-core/git-for-each-*: - /usr/lib/git-core/git-format-patch: - /usr/lib/git-core/git-fsck*: - /usr/lib/git-core/git-gc: - /usr/lib/git-core/git-get-tar-commit-id: - /usr/lib/git-core/git-grep: - /usr/lib/git-core/git-hash-object: - /usr/lib/git-core/git-help: - /usr/lib/git-core/git-index-pack: - /usr/lib/git-core/git-init: - /usr/lib/git-core/git-init-db: - /usr/lib/git-core/git-interpret-trailers: - /usr/lib/git-core/git-log: - /usr/lib/git-core/git-ls-*: - /usr/lib/git-core/git-mailinfo: - /usr/lib/git-core/git-mailsplit: - /usr/lib/git-core/git-maintenance: - /usr/lib/git-core/git-merge: - /usr/lib/git-core/git-merge-base: - /usr/lib/git-core/git-merge-file: - /usr/lib/git-core/git-merge-index: - /usr/lib/git-core/git-merge-octopus: - /usr/lib/git-core/git-merge-one-file: - /usr/lib/git-core/git-merge-ours: - /usr/lib/git-core/git-merge-recursive: - /usr/lib/git-core/git-merge-resolve: - /usr/lib/git-core/git-merge-subtree: - /usr/lib/git-core/git-merge-tree: - /usr/lib/git-core/git-mktag: - /usr/lib/git-core/git-mktree: - /usr/lib/git-core/git-multi-pack-index: - /usr/lib/git-core/git-mv: - /usr/lib/git-core/git-name-rev: - /usr/lib/git-core/git-notes: - /usr/lib/git-core/git-pack-*: - /usr/lib/git-core/git-patch-id: - /usr/lib/git-core/git-prune: - /usr/lib/git-core/git-prune-packed: - /usr/lib/git-core/git-pull: - /usr/lib/git-core/git-push: - /usr/lib/git-core/git-quiltimport: - /usr/lib/git-core/git-range-diff: - /usr/lib/git-core/git-read-tree: - /usr/lib/git-core/git-rebase: - /usr/lib/git-core/git-receive-pack: - /usr/lib/git-core/git-reflog: - /usr/lib/git-core/git-remote: - /usr/lib/git-core/git-remote-ext: - /usr/lib/git-core/git-remote-fd: - /usr/lib/git-core/git-repack: - /usr/lib/git-core/git-replace: - /usr/lib/git-core/git-request-pull: - /usr/lib/git-core/git-rerere: - /usr/lib/git-core/git-reset: - /usr/lib/git-core/git-restore: - /usr/lib/git-core/git-rev-list: - /usr/lib/git-core/git-rev-parse: - /usr/lib/git-core/git-rm: - /usr/lib/git-core/git-send-pack: - /usr/lib/git-core/git-sh-i18n: - /usr/lib/git-core/git-sh-i18n--envsubst: - /usr/lib/git-core/git-sh-prompt: - /usr/lib/git-core/git-sh-setup: - /usr/lib/git-core/git-shell: - /usr/lib/git-core/git-shortlog: - /usr/lib/git-core/git-show: - /usr/lib/git-core/git-show-branch: - /usr/lib/git-core/git-show-index: - /usr/lib/git-core/git-show-ref: - /usr/lib/git-core/git-sparse-checkout: - /usr/lib/git-core/git-stage: - /usr/lib/git-core/git-stash: - /usr/lib/git-core/git-status: - /usr/lib/git-core/git-stripspace: - /usr/lib/git-core/git-submodule: - /usr/lib/git-core/git-submodule--helper: - /usr/lib/git-core/git-subtree: - /usr/lib/git-core/git-switch: - /usr/lib/git-core/git-symbolic-ref: - /usr/lib/git-core/git-tag: - /usr/lib/git-core/git-unpack-file: - /usr/lib/git-core/git-unpack-objects: - /usr/lib/git-core/git-update-index: - /usr/lib/git-core/git-update-ref: - /usr/lib/git-core/git-update-server-info: - /usr/lib/git-core/git-upload-archive: - /usr/lib/git-core/git-upload-pack: - /usr/lib/git-core/git-var: - /usr/lib/git-core/git-verify-commit: - /usr/lib/git-core/git-verify-pack: - /usr/lib/git-core/git-verify-tag: - /usr/lib/git-core/git-whatchanged: - /usr/lib/git-core/git-worktree: - /usr/lib/git-core/git-write-tree: daemon: + # support for git daemon essential: - - git_core-bins + - git_bins contents: /usr/lib/git-core/git-daemon: - net-bins: - # Binaries used with networking. Not needed if git is only being used for local - # items. + http-clone: + # requirements for cloning over http `git clone https://`: essential: - - git_core-bins + - git_bins - libcurl3-gnutls_libs - libexpat1_libs - # While ca-certificates_data isn't strictly a dependency, it is generally needed if you use https. + - libpcre2-8-0_libs + contents: + /usr/lib/git-core/git-remote-http: + /usr/lib/git-core/git-remote-https: # link pointing to git-remote-http + + ftp-clone: + # requirements for cloning over ftp `git clone ftp://`: + essential: + - git_http-clone contents: - /usr/bin/git-receive-pack: - /usr/bin/git-upload-archive: - /usr/bin/git-upload-pack: - /usr/lib/git-core/git-http-*: - /usr/lib/git-core/git-imap-send: - /usr/lib/git-core/git-remote-*: + /usr/lib/git-core/git-remote-ftp: copyright: contents: diff --git a/slices/libcurl3-gnutls.yaml b/slices/libcurl3-gnutls.yaml index 09ddddf49..d7001b90c 100644 --- a/slices/libcurl3-gnutls.yaml +++ b/slices/libcurl3-gnutls.yaml @@ -20,8 +20,7 @@ slices: - libzstd1_libs - zlib1g_libs contents: - /usr/lib/*-linux-*/libcurl-gnutls.so.3: - /usr/lib/*-linux-*/libcurl-gnutls.so.4*: + /usr/lib/*-linux-*/libcurl-gnutls.so.*: copyright: contents: diff --git a/slices/python3-pyftpdlib.yaml b/slices/python3-pyftpdlib.yaml new file mode 100644 index 000000000..54e71952e --- /dev/null +++ b/slices/python3-pyftpdlib.yaml @@ -0,0 +1,15 @@ +package: python3-pyftpdlib + +essential: + - python3-pyftpdlib_copyright + +slices: + libs: + essential: + - python3.10_standard + contents: + /usr/lib/python3/dist-packages/pyftpdlib/*.py: + + copyright: + contents: + /usr/share/doc/python3-pyftpdlib/copyright: diff --git a/tests/spread/integration/git/task.yaml b/tests/spread/integration/git/task.yaml index 390d674d5..d6dc9a019 100644 --- a/tests/spread/integration/git/task.yaml +++ b/tests/spread/integration/git/task.yaml @@ -1,30 +1,152 @@ summary: Integration tests for git -environment: - EXTRA_SLICES: "" # No extra slices by default. - SLICE/core_bins: git_core-bins - SLICE/net_bins: git_net-bins - EXTRA_SLICES/net_bins: ca-certificates_data - SLICE/gitweb: git_gitweb - EXTRA_SLICES/gitweb: python3.10_standard curl_bins - execute: | - rootfs="$(install-slices $SLICE $EXTRA_SLICES)" - # Basic configuration of extra things not in the packages. - # Git uses /dev/null - mkdir -p "${rootfs}/dev" - mount --bind /dev "${rootfs}/dev" + function setup(){ + + mkdir -p "$1/dev/" + mkdir -p "$1/etc/" + + # fake essentials + touch "$1/dev/null" + head -c 500 /dev/urandom > "$1/dev/urandom" + cp /etc/resolv.conf $1/etc/ + + # link busybox + pushd "$1/usr/bin/" + for TARGET in ash mkdir cat sleep nc + do + ln -sf busybox $TARGET + done + popd + + } + + rootfs_bins=$(install-slices git_bins busybox_bins) + setup "$rootfs_bins" + + chroot "$rootfs_bins" ash << EOF + set -ex + + mkdir repo + cd repo + + git init + + git config user.email "you@example.com" + git config user.name "Your Name" + git config core.pager cat + + echo hello_world > test_file + git add test_file + git commit -m "hello hello_world" + + git status + git log + + git blame -L 1,1 test_file + + git checkout -b test + + echo foo_bar >> test_file + git add test_file + git commit -m "hello foo_bar" + + git diff master + + git branch + git checkout master + git merge test + + EOF + + + # Testing for http-clone + rootfs_http=$(install-slices git_http-clone busybox_bins ca-certificates_data) + setup "$rootfs_http" + + chroot "$rootfs_http" ash << EOF + set -ex + + # TODO: should we replace this with locally hosted server? + git clone https://github.com/cmatsuoka/figlet.git "$rootfs_bins/figlet" + + EOF + + # Testing for daemon clone + rootfs_daemon=$(install-slices git_daemon busybox_bins) + setup "$rootfs_daemon" + + chroot "$rootfs_daemon" ash << EOF + set -xe + + # create a test repo + repo_name=daemon-src + repo_path=/srv/git/\$repo_name + mkdir -p \$repo_path + cd \$repo_path + + git init . + echo foo_bar >> test_file + git add test_file + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -m "hello foo_bar" + + # start the daemon in the background + cd .. + /usr/lib/git-core/git-daemon \\ + --base-path=. \\ + --reuseaddr \\ + --listen=127.0.0.1 \\ + --verbose \\ + --export-all & + daemon_pid=\$! + + # wait for server port to become available + while ! echo -n | nc 127.0.0.1 9418 + do + sleep 1 + done + + # clone the repo + git clone git://localhost/\$repo_name daemon-dst + + # cleanup + kill \$daemon_pid + + EOF + + # Testing for ftp-clone + rootfs_ftp=$(install-slices git_ftp-clone busybox_bins python3-pyftpdlib_libs) + setup "$rootfs_ftp" + + chroot "$rootfs_ftp" ash << EOF + set -xe + + # create a test repo + repo_name=ftp-src + repo_path=/srv/git/\$repo_name + mkdir -p \$repo_path + cd \$repo_path + + git init --bare + git update-server-info + + cd .. + /usr/bin/python3.12 -m pyftpdlib -V & + pyftpdlib_pid=\$! - # Make domain resolution work - mkdir -p "${rootfs}/etc" - cp /etc/resolv.conf "${rootfs}/etc/resolv.conf" + # wait for server port to become available + while ! echo -n | nc 127.0.0.1 2121 + do + sleep 1 + done - # Give root a homedir in the fs (for git config) - mkdir -p "${rootfs}/root" + # clone the repo + git clone ftp://localhost:2121/\$repo_name ftp-dst - # Run the test script for this slice. - "./test-${SLICE}.sh" "${rootfs}" + # cleanup + kill \$pyftpdlib_pid - # Clean up - umount "${rootfs}/dev" + EOF diff --git a/tests/spread/integration/git/test-git_core-bins.sh b/tests/spread/integration/git/test-git_core-bins.sh deleted file mode 100755 index 4b23ce094..000000000 --- a/tests/spread/integration/git/test-git_core-bins.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Basic tests for git core binaries. -rootfs="${1}" - -chroot "${rootfs}" git init -echo "Test" > "${rootfs}/test.txt" -chroot "${rootfs}" git add test.txt -chroot "${rootfs}" git config --global user.email "root@localhost" -chroot "${rootfs}" git config --global user.name "Test Runner" -chroot "${rootfs}" git commit -m test -[[ $(chroot "${rootfs}" git ls-files) == "test.txt" ]] diff --git a/tests/spread/integration/git/test-git_net-bins.sh b/tests/spread/integration/git/test-git_net-bins.sh deleted file mode 100755 index 91c44c8b7..000000000 --- a/tests/spread/integration/git/test-git_net-bins.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# Test for network activity. -chroot "${1}" git clone --branch ubuntu-22.04 --depth 1 https://github.com/canonical/chisel-releases