-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add git to ubuntu-22.04 release (#372)
Needed because pyftpdlib needs a file in /dev
- Loading branch information
Showing
6 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package: git | ||
|
||
essential: | ||
- git_copyright | ||
|
||
slices: | ||
bins: | ||
# Basic functionality including: | ||
# - add | ||
# - blame | ||
# - branch | ||
# - checkout | ||
# - commit | ||
# - config | ||
# - diff | ||
# - fetch | ||
# - init | ||
# - log | ||
# - merge | ||
# - rev-list | ||
# - status | ||
essential: | ||
- libc6_libs | ||
- libpcre2-8-0_libs | ||
- zlib1g_libs | ||
contents: | ||
# /usr/bin/git is a regular file in the package, but shares | ||
# the same hash of /usr/lib/git-core/git. That's why this | ||
# is added as a symlink to reduce space. | ||
/usr/bin/git: {symlink: /usr/lib/git-core/git} | ||
/usr/lib/git-core/git: | ||
|
||
daemon: | ||
# support for git daemon | ||
essential: | ||
- git_bins | ||
contents: | ||
/usr/lib/git-core/git-daemon: | ||
|
||
http-support: | ||
# Adds support for cloning over HTTP e.g. git clone https://... | ||
essential: | ||
- git_bins | ||
- libcurl3-gnutls_libs | ||
- libexpat1_libs | ||
- 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-support: | ||
# Adds support for cloning over FTP e.g. git clone ftp://... | ||
essential: | ||
- git_http-support | ||
contents: | ||
/usr/lib/git-core/git-remote-ftp: | ||
|
||
copyright: | ||
contents: | ||
/usr/share/doc/git/copyright: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package: libcurl3-gnutls | ||
|
||
essential: | ||
- libcurl3-gnutls_copyright | ||
|
||
slices: | ||
libs: | ||
essential: | ||
- libbrotli1_libs | ||
- libc6_libs | ||
- libgnutls30_libs | ||
- libgssapi-krb5-2_libs | ||
- libidn2-0_libs | ||
- libldap-2.5-0_libs | ||
- libnettle8_libs | ||
- libnghttp2-14_libs | ||
- libpsl5_libs | ||
- librtmp1_libs | ||
- libssh-4_libs | ||
- libzstd1_libs | ||
- zlib1g_libs | ||
contents: | ||
/usr/lib/*-linux-*/libcurl-gnutls.so.*: | ||
|
||
copyright: | ||
contents: | ||
/usr/share/doc/libcurl3-gnutls/copyright: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
summary: Integration tests for git | ||
|
||
environment: | ||
EXTRA_SLICES: "" # No extra slices by default. | ||
# test git_bins | ||
RUN/bins: test_bins | ||
SLICE/bins: git_bins | ||
# test git_http-support | ||
RUN/http_support: test_http_support | ||
SLICE/http_support: git_http-support | ||
EXTRA_SLICES/http_support: ca-certificates_data | ||
# test git_ftp-support | ||
RUN/ftp_support: test_ftp_support | ||
SLICE/ftp_support: git_ftp-support | ||
# test git_daemon | ||
RUN/daemon_support: test_daemon_support | ||
SLICE/daemon_support: git_daemon | ||
|
||
execute: | | ||
git_rootfs="/" | ||
function chroot_git(){ | ||
# execute git within chroot. We use -C to cd since | ||
# we have no $SHELL to navigate with. | ||
repo="$(realpath -e --relative-to="$git_rootfs" "$PWD")" | ||
chroot "$git_rootfs" /usr/bin/git -C "$repo" "$@" | ||
} | ||
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/ | ||
mkdir "$1/root" | ||
# configure | ||
git_rootfs="$1" | ||
pushd "$1" | ||
} | ||
function cleanup(){ | ||
popd | ||
} | ||
function test_bins(){ | ||
chroot_git init | ||
chroot_git config user.email "root@localhost" | ||
chroot_git config user.name "Test Runner" | ||
echo "Test" > "$1/test.txt" | ||
chroot_git add test.txt | ||
chroot_git commit -m 'test commit' | ||
chroot_git --no-pager status | ||
chroot_git --no-pager log | ||
chroot_git blame -L 1,1 test.txt | ||
[[ $(chroot_git ls-files) == "test.txt" ]] | ||
chroot_git checkout -b test | ||
chroot_git --no-pager diff master | ||
chroot_git branch | ||
chroot_git checkout master | ||
chroot_git merge test | ||
} | ||
function test_http_support(){ | ||
chroot_git clone --depth 1 https://git.launchpad.net/ubuntu/+source/hello hello | ||
cd $_ | ||
chroot_git --no-pager log | ||
chroot_git fetch origin | ||
chroot_git --no-pager branch --remotes --contains $(chroot_git rev-list -n 1 HEAD) | ||
} | ||
function test_ftp_support(){ | ||
ftp_root=$(install-slices python3-pyftpdlib_libs) | ||
mkdir $ftp_root/dev | ||
mount --bind /dev "${ftp_root}/dev" | ||
mkdir -p srv/git/ftp-src | ||
pushd $_ | ||
chroot_git init --bare | ||
chroot_git update-server-info | ||
popd | ||
cp -r $1/srv $ftp_root | ||
pushd $ftp_root/srv/git | ||
chroot $ftp_root /usr/bin/python3.10 -m pyftpdlib -V -p 2121 -d /srv/git & | ||
pyftpdlib_pid=$! | ||
popd | ||
# wait for server port to become available | ||
while ! fuser 2121/tcp > /dev/null 2>&1 | ||
do | ||
if ! test -d /proc/$pyftpdlib_pid | ||
then | ||
echo "pyftpdlib exited early" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
# Test cloning the repo | ||
chroot_git clone ftp://localhost:2121/ftp-src ftp-dst | ||
# cleanup | ||
kill -TERM $(fuser 2121/tcp 2>/dev/null) | ||
} | ||
function test_daemon_support(){ | ||
mkdir -p $1/srv/git/daemon-src | ||
pushd $1/srv/git/daemon-src | ||
git init | ||
touch test-file | ||
chroot_git add test-file | ||
chroot_git config user.email "root@localhost" | ||
chroot_git config user.name "Test Runner" | ||
chroot_git commit -m "Hello daemon" | ||
popd | ||
chroot_git daemon \ | ||
--base-path=/srv/git \ | ||
--reuseaddr \ | ||
--listen=127.0.0.1 \ | ||
--verbose \ | ||
--export-all & | ||
daemon_pid=$! | ||
# Wait for daemon to start | ||
while ! fuser 9418/tcp > /dev/null 2>&1 | ||
do | ||
if ! test -d /proc/$daemon_pid | ||
then | ||
echo "daemon exited early" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
# Test cloning the repo | ||
chroot_git clone git://localhost/daemon-src daemon-dst | ||
# Cleanup. TERM or KILL cause git to return an en error. | ||
kill -INT $(fuser 9418/tcp 2>/dev/null) | ||
} | ||
rootfs=$(install-slices $SLICE $EXTRA_SLICES) | ||
setup $rootfs | ||
$RUN $rootfs | ||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
summary: Integration tests for libcurl3-gnutls | ||
|
||
execute: | | ||
rootfs="$(install-slices libcurl3-gnutls_libs)" | ||
arch=$(uname -m) | ||
test -f ${rootfs}/usr/lib/${arch}-linux-gnu/libcurl-gnutls.so.3 | ||
test -f ${rootfs}/usr/lib/${arch}-linux-gnu/libcurl-gnutls.so.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
summary: Integration tests for python3-pyftpdlib | ||
|
||
execute: | | ||
function wait_for_ftp(){ | ||
sleep 0.3 | ||
while ! nc -z 127.0.0.1 2121 | ||
do | ||
test -d /proc/$pyftpdlib_pid || (echo "pyftpdlib exited early"; exit 1) | ||
sleep 1 | ||
done | ||
} | ||
function cleanup(){ | ||
while [[ -d /proc/$pyftpdlib_pid ]]; do | ||
kill $pyftpdlib_pid || true | ||
sleep 0.1 | ||
done | ||
} | ||
# Still run the cleanup even on test failure. | ||
trap cleanup EXIT | ||
rootfs="$(install-slices python3-pyftpdlib_libs)" | ||
mkdir "${rootfs}/dev" | ||
mount --bind /dev "${rootfs}/dev" | ||
mkdir -p "${rootfs}"/srv/subdir | ||
echo "Test file" > "${rootfs}"/srv/subdir/test-file | ||
# Basic install smoke test | ||
chroot "${rootfs}" python3.10 -m pyftpdlib --help | ||
# Anonymous hosting | ||
chroot "${rootfs}" /usr/bin/python3.10 -m pyftpdlib \ | ||
--verbose \ | ||
--interface=127.0.0.1 \ | ||
--port=2121 \ | ||
--directory=/srv & | ||
export pyftpdlib_pid=$! | ||
wait_for_ftp | ||
[[ "$(curl ftp://127.0.0.1:2121/subdir/test-file)" == "Test file" ]] | ||
cleanup | ||
# With login and file upload. | ||
chroot "${rootfs}" /usr/bin/python3.10 -m pyftpdlib \ | ||
--verbose \ | ||
--interface=127.0.0.1 \ | ||
--port=2121 \ | ||
--directory=/srv \ | ||
--write \ | ||
--username=testy \ | ||
--password=testy & | ||
export pyftpdlib_pid=$! | ||
wait_for_ftp | ||
[[ "$(curl ftp://testy:[email protected]:2121/subdir/test-file)" == "Test file" ]] | ||
echo "Test upload" > test-upload | ||
curl -T test-upload ftp://testy:[email protected]:2121/test-upload | ||
[[ "$(cat "${rootfs}/srv/test-upload")" == "$(cat test-upload)" ]] | ||
cleanup |