From 7a76ae8fe8dde45d8bfdf9b76453bb1b66acbcb7 Mon Sep 17 00:00:00 2001 From: Georgy Yakovlev Date: Fri, 4 Jun 2021 15:54:10 -0700 Subject: dev-util/schroot: add portage and zfs clone setup.d scripts used by some releng machines Signed-off-by: Georgy Yakovlev --- dev-util/schroot/files/06zfscloneopts | 44 ++++++++ dev-util/schroot/files/11gentoo | 61 +++++++++++ dev-util/schroot/files/schroot_prompt.sh | 1 + dev-util/schroot/schroot-1.6.10_p12-r1.ebuild | 148 ++++++++++++++++++++++++++ dev-util/schroot/schroot-1.6.10_p12.ebuild | 130 ---------------------- 5 files changed, 254 insertions(+), 130 deletions(-) create mode 100644 dev-util/schroot/files/06zfscloneopts create mode 100644 dev-util/schroot/files/11gentoo create mode 100644 dev-util/schroot/files/schroot_prompt.sh create mode 100644 dev-util/schroot/schroot-1.6.10_p12-r1.ebuild delete mode 100644 dev-util/schroot/schroot-1.6.10_p12.ebuild (limited to 'dev-util') diff --git a/dev-util/schroot/files/06zfscloneopts b/dev-util/schroot/files/06zfscloneopts new file mode 100644 index 000000000000..e66f0885e78f --- /dev/null +++ b/dev-util/schroot/files/06zfscloneopts @@ -0,0 +1,44 @@ +#!/bin/sh +# Copyright © 2020 Georgy Yakovlev +# +# schroot is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# schroot is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY 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 +# . +# +##################################################################### + +set -e + +. "$SETUP_DATA_DIR/common-data" +. "$SETUP_DATA_DIR/common-functions" +. "$SETUP_DATA_DIR/common-config" + +if [ "$CHROOT_TYPE" = "zfs-snapshot" ] && [ -n "$CHROOT_ZFS_CLONE_NAME" ]; then + + if [ $STAGE = "setup-start" ]; then + + if ! zfs list "$CHROOT_ZFS_CLONE_NAME" >/dev/null 2>&1; then + fatal "Dataset '$CHROOT_ZFS_CLONE_NAME' does not exist" + fi + + if [ "${ZFS_CLONE_OPTIONS+set}" = "set" ]; then + if [ "$VERBOSE" = "verbose" ]; then + zfs set $ZFS_CLONE_OPTIONS \ + "$CHROOT_ZFS_CLONE_NAME" + else + zfs set $ZFS_CLONE_OPTIONS \ + "$CHROOT_ZFS_CLONE_NAME" > /dev/null + fi + fi + fi +fi diff --git a/dev-util/schroot/files/11gentoo b/dev-util/schroot/files/11gentoo new file mode 100644 index 000000000000..ddf2df305c68 --- /dev/null +++ b/dev-util/schroot/files/11gentoo @@ -0,0 +1,61 @@ +#!/bin/sh +# Copyright © 2020 Georgy Yakovlev +# +# schroot is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# schroot is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY 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 +# . +# +##################################################################### + +set -e + +. "$SETUP_DATA_DIR/common-data" +. "$SETUP_DATA_DIR/common-functions" +. "$SETUP_DATA_DIR/common-config" + +if [ "$VERBOSE" = "verbose" ]; then + VERBOSE_OPT="true" +fi + +if [ "${PORTAGE_BASE_TMPDIR+set}" = "set" ] ; then + if [ "$STAGE" = "setup-start" ]; then + if [ ! -d "$PORTAGE_BASE_TMPDIR" ]; then + fatal "$PORTAGE_BASE_TMPDIR does not exist or not a directory" + fi + if [ "x$SESSION_ID" = x ]; then + fatal "SESSION_ID is not set" + fi + if [ ! -d "$PORTAGE_BASE_TMPDIR/schroot-$SESSION_ID" ]; then + mkdir ${VERBOSE_OPT+-v} \ + "$PORTAGE_BASE_TMPDIR/schroot-$SESSION_ID" + fi + mkdir -p ${VERBOSE_OPT+-v} "$CHROOT_MOUNT_LOCATION/var/tmp/portage" + mount --make-private -o bind ${VERBOSE_OPT+-v}\ + "$PORTAGE_BASE_TMPDIR/schroot-$SESSION_ID" \ + "$CHROOT_MOUNT_LOCATION/var/tmp/portage" + + elif [ "$STAGE" = "setup-stop" ]; then + if [ "$CHROOT_SESSION_PURGE" = true ] || \ + [ "${CHROOT_NAME/#*_master/m}" = "m" ]; then + umount ${VERBOSE_OPT+-v} \ + "$CHROOT_MOUNT_LOCATION/var/tmp/portage" + if [ -d "$PORTAGE_BASE_TMPDIR/schroot-$SESSION_ID" ]; then + if [ "x$SESSION_ID" != x ]; then + rm -fr ${VERBOSE_OPT+-v} \ + "$PORTAGE_BASE_TMPDIR/schroot-$SESSION_ID" + fi + fi + fi + + fi +fi diff --git a/dev-util/schroot/files/schroot_prompt.sh b/dev-util/schroot/files/schroot_prompt.sh new file mode 100644 index 000000000000..bd72f2ce5b83 --- /dev/null +++ b/dev-util/schroot/files/schroot_prompt.sh @@ -0,0 +1 @@ +[[ -f /etc/debian_chroot ]] && PS1="chr: $(< /etc/debian_chroot) ${PS1}" diff --git a/dev-util/schroot/schroot-1.6.10_p12-r1.ebuild b/dev-util/schroot/schroot-1.6.10_p12-r1.ebuild new file mode 100644 index 000000000000..0a4a39d4ed2f --- /dev/null +++ b/dev-util/schroot/schroot-1.6.10_p12-r1.ebuild @@ -0,0 +1,148 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit bash-completion-r1 cmake pam tmpfiles + +MY_P=${PN}_${PV/_p/-} + +DESCRIPTION="Utility to execute commands in a chroot environment" +HOMEPAGE="https://packages.debian.org/source/sid/schroot" +SRC_URI="mirror://debian/pool/main/${PN::1}/${PN}/${MY_P/%-*/}.orig.tar.xz + mirror://debian/pool/main/${PN::1}/${PN}/${MY_P}.debian.tar.xz" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86" +IUSE="btrfs +dchroot debug doc lvm nls pam test zfs" +RESTRICT="!test? ( test )" + +COMMON_DEPEND=" + >=dev-libs/boost-1.42.0:= + >=sys-apps/util-linux-2.16 + btrfs? ( >=sys-fs/btrfs-progs-0.19-r2 ) + lvm? ( sys-fs/lvm2 ) + pam? ( sys-libs/pam ) + zfs? ( sys-fs/zfs ) +" + +DEPEND="${COMMON_DEPEND} + app-arch/xz-utils + sys-apps/groff + doc? ( + app-doc/doxygen + media-gfx/graphviz + ) + nls? ( + >=app-text/po4a-0.40 + sys-devel/gettext + ) + test? ( >=dev-util/cppunit-1.10.0 ) +" +RDEPEND="${COMMON_DEPEND} + sys-apps/debianutils + dchroot? ( !sys-apps/dchroot ) + nls? ( virtual/libintl ) +" + +S="${WORKDIR}/${PN}-${PV/%_p*/}" + +src_unpack() { + unpack ${MY_P/%-*/}.orig.tar.xz + cd "${S}" + unpack ${MY_P}.debian.tar.xz +} + +src_prepare() { + sed -i -e 's/warn(/message(WARNING /' man/CMakeLists.txt || die + eapply "${S}"/debian/patches/*.patch + cmake_src_prepare +} + +src_configure() { + local mycmakeargs=( + -Dbtrfs-snapshot=$(usex btrfs) + -Ddchroot=$(usex dchroot) + -Ddchroot-dsa=$(usex dchroot) + -Ddebug=$(usex debug) + -Ddoxygen=$(usex doc) + -Dlvm-snapshot=$(usex lvm) + -Dnls=$(usex nls) + -Dpam=$(usex pam) + -Dtest=$(usex test) + -Dzfs-snapshot=$(usex zfs) + -Dbash_completion_dir="$(get_bashcompdir)" + -DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc" + -DCMAKE_INSTALL_LOCALSTATEDIR="${EPREFIX}/var" + -DSCHROOT_MOUNT_DIR="${EPREFIX}/run/${PN}/mount" + -DBoost_NO_BOOST_CMAKE=ON # https://bugs.gentoo.org/791712 and https://bugs.gentoo.org/752120 + ) + if ! use nls; then + mycmakeargs+=(-DPO4A_EXECUTABLE=NOTFOUND) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile all $(usev doc) +} + +src_test() { + if [[ $EUID -ne 0 ]]; then + ewarn "Disabling tests because you are not root" + return 0 + fi + + cmake_src_test +} + +src_install() { + cmake_src_install + + # debian-stype PS1 for chroot + # checks for /etc/debian_chroot file, which is created by schroot + insinto /etc/bash/bashrc.d + doins "${FILESDIR}/schroot_prompt.sh" + + # gentoo /var/tmp/portage handler + # e.g. portage.base.tmpdir=/var/tmp/portage in config file + # will use a subdirectory of hosts $PORTAGE_TMPDIR + exeinto /etc/schroot/setup.d + doexe "${FILESDIR}/11gentoo" + + # support for zfs clone options. + # zfs.clone.options=com.sun:auto-snapshot=false + if use zfs; then + exeinto /etc/schroot/setup.d + doexe "${FILESDIR}/06zfscloneopts" + fi + + keepdir /var/lib/schroot/{session,unpack,union/{overlay,underlay}} + + docinto /usr/share/doc/${PF}/contrib/setup.d + dodoc contrib/setup.d/05customdir contrib/setup.d/09fsck contrib/setup.d/10mount-ssh + + newdoc debian/schroot.NEWS NEWS.debian + + newinitd "${FILESDIR}"/schroot.initd schroot + newconfd "${FILESDIR}"/schroot.confd schroot + newtmpfiles "${FILESDIR}"/schroot.tmpfilesd schroot.conf + + if use doc; then + docinto html/sbuild + dodoc "${BUILD_DIR}"/doc/sbuild/html/* + docinto html/schroot + dodoc "${BUILD_DIR}"/doc/schroot/html/* + fi + + if use pam; then + rm -f "${ED}"/etc/pam.d/schroot + pamd_mimic_system schroot auth account session + fi +} + +pkg_postinst() { + tmpfiles_process ${PN}.conf +} diff --git a/dev-util/schroot/schroot-1.6.10_p12.ebuild b/dev-util/schroot/schroot-1.6.10_p12.ebuild deleted file mode 100644 index d1292d3caaaf..000000000000 --- a/dev-util/schroot/schroot-1.6.10_p12.ebuild +++ /dev/null @@ -1,130 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -inherit bash-completion-r1 cmake pam tmpfiles - -MY_P=${PN}_${PV/_p/-} - -DESCRIPTION="Utility to execute commands in a chroot environment" -HOMEPAGE="https://packages.debian.org/source/sid/schroot" -SRC_URI="mirror://debian/pool/main/${PN::1}/${PN}/${MY_P/%-*/}.orig.tar.xz - mirror://debian/pool/main/${PN::1}/${PN}/${MY_P}.debian.tar.xz" - -LICENSE="GPL-3" -SLOT="0" -KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86" -IUSE="btrfs +dchroot debug doc lvm nls pam test zfs" -RESTRICT="!test? ( test )" - -COMMON_DEPEND=" - >=dev-libs/boost-1.42.0:= - >=sys-apps/util-linux-2.16 - btrfs? ( >=sys-fs/btrfs-progs-0.19-r2 ) - lvm? ( sys-fs/lvm2 ) - pam? ( sys-libs/pam ) - zfs? ( sys-fs/zfs ) -" - -DEPEND="${COMMON_DEPEND} - app-arch/xz-utils - sys-apps/groff - doc? ( - app-doc/doxygen - media-gfx/graphviz - ) - nls? ( - >=app-text/po4a-0.40 - sys-devel/gettext - ) - test? ( >=dev-util/cppunit-1.10.0 ) -" -RDEPEND="${COMMON_DEPEND} - sys-apps/debianutils - dchroot? ( !sys-apps/dchroot ) - nls? ( virtual/libintl ) -" - -S="${WORKDIR}/${PN}-${PV/%_p*/}" - -src_unpack() { - unpack ${MY_P/%-*/}.orig.tar.xz - cd "${S}" - unpack ${MY_P}.debian.tar.xz -} - -src_prepare() { - sed -i -e 's/warn(/message(WARNING /' man/CMakeLists.txt || die - eapply "${S}"/debian/patches/*.patch - cmake_src_prepare -} - -src_configure() { - local mycmakeargs=( - -Dbtrfs-snapshot=$(usex btrfs) - -Ddchroot=$(usex dchroot) - -Ddchroot-dsa=$(usex dchroot) - -Ddebug=$(usex debug) - -Ddoxygen=$(usex doc) - -Dlvm-snapshot=$(usex lvm) - -Dnls=$(usex nls) - -Dpam=$(usex pam) - -Dtest=$(usex test) - -Dzfs-snapshot=$(usex zfs) - -Dbash_completion_dir="$(get_bashcompdir)" - -DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc" - -DCMAKE_INSTALL_LOCALSTATEDIR="${EPREFIX}/var" - -DSCHROOT_MOUNT_DIR="${EPREFIX}/run/${PN}/mount" - -DBoost_NO_BOOST_CMAKE=ON # https://bugs.gentoo.org/791712 and https://bugs.gentoo.org/752120 - ) - if ! use nls; then - mycmakeargs+=(-DPO4A_EXECUTABLE=NOTFOUND) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile all $(usev doc) -} - -src_test() { - if [[ $EUID -ne 0 ]]; then - ewarn "Disabling tests because you are not root" - return 0 - fi - - cmake_src_test -} - -src_install() { - cmake_src_install - - keepdir /var/lib/schroot/{session,unpack,union/{overlay,underlay}} - - docinto /usr/share/doc/${PF}/contrib/setup.d - dodoc contrib/setup.d/05customdir contrib/setup.d/09fsck contrib/setup.d/10mount-ssh - - newdoc debian/schroot.NEWS NEWS.debian - - newinitd "${FILESDIR}"/schroot.initd schroot - newconfd "${FILESDIR}"/schroot.confd schroot - newtmpfiles "${FILESDIR}"/schroot.tmpfilesd schroot.conf - - if use doc; then - docinto html/sbuild - dodoc "${BUILD_DIR}"/doc/sbuild/html/* - docinto html/schroot - dodoc "${BUILD_DIR}"/doc/schroot/html/* - fi - - if use pam; then - rm -f "${ED}"/etc/pam.d/schroot - pamd_mimic_system schroot auth account session - fi -} - -pkg_postinst() { - tmpfiles_process ${PN}.conf -} -- cgit v1.2.3-65-gdbad