diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..ee2b8c3003127c61057cc5df3838eeabd5889eeb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +liberapay: benz0li +custom: ['https://benz0li.b-data.io/donate?project=4'] diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff08893a80a9e6172bcb469d12d8b7f1604a0419..74d524ec739700fbf4c750840afe27eef04f9a81 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,8 +36,7 @@ build:version-linux-amd64: --build-arg GIT_LFS_VERSION -t $CI_APP_REPO:$GIT_LFS_VERSION-linux-amd64 -f build.Dockerfile . - - | - docker push $CI_APP_REPO:$GIT_LFS_VERSION-linux-amd64 + - docker push $CI_APP_REPO:$GIT_LFS_VERSION-linux-amd64 rules: - if: $CI_COMMIT_BRANCH == "main" && $CI_BUILD_PLATFORMS =~ /(linux\/amd64)/ changes: @@ -56,8 +55,7 @@ build:version-linux-arm64v8: --build-arg GIT_LFS_VERSION -t $CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8 -f build.Dockerfile . - - | - docker push $CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8 + - docker push $CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8 rules: - if: $CI_COMMIT_BRANCH == "main" && $CI_BUILD_PLATFORMS =~ /(linux\/arm64\/v8)/ changes: diff --git a/README.md b/README.md index 34af33a0a6fc2586964850f4e1800fbf5340dcc1..9b51c476cbb2da763f848d9f241c3158914273b5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [](https://github.com/RichardLitt/standard-readme/blob/master/example-readmes/minimal-readme.md) [](https://www.repostatus.org/#active) <a href="https://benz0li.b-data.io/donate?project=4"><img src="https://benz0li.b-data.io/donate/static/donate-with-fosspay.png" alt="Donate with fosspay"></a> <a href="https://liberapay.com/benz0li/donate"><img src="https://liberapay.com/assets/widgets/donate.svg" alt="Donate using Liberapay" height="20"></a> -# Git LFS install +# Dockerised Git LFS installation [This project](https://gitlab.com/b-data/git-lfs/glfsi) is intended for system administrators who want to perform an installation of Git LFS on any Linux @@ -23,11 +23,11 @@ This projects requires an installation of docker and docker compose. To install docker, follow the instructions for your platform: * [Install Docker Engine | Docker Documentation > Supported platforms](https://docs.docker.com/engine/install/#supported-platforms) -* [Post-installation steps for Linux](https://docs.docker.com/engine/install/linux-postinstall/) +* [Post-installation steps for Linux | Docker Documentation](https://docs.docker.com/engine/install/linux-postinstall/) ### Docker Compose -* [Install Docker Compose](https://docs.docker.com/compose/install/) +* [Install Docker Compose | Docker Documentation](https://docs.docker.com/compose/install/) ## Install diff --git a/sample..env b/sample..env index b1bf149f9cadcad4cda4be004a3347190dfe890c..c80c8bc76a833906c7aa799563e03772db1edf20 100644 --- a/sample..env +++ b/sample..env @@ -4,7 +4,8 @@ IMAGE=debian:bullseye GIT_LFS_VERSION=3.2.0 # Installation prefix -PREFIX=/usr/local +# default: /usr/local +PREFIX= # Execution mode (default: install) # other: uninstall diff --git a/sample.docker-compose.yml b/sample.docker-compose.yml index ab8dc91121dbfd5b01d1321809482af52ae88f47..0b1e3f9580fb5d6746cabd201a0456e64aa82f21 100644 --- a/sample.docker-compose.yml +++ b/sample.docker-compose.yml @@ -9,10 +9,11 @@ services: image: glfsi container_name: glfsi network_mode: host + userns_mode: host volumes: - - ${PREFIX}:${PREFIX} + - ${PREFIX:-/usr/local}:${PREFIX:-/usr/local} + - /etc:/tmp/etc environment: - GIT_LFS_VERSION=${GIT_LFS_VERSION} - - PREFIX=${PREFIX} + - PREFIX=${PREFIX:-/usr/local} - MODE=${MODE:-install} - userns_mode: host diff --git a/scripts/start.sh b/scripts/start.sh index b917b22f479070877dbbcdc6a44939bb4495b435..72ea229cd3752c7498d58d524429384c35e85d35 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -4,27 +4,64 @@ set -e +# Test if PREFIX location is whithin limits +if [[ ! "${PREFIX}" == "/usr/local" && ! "${PREFIX}" =~ ^"/opt" ]]; then + echo "ERROR: PREFIX set to '${PREFIX}'. Must either be '/usr/local' or within '/opt'." + exit 1 +fi + cd /tmp curl -sSLO https://github.com/git-lfs/git-lfs/releases/download/v${GIT_LFS_VERSION}/git-lfs-linux-$(dpkg --print-architecture)-v${GIT_LFS_VERSION}.tar.gz -tar xfz git-lfs-linux-$(dpkg --print-architecture)-v${GIT_LFS_VERSION}.tar.gz --no-same-owner -cd git-lfs-${GIT_LFS_VERSION} - +if [[ ${GIT_LFS_VERSION//./} -ge 320 ]]; then + tar xfz git-lfs-linux-$(dpkg --print-architecture)-v${GIT_LFS_VERSION}.tar.gz --no-same-owner + cd git-lfs-${GIT_LFS_VERSION} +else + tar xfz git-lfs-linux-$(dpkg --print-architecture)-v${GIT_LFS_VERSION}.tar.gz --no-same-owner --one-top-level + cd git-lfs-linux-$(dpkg --print-architecture)-v${GIT_LFS_VERSION} +fi sed -i 's/git lfs install/#git lfs install/g' install.sh + echo ' -mkdir -p $prefix/share/man/man1 +# According to https://www.debian.org/doc/debian-policy/ch-opersys.html#site-specific-programs +if [[ "$PREFIX" == "/usr/local" && -e /tmp/etc/staff-group-for-usr-local ]]; then + perm=2775 + group=staff +else + perm=755 + group=root +fi + +mkdir -p $prefix/share +mkdir -m$perm -p $prefix/share/man +chown root:$group $prefix/share/man +mkdir -m$perm -p $prefix/share/man/man1 +chown root:$group $prefix/share/man/man1 rm -rf $prefix/share/man/man1/git-lfs* -pushd "$( dirname "${BASH_SOURCE[0]}" )/man/man1" > /dev/null - for g in git-lfs*; do +if [[ -d man/man1 ]]; then + suffix=/man1 +else + suffix= +fi + +pushd "$( dirname "${BASH_SOURCE[0]}" )/man$suffix" > /dev/null + for g in *.1; do install -m0644 $g "$prefix/share/man/man1/$g" done popd > /dev/null -mkdir -p $prefix/share/man/man5 +mkdir -m$perm -p $prefix/share/man/man5 +chown root:$group $prefix/share/man/man5 rm -rf $prefix/share/man/man5/git-lfs* -pushd "$( dirname "${BASH_SOURCE[0]}" )/man/man5" > /dev/null - for g in git-lfs*; do +if [[ -d man/man5 ]]; then + suffix=/man5 +else + suffix= +fi + +pushd "$( dirname "${BASH_SOURCE[0]}" )/man$suffix" > /dev/null + for g in *.5; do install -m0644 $g "$prefix/share/man/man5/$g" done popd > /dev/null' >> install.sh @@ -34,20 +71,23 @@ set -eu prefix="/usr/local" -if [ "${PREFIX:-}" != "" ] ; then +if [[ "${PREFIX:-}" != "" ]] ; then prefix=${PREFIX:-} -elif [ "${BOXEN_HOME:-}" != "" ] ; then +elif [[ "${BOXEN_HOME:-}" != "" ]] ; then prefix=${BOXEN_HOME:-} fi rm -rf $prefix/bin/git-lfs* rm -rf $prefix/share/man/man1/git-lfs* -rm -rf $prefix/share/man/man5/git-lfs*' > uninstall.sh +rm -rf $prefix/share/man/man5/git-lfs* + +rmdir $prefix/share/man/man1 2>&1 | sed "s|^|INFO: |" +rmdir $prefix/share/man/man5 2>&1 | sed "s|^|INFO: |"' > uninstall.sh chmod +x uninstall.sh if [[ -f "${MODE}.sh" ]]; then ./${MODE}.sh - echo "Git LFS at ${PREFIX} ${MODE}ed." + echo "INFO: Git LFS v${GIT_LFS_VERSION} at ${PREFIX} ${MODE}ed." else - echo "Execution mode '${MODE}' not supported!" + echo "ERROR: Execution mode '${MODE}' not supported!" fi