diff options
Diffstat (limited to '0.4.0/ebuild')
94 files changed, 5689 insertions, 0 deletions
diff --git a/0.4.0/ebuild/Makefile.am b/0.4.0/ebuild/Makefile.am new file mode 100644 index 000000000..746f90f02 --- /dev/null +++ b/0.4.0/ebuild/Makefile.am @@ -0,0 +1,49 @@ +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *~ +SUBDIRS = . digests fetchers utils + +libexecprogdir = $(libexecdir)/paludis/ + +libexecprog_SCRIPTS = \ + build_functions.bash \ + builtin_fetch.bash \ + builtin_init.bash \ + builtin_merge.bash \ + builtin_metadata.bash \ + builtin_strip.bash \ + builtin_tidyup.bash \ + builtin_unmerge.bash \ + builtin_variable.bash \ + ebuild.bash \ + echo_functions.bash \ + kernel_functions.bash \ + eclass_functions.bash \ + install_functions.bash \ + list_functions.bash \ + multilib_functions.bash \ + pkg_config.bash \ + pkg_nofetch.bash \ + pkg_postinst.bash \ + pkg_postrm.bash \ + pkg_preinst.bash \ + pkg_prerm.bash \ + pkg_setup.bash \ + portage_stubs.bash \ + sandbox.bash \ + src_compile.bash \ + src_install.bash \ + src_test.bash \ + src_unpack.bash \ + usage_error.bash + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/ebuild/run_test.bash + +TESTS = echo_functions_TEST.bash list_functions_TEST.bash kernel_functions_TEST.bash +EXTRA_DIST = $(libexecprog_SCRIPTS) run_test.bash $(TESTS) + +check_SCRIPTS = run_test.bash $(TESTS) +check_PROGRAMS = + diff --git a/0.4.0/ebuild/build_functions.bash b/0.4.0/ebuild/build_functions.bash new file mode 100644 index 000000000..ec3b129a5 --- /dev/null +++ b/0.4.0/ebuild/build_functions.bash @@ -0,0 +1,99 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +econf() +{ + local LOCAL_EXTRA_ECONF="${EXTRA_ECONF}" + local LOCAL_ECONF_WRAPPER="${ECONF_WRAPPER}" + + [[ -z "${ECONF_SOURCE}" ]] && ECONF_SOURCE=. + + if [[ -x "${ECONF_SOURCE}/configure" ]] ; then + if [[ -d /usr/share/gnuconfig ]] ; then + local f + for f in $(find "${WORKDIR}" -type f -name config.guess -or -name config.sub ) ; do + echo "econf: updating ${f} with /usr/share/gnuconfig/${f##*/}" + cp -f /usr/share/gnuconfig/${f##*/} ${f} + done + fi + + [[ -z "${CBUILD}" ]] || LOCAL_EXTRA_ECONF="--build=${CBUILD} ${LOCAL_EXTRA_ECONF}" + [[ -z "${CTARGET}" ]] || LOCAL_EXTRA_ECONF="--target=${CTARGET} ${LOCAL_EXTRA_ECONF}" + + # Check that this is actually what's wanted for multilib etc. + local libcmd= + if [[ -n "${ABI}" ]] ; then + local v="LIBDIR_${ABI}" + if [[ -n "${!v}" ]] ; then + libcmd="--libdir=/usr/$(ebuild_get_libdir)" + fi + fi + + echo ${LOCAL_ECONF_WRAPPER} ${ECONF_SOURCE}/configure \ + --prefix=/usr \ + --host=${CHOST} \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --datadir=/usr/share \ + --sysconfdir=/etc \ + --localstatedir=/var/lib \ + ${libcmd} "$@" ${LOCAL_EXTRA_ECONF} 1>&2 + + ${LOCAL_ECONF_WRAPPER} ${ECONF_SOURCE}/configure \ + --prefix=/usr \ + --host=${CHOST} \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --datadir=/usr/share \ + --sysconfdir=/etc \ + --localstatedir=/var/lib \ + ${libcmd} "$@" ${LOCAL_EXTRA_ECONF} || die "econf failed" + + else + die "No configure script for econf" + fi +} + +einstall() +{ + if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then + local cmd="${EINSTALL_WRAPPER} make prefix=${D}/usr" + cmd="${cmd} mandir=${D}/usr/share/man" + cmd="${cmd} infodir=${D}/usr/share/info" + cmd="${cmd} datadir=${D}/usr/share" + cmd="${cmd} sysconfdir=${D}/etc" + cmd="${cmd} localstatedir=${D}/var/lib" + cmd="${cmd} libdir=${D}/usr/$(ebuild_get_libdir)" + cmd="${cmd} ${EXTRA_EINSTALL} ${@} install" + echo "${cmd}" 1>&2 + ${cmd} || die "einstall failed" + else + die "No Makefile for einstall" + fi +} + +unpack() +{ + dounpack ${@} || die "unpack failed" +} + diff --git a/0.4.0/ebuild/builtin_fetch.bash b/0.4.0/ebuild/builtin_fetch.bash new file mode 100644 index 000000000..e58aace0f --- /dev/null +++ b/0.4.0/ebuild/builtin_fetch.bash @@ -0,0 +1,132 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +builtin_fetch() +{ + [[ -d "${DISTDIR}" ]] || die "DISTDIR \"${DISTDIR}\" is not a directory" + + local a nofetch unique_aa old_aa + for a in ${FLAT_SRC_URI} ; do + local aa=${a##*/} + hasq "${aa}" ${unique_aa} || unique_aa="${unique_aa} ${aa}" + + if [[ -f "${DISTDIR}/${aa}" ]] && [[ "0" != $(stat -c '%s' "${DISTDIR}/${aa}" ) ]] ; then + if [[ "${old_aa}" != "${aa}" ]] ; then + ebuild_section "Already have ${aa}" + old_aa="${aa}" + fi + else + if [[ -f "${DISTDIR}/${aa}" ]] ; then + ebuild_section "Trying to remove existing ${aa}..." + rm -f "${DISTDIR}/${aa}" + fi + + if ! hasq fetch ${RESTRICT} ; then + if [[ "${old_aa}" != "${aa}" ]] ; then + ebuild_section "Need to fetch ${aa}" + old_aa="${aa}" + fi + prg="${PALUDIS_EBUILD_DIR}/fetchers/do$(echo ${a%%://*} )" + if [[ -x "${prg}" ]] ; then + ${prg} "${a}" "${DISTDIR}/${aa}" + else + eerror "Don't know how to fetch '${a}'" + fi + else + if ! [[ "${old_aa}" != "${aa}" ]] ; then + ebuild_section "Can't fetch ${aa}" + old_aa="${aa}" + fi + fi + fi + done + + for a in ${unique_aa} ; do + [[ -f ${DISTDIR}/${a} ]] || nofetch="${nofetch} ${a}" + done + + if [[ -n "${nofetch}" ]] ; then + local c + echo + eerror "Couldn't fetch the following components:" + for c in ${nofetch} ; do + eerror " * ${c}" + done + echo + die "builtin_fetch failed" + fi + + local badfetch= + if [[ -f "${FILESDIR}/digest-${PN}-${PVR%-r0}" ]] ; then + local line items prg + while read line ; do + line=( ${line} ) + if ! hasq "${line[2]}" ${A} ; then + ebuild_section "Skipping check for ${line[2]}" + continue + fi + + prg="${PALUDIS_EBUILD_DIR}/digests/do$(echo ${line[0]} | tr \ + '[[:upper:]]' '[[:lower:]]')" + if [[ -x "${prg}" ]] ; then + ebegin "Checking ${line[0]} for ${line[2]}" + if [[ $("${prg}" "${DISTDIR}/${line[2]}" ) == "${line[1]}" ]] ; then + eend 0 + else + eend 1 + hasq "${line[2]}" ${badfetch} || badfetch="${badfetch} ${line[2]}" + fi + else + einfo "Can't check ${line[0]} for ${line[2]}" + fi + + done < "${FILESDIR}"/digest-${PN}-${PVR%-r0} + else + ebuild_section "No digest file, skipping integrity checks" + fi + + if [[ -n "${badfetch}" ]] ; then + local c + echo + eerror "Bad digests encountered for the following components:" + for c in ${badfetch} ; do + eerror " * ${c}" + done + echo + die "builtin_fetch failed" + fi +} + +ebuild_f_fetch() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${DISTDIR}" + if hasq "fetch" ${RESTRICT} ; then + ebuild_section "Skipping builtin_fetch (RESTRICT)" + elif hasq "fetch" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_fetch (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_fetch" + builtin_fetch + ebuild_section "Done builtin_fetch" + fi + SANDBOX_WRITE="${old_sandbox_write}" +} + + diff --git a/0.4.0/ebuild/builtin_init.bash b/0.4.0/ebuild/builtin_init.bash new file mode 100644 index 000000000..2a45eeaa8 --- /dev/null +++ b/0.4.0/ebuild/builtin_init.bash @@ -0,0 +1,73 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +builtin_init() +{ + export ROOT="${ROOT//+(\/)//}" + + local a + for a in P PV PR PN PVR PF CATEGORY FILESDIR ECLASSDIR PORTDIR \ + DISTDIR KV PALUDIS_TMPDIR PALUDIS_EBUILD_LOG_LEVEL PALUDIS_EBUILD_DIR \ + USERLAND KERNEL ARCH CHOST PALUDIS_COMMAND ROOT ; do + [[ -z "${!a}" ]] && die "\$${a} unset or empty" + declare -r ${a}="${!a}" + done + + for a in FILESDIR ECLASSDIR PORTDIR DISTDIR ; do + [[ -d "${!a}" ]] || die "\$${a} (\"${!a}\") not a directory" + done + + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" ]] ; then + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" || die "Couldn't remove previous work" + fi + + export WORKDIR="${PALUDIS_TMPDIR}/${CATEGORY}/${PF}/work" + mkdir -p "${WORKDIR}" || die "Couldn't create \$WORKDIR (\"${WORKDIR}\")" + declare -r WORKDIR="${WORKDIR}" + + export T="${PALUDIS_TMPDIR}/${CATEGORY}/${PF}/temp/" + mkdir -p "${T}" || die "Couldn't create \$T (\"${T}\")" + declare -r T="${T}" + export PALUDIS_HOME="${HOME}" + export HOME="${T}" + + export D="${PALUDIS_TMPDIR}/${CATEGORY}/${PF}/image/" + export D="${D//+(\/)//}" + mkdir -p "${D}" || die "Couldn't create \$D (\"${D}\")" + declare -r D="${D}" + + export IMAGE="${D}" + declare -r IMAGE="${IMAGE}" + + export S="${WORKDIR}/${P}" +} + +ebuild_f_init() +{ + if hasq "init" ${RESTRICT} ; then + ebuild_section "Skipping builtin_init (RESTRICT)" + elif hasq "init" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_init (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_init" + builtin_init + ebuild_section "Done builtin_init" + fi +} + diff --git a/0.4.0/ebuild/builtin_merge.bash b/0.4.0/ebuild/builtin_merge.bash new file mode 100644 index 000000000..6859cb76d --- /dev/null +++ b/0.4.0/ebuild/builtin_merge.bash @@ -0,0 +1,118 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +builtin_merge() +{ + ebuild_section "Merging to '${ROOT:-/}'..." + + shopt -q dotglob + local olddotglob=$? + shopt -s dotglob + + local dbdir="${ROOT%/}"/var/db/pkg/"${CATEGORY}/${PF}" + ebuild_section "Writing VDB entry to '${dbdir}'..." + install -d "${dbdir}" || die "couldn't make pkg db directory (\"${dbdir}\")" + install -d "${ROOT%/}"/var/db/pkg/.cache || die "couldn't make pkg db cache" + + local v VDB_FORMAT="paludis-2" + for v in CATEGORY CBUILD CHOST DEPEND DESCRIPTION EAPI \ + FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \ + PROVIDE RDEPEND SLOT SRC_URI USE CONFIG_PROTECT CONFIG_PROTECT_MASK \ + VDB_FORMAT ; do + echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed" + done + for v in ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX CXXFLAGS \ + EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE LDFLAGS LIBCXXFLAGS \ + REPOSITORY ; do + [[ -z "${!v}" ]] && continue + echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed" + done + + if [[ -n ${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT} ]]; then + CONFIG_PROTECT=${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT} + fi + if [[ -n ${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK} ]]; then + CONFIG_PROTECT_MASK=${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK} + fi + + export CONFIG_PROTECT="${CONFIG_PROTECT}" + export CONFIG_PROTECT_MASK="${CONFIG_PROTECT_MASK}" + + [[ -f "${EBUILD}" ]] && cp "${EBUILD}" ${dbdir}/ + + local reinstall= + if [[ -f "${dbdir}/CONTENTS" ]] ; then + mv "${dbdir}/CONTENTS" "${dbdir}/OLDCONTENTS" || die "save contents failed" + reinstall="yes" + fi + + ( set ; export -p | sed 's:^declare -rx:declare -x:' ) | bzip2 > ${dbdir}/environment.bz2 + > ${dbdir}/CONTENTS + + if [[ -n "${D}" ]] && [[ -d "${D}" ]] ; then + install -d "${ROOT%/}/" || die "couldn't make \${ROOT} (\"${ROOT}\")" + if [[ -d "${D}" ]] ; then + merge "${D%/}/" "${ROOT%/}/" "${dbdir}/CONTENTS" \ + || die "merge failed" + fi + fi + + if ! /bin/sh -c 'echo Good, our shell is still usable' ; then + echo "Looks like our shell broke. Trying an ldconfig to fix it..." + ldconfig -r ${ROOT} + fi + + if [[ -n "${reinstall}" ]] ; then + unmerge "${ROOT%/}/" "${dbdir}/OLDCONTENTS" \ + || die "unmerge failed" + + if ! /bin/sh -c 'echo Good, our shell is still usable' ; then + echo "Looks like our shell broke. Trying an ldconfig to fix it..." + ldconfig -r ${ROOT} + fi + + rm -f "${dbdir}/OLDCONTENTS" + fi + + [[ $olddotglob != 0 ]] && shopt -u dotglob + shopt -q dotglob + [[ $olddotglob == $? ]] || ebuild_notice "warning" "shopt dotglob restore failed" +} + +ebuild_f_merge() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + local old_sandbox_on="${SANDBOX_ON}" + [[ "$(canonicalise ${ROOT} )" != "/" ]] || SANDBOX_ON=0 + + if hasq "merge" ${RESTRICT} ; then + ebuild_section "Skipping builtin_merge (RESTRICT)" + elif hasq "merge" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_merge (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_merge" + builtin_merge + ebuild_section "Done builtin_merge" + fi + + SANDBOX_WRITE="${old_sandbox_write}" + SANDBOX_ON="${old_sandbox_on}" +} + diff --git a/0.4.0/ebuild/builtin_metadata.bash b/0.4.0/ebuild/builtin_metadata.bash new file mode 100644 index 000000000..35f408565 --- /dev/null +++ b/0.4.0/ebuild/builtin_metadata.bash @@ -0,0 +1,39 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +ebuild_f_metadata() +{ + local key + + for key in DEPEND RDEPEND PDEPEND IUSE SLOT SRC_URI RESTRICT LICENSE \ + KEYWORDS INHERITED PROVIDE EAPI HOMEPAGE DESCRIPTION E_IUSE \ + E_DEPEND E_RDEPEND E_PDEPEND E_KEYWORDS ; do + set -o noglob + local k=${!key} + k=${k/\\/\\\\} + k=${k/\"/\\\"} + echo "${key}=\""${k}"\"" + set +o noglob + done +} + diff --git a/0.4.0/ebuild/builtin_strip.bash b/0.4.0/ebuild/builtin_strip.bash new file mode 100644 index 000000000..9e4bb7274 --- /dev/null +++ b/0.4.0/ebuild/builtin_strip.bash @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +builtin_strip() +{ + STRIP=${STRIP:-${CHOST}-strip} + if ! type -p -- ${STRIP} >/dev/null; then + STRIP=strip + fi + PALUDIS_STRIP_FLAGS=${PALUDIS_STRIP_FLAGS:---strip-unneeded} + + for fn in $(find "${D}" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -name '*.so' -or -name '*.so.*' \)); do + local ft=$(file "${fn}") + if [[ $? != 0 || -z ${ft} ]]; then + return 1 + fi + + if [[ ${ft} == *"current ar archive"* ]]; then + echo ${STRIP} -g "${fn}" + ${STRIP} -g "${fn}" + elif [[ ${ft} == *"SB executable"* || ${ft} == *"SB shared object"* ]]; then + echo ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}" + ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}" + fi + done +} + +ebuild_f_strip() +{ + if hasq "strip" ${RESTRICT} ; then + ebuild_section "Skipping builtin_strip (RESTRICT)" + elif hasq "strip" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_strip (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_strip" + builtin_strip + ebuild_section "Done builtin_strip" + fi +} + diff --git a/0.4.0/ebuild/builtin_tidyup.bash b/0.4.0/ebuild/builtin_tidyup.bash new file mode 100644 index 000000000..7d6045914 --- /dev/null +++ b/0.4.0/ebuild/builtin_tidyup.bash @@ -0,0 +1,40 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +builtin_tidyup() +{ + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" ]] ; then + echo rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" 1>&2 + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" || die "Couldn't remove work" + fi +} + +ebuild_f_tidyup() +{ + if hasq "tidyup" ${RESTRICT} ; then + ebuild_section "Skipping builtin_tidyup (RESTRICT)" + elif hasq "tidyup" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_tidyup (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_tidyup" + builtin_tidyup + ebuild_section "Done builtin_tidyup" + fi +} + diff --git a/0.4.0/ebuild/builtin_unmerge.bash b/0.4.0/ebuild/builtin_unmerge.bash new file mode 100644 index 000000000..c965b3342 --- /dev/null +++ b/0.4.0/ebuild/builtin_unmerge.bash @@ -0,0 +1,96 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +builtin_unmerge() +{ + local dbdir="${ROOT}"/var/db/pkg/"${CATEGORY}/${PF}" entry + [[ -d "${dbdir}" ]] || die "couldn't find pkg db directory (\"${dbdir}\")" + + for v in CATEGORY CBUILD CHOST DEPEND DESCRIPTION EAPI \ + FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \ + PROVIDE RDEPEND SLOT SRC_URI USE CONFIG_PROTECT CONFIG_PROTECT_MASK \ + VDB_FORMAT ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX CXXFLAGS \ + EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE LDFLAGS LIBCXXFLAGS \ + REPOSITORY ; do + if [[ -f "${dbdir}/${v}" ]] ; then + eval "${v}=\$(< ${dbdir}/${v} ) || die \"Load key ${v} failed\"" + else + eval "${v}=" + fi + done + + if [[ -f ${dbdir}/CONFIG_PROTECT ]]; then + CONFIG_PROTECT="$(< ${dbdir}/CONFIG_PROTECT) ${CONFIG_PROTECT}" + if [[ -f ${dbdir}/CONFIG_PROTECT_MASK ]]; then + CONFIG_PROTECT_MASK="$(< ${dbdir}/CONFIG_PROTECT_MASK)" + fi + else + eval $(bzcat "${dbdir}/environment.bz2" | while read line; do + line=${line//\'} + if [[ ${line%%=*} == CONFIG_PROTECT ]]; then + echo "CONFIG_PROTECT='${line#*=} ${CONFIG_PROTECT}'" + elif [[ ${line%%=*} == CONFIG_PROTECT_MASK ]]; then + echo "CONFIG_PROTECT_MASK='${line#*=}'" + fi + done) + fi + + if [[ -n ${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT} ]]; then + CONFIG_PROTECT=${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT} + fi + if [[ -n ${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK} ]]; then + CONFIG_PROTECT_MASK=${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK} + fi + + export CONFIG_PROTECT="${CONFIG_PROTECT}" + export CONFIG_PROTECT_MASK="${CONFIG_PROTECT_MASK}" + + unmerge "${ROOT}/" "${dbdir}/CONTENTS" \ + || die "unmerge failed" + + if ! /bin/sh -c 'echo Good, our shell is still usable' ; then + echo "Looks like our shell broke. Trying an ldconfig to fix it..." + ldconfig -r ${ROOT} + fi + + rm -fr "${dbdir}" +} + +ebuild_f_unmerge() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + local old_sandbox_on="${SANDBOX_ON}" + [[ "$(canonicalise ${ROOT} )" != "/" ]] || SANDBOX_ON=0 + + if hasq "unmerge" ${RESTRICT} ; then + ebuild_section "Skipping builtin_unmerge (RESTRICT)" + elif hasq "unmerge" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_unmerge (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_unmerge" + builtin_unmerge + ebuild_section "Done builtin_unmerge" + fi + + SANDBOX_WRITE="${old_sandbox_write}" + SANDBOX_ON="${old_sandbox_on}" +} + + diff --git a/0.4.0/ebuild/builtin_variable.bash b/0.4.0/ebuild/builtin_variable.bash new file mode 100644 index 000000000..3ffa7d623 --- /dev/null +++ b/0.4.0/ebuild/builtin_variable.bash @@ -0,0 +1,24 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +ebuild_f_variable() +{ + echo "${!PALUDIS_VARIABLE}" +} + diff --git a/0.4.0/ebuild/digests/Makefile.am b/0.4.0/ebuild/digests/Makefile.am new file mode 100644 index 000000000..9a2161f22 --- /dev/null +++ b/0.4.0/ebuild/digests/Makefile.am @@ -0,0 +1,26 @@ +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *~ +SUBDIRS = . + +libexecprogdir = $(libexecdir)/paludis/digests/ + +libexecprog_PROGRAMS = \ + dosha256 \ + dormd160 \ + domd5 + +dosha256_SOURCES = dosha256.cc +dosha256_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.a + +dormd160_SOURCES = dormd160.cc +dormd160_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.a + +domd5_SOURCES = domd5.cc +domd5_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.a + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/test/run_test.sh + +AM_CXXFLAGS = -I$(top_srcdir) diff --git a/0.4.0/ebuild/digests/domd5.cc b/0.4.0/ebuild/digests/domd5.cc new file mode 100644 index 000000000..5c6fc2901 --- /dev/null +++ b/0.4.0/ebuild/digests/domd5.cc @@ -0,0 +1,54 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis/digests/md5.hh> +#include <iostream> +#include <cstdlib> +#include <fstream> + +int +main(int argc, char * argv[]) +{ + if (argc >= 3) + { + std::cerr << "usage: " << argv[0] << " [filename]" << std::endl; + return EXIT_FAILURE; + } + + if (argc == 2) + { + std::ifstream f(argv[1]); + if (! f) + { + std::cerr << argv[0] << ": could not open '" << argv[1] << "'" << std::endl; + return EXIT_FAILURE; + } + paludis::MD5 sum(f); + std::cout << sum.hexsum() << std::endl; + } + else + { + paludis::MD5 sum(std::cin); + std::cout << sum.hexsum() << std::endl; + } + +} + + + diff --git a/0.4.0/ebuild/digests/dormd160.cc b/0.4.0/ebuild/digests/dormd160.cc new file mode 100644 index 000000000..bc9a81e5f --- /dev/null +++ b/0.4.0/ebuild/digests/dormd160.cc @@ -0,0 +1,53 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis/digests/rmd160.hh> +#include <iostream> +#include <fstream> +#include <cstdlib> + +int +main(int argc, char * argv[]) +{ + if (argc >= 3) + { + std::cerr << "usage: " << argv[0] << " [filename]" << std::endl; + return EXIT_FAILURE; + } + + if (argc == 2) + { + std::ifstream f(argv[1]); + if (! f) + { + std::cerr << argv[0] << ": could not open '" << argv[1] << "'" << std::endl; + return EXIT_FAILURE; + } + paludis::RMD160 sum(f); + std::cout << sum.hexsum() << std::endl; + } + else + { + paludis::RMD160 sum(std::cin); + std::cout << sum.hexsum() << std::endl; + } + +} + + diff --git a/0.4.0/ebuild/digests/dosha256.cc b/0.4.0/ebuild/digests/dosha256.cc new file mode 100644 index 000000000..fe7fcc763 --- /dev/null +++ b/0.4.0/ebuild/digests/dosha256.cc @@ -0,0 +1,52 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis/digests/sha256.hh> +#include <iostream> +#include <cstdlib> +#include <fstream> + +int +main(int argc, char * argv[]) +{ + if (argc >= 3) + { + std::cerr << "usage: " << argv[0] << " [filename]" << std::endl; + return EXIT_FAILURE; + } + + if (argc == 2) + { + std::ifstream f(argv[1]); + if (! f) + { + std::cerr << argv[0] << ": could not open '" << argv[1] << "'" << std::endl; + return EXIT_FAILURE; + } + paludis::SHA256 sum(f); + std::cout << sum.hexsum() << std::endl; + } + else + { + paludis::SHA256 sum(std::cin); + std::cout << sum.hexsum() << std::endl; + } + +} + diff --git a/0.4.0/ebuild/ebuild.bash b/0.4.0/ebuild/ebuild.bash new file mode 100755 index 000000000..2a2cea543 --- /dev/null +++ b/0.4.0/ebuild/ebuild.bash @@ -0,0 +1,272 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +unalias -a +unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE +eval unset LANG ${!LC_*} + +export SANDBOX_PREDICT="${SANDBOX_PREDICT+${SANDBOX_PREDICT}:}" +export SANDBOX_PREDICT="${SANDBOX_PREDICT}/proc/self/maps:/dev/console:/dev/random" +export SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}" +export SANDBOX_WRITE="${SANDBOX_WRITE}/dev/shm:/dev/stdout:/dev/stderr:/dev/null:/dev/tty" +export SANDBOX_WRITE="${SANDBOX_WRITE}:${PALUDIS_TMPDIR}:/var/cache" +export SANDBOX_WRITE="${SANDBOX_WRITE}:/proc/self/attr:/selinux/context" +export SANDBOX_ON="1" + +shopt -s expand_aliases + +EBUILD_KILL_PID=$$ +alias die='diefunc "$FUNCNAME" "$LINENO"' +alias assert='_pipestatus="${PIPESTATUS[*]}"; [[ -z "${_pipestatus//[ 0]/}" ]] || diefunc "$FUNCNAME" "$LINENO" "$_pipestatus"' +trap 'echo "die trap: exiting with error." 1>&2 ; exit 250' 15 + +export EBUILD_PROGRAM_NAME="$0" + +diefunc() +{ + local func="$1" line="$2" + shift 2 + echo 1>&2 + echo "!!! ERROR in ${CATEGORY:-?}/${PF:-?}:" 1>&2 + echo "!!! In ${func:-?} at line ${line:-?}" 1>&2 + echo "!!! ${*:-(no message provided)}" 1>&2 + echo 1>&2 + + echo "!!! Call stack:" 1>&2 + for (( n = 1 ; n < ${#FUNCNAME[@]} ; ++n )) ; do + funcname=${FUNCNAME[${n}]} + sourcefile=$(basename ${BASH_SOURCE[${n}]}) + lineno=${BASH_LINENO[$(( n - 1 ))]} + echo "!!! * ${funcname} (${sourcefile}:${lineno})" 1>&2 + done + echo 1>&2 + + kill ${EBUILD_KILL_PID} + exit 249 +} + +if [[ -n "${PALUDIS_EBUILD_DIR_FALLBACK}" ]] ; then + export PATH="${PALUDIS_EBUILD_DIR_FALLBACK}/utils:${PATH}" +fi +export PATH="${PALUDIS_EBUILD_DIR}/utils:${PATH}" +EBUILD_MODULES_DIR=$(canonicalise $(dirname $0 ) ) +[[ -d ${EBUILD_MODULES_DIR} ]] || die "${EBUILD_MODULES_DIR} is not a directory" +export PALUDIS_EBUILD_MODULES_DIR="${EBUILD_MODULES_DIR}" + +ebuild_load_module() +{ + source "${EBUILD_MODULES_DIR}/${1}.bash" || die "Error loading module ${1}" +} + +ebuild_load_module echo_functions +ebuild_load_module kernel_functions +ebuild_load_module sandbox +ebuild_load_module portage_stubs +ebuild_load_module list_functions +ebuild_load_module multilib_functions +ebuild_load_module install_functions +ebuild_load_module build_functions +ebuild_load_module eclass_functions + +ebuild_source_profile() +{ + if [[ -f ${1}/parent ]] ; then + while read line; do + ebuild_source_profile $(canonicalise ${1}/${line} ) + done <${1}/parent + fi + + if [[ -f ${1}/make.defaults ]] ; then + eval "$(sed -e 's/^\([a-zA-Z0-9\-_]\+=\)/export \1/' ${1}/make.defaults )" || die "Couldn't source ${1}/make.defaults" + fi + + if [[ -f ${1}/bashrc ]] ; then + source ${1}/bashrc || die "Couldn't source ${1}/bashrc" + fi +} + +save_vars="USE USE_EXPAND" + +for var in ${save_vars} ; do + eval "export save_var_${var}='${!var}'" +done + +if [[ -n "${PALUDIS_PROFILE_DIRS}" ]] ; then + for var in ${PALUDIS_PROFILE_DIRS} ; do + ebuild_source_profile $(canonicalise "${var}") + done +elif [[ -n "${PALUDIS_PROFILE_DIR}" ]] ; then + ebuild_source_profile $(canonicalise "${PALUDIS_PROFILE_DIR}") +fi + +unset ${save_vars} + +for f in ${PALUDIS_BASHRC_FILES} ; do + if [[ -f ${f} ]] ; then + ebuild_notice "debug" "Loading bashrc file ${f}" + source ${f} + else + ebuild_notice "debug" "Skipping bashrc file ${f}" + fi +done + +for var in ${save_vars}; do + if [[ -n ${!var} ]]; then + die "${var} should not be set in bashrc. Aborting." + fi +done + +for var in ${save_vars} ; do + eval "export ${var}=\${save_var_${var}}" +done + +ebuild_load_ebuild() +{ + if [[ -n "${PALUDIS_LOAD_ENVIRONMENT}" ]] ; then + bunzip2 < "${PALUDIS_LOAD_ENVIRONMENT}" > ${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF} \ + || die "Can't extract ${PALUDIS_LOAD_ENVIRONMENT}" + + sed -i \ + -e '/^diefunc ()/,/^}/d' \ + -e '/^perform_hook ()/,/^}/d' \ + -e '/^ROOTPATH=/d' \ + -e '/^PATH=/d' \ + -e '/^T=/d' \ + -e '/^PALUDIS_TMPDIR=/d' \ + -e '/^PALUDIS_EBUILD_LOG_LEVEL=/d' \ + -e '/^PORTDIR=/d' \ + -e '/^FILESDIR=/d' \ + -e '/^ECLASSDIR=/d' \ + -e '/^DISTDIR=/d' \ + -e '/^PALUDIS_EBUILD_DIR=/d' \ + -e '/^PALUDIS_COMMAND=/d' \ + -e '/^ROOT=/d' \ + "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" + + source "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" &>/dev/null \ + || die "Can't load saved environment" + + rm "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" + fi + + export EBUILD="${1}" + if [[ "${CATEGORY}" == "virtual" ]] ; then + if [[ -f "${1}" ]] ; then + source ${1} || die "Error sourcing ebuild '${1}'" + elif [[ -e "${1}" ]] ; then + die "'${1}' exists but is not a regular file" + fi + else + [[ -f "${1}" ]] || die "Ebuild '${1}' is not a file" + source ${1} || die "Error sourcing ebuild '${1}'" + fi + [[ ${RDEPEND-unset} == "unset" ]] && RDEPEND="${DEPEND}" + + IUSE="${IUSE} ${E_IUSE}" + DEPEND="${DEPEND} ${E_DEPEND}" + RDEPEND="${RDEPEND} ${E_RDEPEND}" + PDEPEND="${PDEPEND} ${E_PDEPEND}" + KEYWORDS="${KEYWORDS} ${E_KEYWORDS}" + [[ ${EAPI-unset} == "unset" ]] && EAPI="0" +} + +perform_hook() +{ + export HOOK=${1} + ebuild_notice "debug" "Starting hook '${HOOK}'" + + local old_sandbox_on="${SANDBOX_ON}" + export SANDBOX_ON="0" + + local hook_dir + for hook_dir in ${PALUDIS_HOOK_DIRS} ; do + [[ -d "${hook_dir}/${HOOK}" ]] || continue + local hook_file + for hook_file in "${hook_dir}/${HOOK}/"*.bash ; do + [[ -e "${hook_file}" ]] || continue + ebuild_notice "debug" "Starting hook script '${hook_file}' for '${HOOK}'" + if ! bash "${hook_file}" ; then + ebuild_notice "warning" "Hook '${hook_file}' returned failure" + else + ebuild_notice "warning" "Hook '${hook_file}' returned success" + fi + done + done + + export SANDBOX_ON="${old_sandbox_on}" +} + +ebuild_main() +{ + local action ebuild="$1" + shift + + for action in $@ ; do + case ${action} in + metadata|variable|init|fetch|merge|unmerge|tidyup|strip) + ebuild_load_module builtin_${action} + ;; + + unpack|compile|install|test) + ebuild_load_module src_${action} + ;; + + setup|config|nofetch|preinst|postinst|prerm|postrm) + ebuild_load_module pkg_${action} + ;; + + *) + ebuild_load_module usage_error + ebuild_f_usage_error "Unknown action '${action}'" + exit 1 + ;; + esac + done + + if [[ $1 == metadata ]] || [[ $1 == variable ]] ; then + perform_hook ebuild_${action}_pre + if [[ $1 != variable ]] || [[ -n "${ebuild}" ]] ; then + for f in cut tr date ; do + eval "export ebuild_real_${f}=\"$(which $f )\"" + eval "${f}() { ebuild_notice qa 'global scope ${f}' ; $(which $f ) \"\$@\" ; }" + done + PATH="" ebuild_load_ebuild "${ebuild}" + fi + ebuild_f_${1} || die "${1} failed" + perform_hook ebuild_${action}_post + else + ebuild_load_ebuild "${ebuild}" + for action in $@ ; do + export EBUILD_PHASE="${action}" + perform_hook ebuild_${action}_pre + ebuild_f_${action} || die "${action} failed" + if [[ ${action} == "init" ]] ; then + ebuild_load_ebuild "${ebuild}" + fi + perform_hook ebuild_${action}_post + done + fi +} + +ebuild_main $@ + diff --git a/0.4.0/ebuild/echo_functions.bash.in b/0.4.0/ebuild/echo_functions.bash.in new file mode 100644 index 000000000..4c9978cff --- /dev/null +++ b/0.4.0/ebuild/echo_functions.bash.in @@ -0,0 +1,187 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +@GENERATED_FILE@ + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +[[ -z ${PALUDIS_COLOURS} ]] && PALUDIS_COLOURS=@COLOURSCHEME@ + +COLOUR_GREEN=$'\e[32;01m' +COLOUR_YELLOW=$'\e[33;01m' +COLOUR_RED=$'\e[31;01m' +COLOUR_BLUE=$'\e[34;01m' +COLOUR_PINK=$'\e[35;01m' + +if [[ ${PALUDIS_COLOURS} == pink ]]; then + COLOUR_GOOD=${COLOUR_PINK} + COLOUR_WARN=${COLOUR_YELLOW} + COLOUR_BAD=${COLOUR_RED} + COLOUR_BRACKET=${COLOUR_PINK} +else + COLOUR_GOOD=${COLOUR_GREEN} + COLOUR_WARN=${COLOUR_YELLOW} + COLOUR_BAD=${COLOUR_RED} + COLOUR_BRACKET=${COLOUR_BLUE} +fi + +COLOUR_NORMAL=$'\e[0m' +PALUDIS_ENDCOL=$'\e[A\e['$(( ${COLUMNS:-80} - 7 ))'G' + +einfon() +{ + echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} $*" + PALUDIS_LAST_E_CMD=einfon +} + +einfo() +{ + einfon "$*\n" + PALUDIS_LAST_E_CMD=einfo +} + +elog() +{ + einfo "$@" +} + +ewarn() +{ + echo -e " ${COLOUR_WARN}*${COLOUR_NORMAL} $*" + PALUDIS_LAST_E_CMD=ewarn +} + +eerror() +{ + echo -e " ${COLOUR_BAD}*${COLOUR_NORMAL} $*" + PALUDIS_LAST_E_CMD=eerror +} + +ebegin() +{ + einfo "$* ..." + PALUDIS_LAST_E_CMD=ebegin + PALUDIS_LAST_E_LEN=$(( 4 + ${#msg} )) +} + +_eend() +{ + local retval=${1:-0} efunc=${2:-eerror} msg + shift 2 + + if [[ ${retval} == 0 ]]; then + msg="${COLOUR_BRACKET}[ ${COLOUR_GOOD}ok${COLOUR_BRACKET} ]${COLOUR_NORMAL}" + else + if [[ -n "$*" ]]; then + ${efunc} $* + fi + msg="${COLOUR_BRACKET}[ ${COLOUR_BAD}!!${COLOUR_BRACKET} ]${COLOUR_NORMAL}" + fi + +# printf "%$(( ${COLUMNS:-80} - PALUDIS_LAST_E_LEN - 6))s%b\n" '' "${msg}" + echo -e "${PALUDIS_ENDCOL} ${msg}" + + return ${retval} +} + +eend() +{ + local retval=${1:-0} + shift + _eend ${retval} eerror "$*" + PALUDIS_LAST_E_CMD=eend + return ${retval} +} + +ewend() +{ + local retval=${1:-0} + shift + _eend ${retval} ewarn "$*" + PALUDIS_LAST_E_CMD=ewend + return ${retval} +} + +use_with() +{ + if useq "${1}" ; then + echo "--with-${2:-${1}}${3+=${3}}" + else + echo "--without-${2:-${1}}" + fi +} + +use_enable() +{ + if useq "${1}" ; then + echo "--enable-${2:-${1}}${3+=${3}}" + else + echo "--disable-${2:-${1}}" + fi +} + +ebuild_notice_level() +{ + case "$1" in + debug) + echo "1"; + ;; + + qa) + echo "2"; + ;; + + warning) + echo "3"; + ;; + + silent) + echo "4"; + ;; + + *) + echo "[WARNING.EBUILD] Bad value '$1' for qa level" 1>&2 + echo "2"; + ;; + esac +} + +ebuild_notice() +{ + local level="$1" + shift + + local level_num=$(ebuild_notice_level "${level}" ) + local min_level_num=$(ebuild_notice_level "${PALUDIS_EBUILD_LOG_LEVEL}" ) + + if [[ "${level_num}" -ge "${min_level_num}" ]] ; then + local upper_level=$(echo ${level} | ${ebuild_real_tr:-tr} '[:lower:]' '[:upper:]' ) + echo -n "${EBUILD_PROGRAM_NAME:-ebuild.bash}@$(${ebuild_real_date:-date} +%s ): " 1>&2 + echo "[${upper_level}.EBUILD] $* (from ${EBUILD:-?})" 1>&2 + fi + true +} + +ebuild_section() +{ + echo ">>> $*" +} + diff --git a/0.4.0/ebuild/echo_functions_TEST.bash b/0.4.0/ebuild/echo_functions_TEST.bash new file mode 100644 index 000000000..4c8591817 --- /dev/null +++ b/0.4.0/ebuild/echo_functions_TEST.bash @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis is free software; +# you can redistribute it and/or modify it under the terms of the GNU General +# Public License version 2, as published by the Free Software Foundation. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +use_with_TEST() +{ + export USE="foo" + test_equality "$(use_with foo )" "--with-foo" + test_equality "$(use_with foo bar )" "--with-bar" + test_equality "$(use_with foo bar baz )" "--with-bar=baz" + + export USE="oink" + test_equality "$(use_with foo )" "--without-foo" + test_equality "$(use_with foo bar )" "--without-bar" + test_equality "$(use_with foo bar baz )" "--without-bar" +} + + +use_enable_TEST() +{ + export USE="foo" + test_equality "$(use_enable foo )" "--enable-foo" + test_equality "$(use_enable foo bar )" "--enable-bar" + test_equality "$(use_enable foo bar baz )" "--enable-bar=baz" + + export USE="oink" + test_equality "$(use_enable foo )" "--disable-foo" + test_equality "$(use_enable foo bar )" "--disable-bar" + test_equality "$(use_enable foo bar baz )" "--disable-bar" +} + diff --git a/0.4.0/ebuild/eclass_functions.bash b/0.4.0/ebuild/eclass_functions.bash new file mode 100644 index 000000000..1c742e661 --- /dev/null +++ b/0.4.0/ebuild/eclass_functions.bash @@ -0,0 +1,84 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +EXPORT_FUNCTIONS() +{ + [[ -z "${ECLASS}" ]] && die "EXPORT_FUNCTIONS called but ECLASS undefined" + + local e + for e in "$@" ; do + case "$e" in + pkg_setup|pkg_prerm|pkg_postrm|pkg_preinst|pkg_postinst) + eval "${e}() { ${ECLASS}_${e} \"\$@\" ; }" + ;; + + src_unpack|src_compile|src_install|src_test) + eval "${e}() { ${ECLASS}_${e} \"\$@\" ; }" + ;; + + *) + eval "${e}() { ${ECLASS}_${e} \"\$@\" ; }" + ebuild_notice "qa" "$e should not be in EXPORT_FUNCTIONS for ${ECLASS}" + ;; + esac + done +} + +inherit() +{ + [[ -n "${PALUDIS_SKIP_INHERIT}" ]] && return + + local e ee location= + for e in "$@" ; do + for ee in ${ECLASSDIRS:-${ECLASSDIR}} ; do + [[ -f "${ee}/${e}.eclass" ]] && location="${ee}/${e}.eclass" + done + local old_ECLASS="${ECLASS}" + export ECLASS="${e}" + + local current_IUSE="${IUSE}" current_DEPEND="${DEPEND}" + local current_RDEPEND="${RDEPEND}" current_PDEPEND="${PDEPEND}" + local current_KEYWORDS="${KEYWORDS}" + + unset IUSE DEPEND RDEPEND PDEPEND KEYWORDS + + [[ -z "${location}" ]] && die "Error finding eclass ${e}" + source "${location}" || die "Error sourcing eclass ${e}" + hasq "${ECLASS}" ${INHERITED} || export INHERITED="${INHERITED} ${ECLASS}" + + E_IUSE="${E_IUSE} ${IUSE}" + E_PDEPEND="${E_PDEPEND} ${PDEPEND}" + E_RDEPEND="${E_RDEPEND} ${RDEPEND}" + E_DEPEND="${E_DEPEND} ${DEPEND}" + E_KEYWORDS="${KEYWORDS:+${KEYWORDS} }${E_KEYWORDS}" + + IUSE="${current_IUSE}" + DEPEND="${current_DEPEND}" + RDEPEND="${current_RDEPEND}" + PDEPEND="${current_PDEPEND}" + KEYWORDS="${current_KEYWORDS}" + + export ECLASS="${old_ECLASS}" + done +} + diff --git a/0.4.0/ebuild/fetchers/Makefile.am b/0.4.0/ebuild/fetchers/Makefile.am new file mode 100644 index 000000000..4b57221b7 --- /dev/null +++ b/0.4.0/ebuild/fetchers/Makefile.am @@ -0,0 +1,27 @@ +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *~ dohttp dohttps doftp +SUBDIRS = . + +libexecprogdir = $(libexecdir)/paludis/fetchers/ + +libexecprog_SCRIPTS = \ + dohttp \ + dohttps \ + doftp \ + dofile + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/test/run_test.sh + +TESTS = +EXTRA_DIST = $(libexecprog_SCRIPTS) dowget.in + +check_SCRIPTS = +check_PROGRAMS = $(TESTS) + +AM_CXXFLAGS = -I$(top_srcdir) + +dohttp dohttps doftp : dowget.in + cat $< > $@ diff --git a/0.4.0/ebuild/fetchers/dofile b/0.4.0/ebuild/fetchers/dofile new file mode 100755 index 000000000..fd3e54bf5 --- /dev/null +++ b/0.4.0/ebuild/fetchers/dofile @@ -0,0 +1,6 @@ +#!/bin/bash + +shopt -s extglob +echo cp "/${1##file:+(/)}" "${2}" 1>&2 +cp "/${1##file:+(/)}" "${2}" + diff --git a/0.4.0/ebuild/fetchers/dowget.in b/0.4.0/ebuild/fetchers/dowget.in new file mode 100755 index 000000000..a6d800722 --- /dev/null +++ b/0.4.0/ebuild/fetchers/dowget.in @@ -0,0 +1,10 @@ +#!/bin/bash + +echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" 1>&2 +if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" ; then + exit 0 +else + rm -f "${2}" + exit 1 +fi + diff --git a/0.4.0/ebuild/install_functions.bash b/0.4.0/ebuild/install_functions.bash new file mode 100644 index 000000000..3bab4077e --- /dev/null +++ b/0.4.0/ebuild/install_functions.bash @@ -0,0 +1,110 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +umask 022 +export DESTTREE="/usr" +export INSDESTTREE="" +export EXEDESTTREE="" +export DOCDESTTREE="" +export INSOPTIONS="-m0644" +export EXEOPTIONS="-m0755" +export LIBOPTIONS="-m0644" +export DIROPTIONS="-m0755" +export MOPREFIX="${PN}" + +keepdir() +{ + dodir "$@" + if [[ "${1}" == "-R" ]] || [[ "${1}" == "-r" ]] ; then + shift + find "$@" -type d -printf "${D}/%p/.keep\0" | xargs -0 touch + assert "Failed to create .keep files" + else + local f + for f in "$@" ; do + touch "${D}/${f}/.keep" || die "Couldn't touch .keep in ${f}" + done + fi +} + +into() +{ + if [[ "${1}" == "/" ]] ; then + export DESTTREE= + else + export DESTTREE="${1}" + [[ -d "${D}${DESTTREE}" ]] || install -d "${D}${DESTTREE}" + fi +} + +insinto() +{ + if [[ "${1}" == "/" ]] ; then + export INSDESTTREE= + else + export INSDESTTREE="${1}" + [[ -d "${D}${INSDESTTREE}" ]] || install -d "${D}${INSDESTTREE}" + fi +} + +exeinto() +{ + if [[ "${1}" == "/" ]] ; then + export EXEDESTTREE= + else + export EXEDESTTREE="${1}" + [[ -d "${D}${EXEDESTTREE}" ]] || install -d "${D}${EXEDESTTREE}" + fi +} + +docinto() +{ + if [[ "${1}" == "/" ]] ; then + export DOCDESTTREE= + else + export DOCDESTTREE="${1}" + [[ -d "${D}usr/share/doc/${PF}/${DOCDESTTREE}" ]] || \ + install -d "${D}usr/share/doc/${PF}/${DOCDESTTREE}" + fi +} + +insopts() +{ + export INSOPTIONS="$@" +} + +diropts() +{ + export DIROPTIONS="$@" +} + +exeopts() +{ + export EXEOPTIONS="$@" +} + +libopts() +{ + export LIBOPTIONS="$@" +} + diff --git a/0.4.0/ebuild/kernel_functions.bash b/0.4.0/ebuild/kernel_functions.bash new file mode 100644 index 000000000..554df653e --- /dev/null +++ b/0.4.0/ebuild/kernel_functions.bash @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon functions.sh from Baselayout, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +KV_major() +{ + [[ -z $1 ]] && return 1 + local KV=$@ + echo ${KV%%.*} +} + +KV_minor() +{ + [[ -z $1 ]] && return 1 + local KV=$@ + KV=${KV#*.} + echo ${KV%%.*} +} + +KV_micro() +{ + [[ -z $1 ]] && return 1 + local KV=$@ + KV=${KV#*.*.} + echo ${KV%%[^[:digit:]]*} +} + +KV_to_int() +{ + [[ -z $1 ]] && return 1 + + local major=$(KV_major "$1") + local minor=$(KV_minor "$1") + local micro=$(KV_micro "$1") + echo $(( major * 65536 + minor * 256 + micro )) +} + +get_KV() +{ + echo $(KV_to_int "$(uname -r)") +} diff --git a/0.4.0/ebuild/kernel_functions_TEST.bash b/0.4.0/ebuild/kernel_functions_TEST.bash new file mode 100644 index 000000000..de3a74f2c --- /dev/null +++ b/0.4.0/ebuild/kernel_functions_TEST.bash @@ -0,0 +1,42 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +KV_major_TEST() +{ + test_equality "$(KV_major 2.4.6)" "2" +} + +KV_minor_TEST() +{ + test_equality "$(KV_minor 2.6.16)" "6" + test_equality "$(KV_minor 2.6.7-gentoo-r1)" "6" + test_equality "$(KV_minor 2.4.18-rc1)" "4" +} + +KV_micro_TEST() +{ + test_equality "$(KV_micro 2.6.0)" "0" + test_equality "$(KV_micro 2.5.63-mm8)" "63" + test_equality "$(KV_micro 2.2.0-foo1)" "0" +} + +KV_to_int_TEST() +{ + test_equality "$(KV_to_int 2.6.16)" "132624" +} diff --git a/0.4.0/ebuild/list_functions.bash b/0.4.0/ebuild/list_functions.bash new file mode 100644 index 000000000..53557cb67 --- /dev/null +++ b/0.4.0/ebuild/list_functions.bash @@ -0,0 +1,71 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +use() +{ + useq "${1}" +} + +usev() +{ + if useq "${1}" ; then + echo "${1#!}" + return 0 + else + return 1 + fi +} + +useq() +{ + if [[ "${1:0:1}" == "!" ]] ; then + ! hasq "${1#!}" "${USE}" + else + hasq "${1}" "${USE}" + fi +} + +has() +{ + hasq "${@}" +} + +hasv() +{ + if hasq "${@}" ; then + echo "${1}" + return 0 + else + return 1 + fi +} + +hasq() +{ + local x= want="$1" + shift + for x in $@ ; do + [[ "${x}" == "${want}" ]] && return 0 + done + return 1 +} diff --git a/0.4.0/ebuild/list_functions_TEST.bash b/0.4.0/ebuild/list_functions_TEST.bash new file mode 100644 index 000000000..3bbbc709b --- /dev/null +++ b/0.4.0/ebuild/list_functions_TEST.bash @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis is free software; +# you can redistribute it and/or modify it under the terms of the GNU General +# Public License version 2, as published by the Free Software Foundation. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +use_TEST() +{ + export USE="foo bar" + + use foo ; test_return_code + use bar ; test_return_code + ! use baz ; test_return_code + ! use foofoo ; test_return_code + ! use fo ; test_return_code + + ! use !foo ; test_return_code + ! use !bar ; test_return_code + use !baz ; test_return_code + use !foofoo ; test_return_code + use !fo ; test_return_code +} + +usev_TEST() +{ + export USE="foo bar" + usev foo 1>/dev/null ; test_return_code + test_equality "$(usev foo)" "foo" + + usev bar 1>/dev/null ; test_return_code + test_equality "$(usev bar)" "bar" + + ! usev baz 1>/dev/null ; test_return_code + test_equality "$(usev baz)" "" + + ! usev !foo 1>/dev/null ; test_return_code + test_equality "$(usev !foo)" "" + + ! usev !bar 1>/dev/null ; test_return_code + test_equality "$(usev !bar)" "" + + ! usev baz 1>/dev/null ; test_return_code + test_equality "$(usev !baz)" "baz" +} + +useq_TEST() +{ + export USE="foo bar" + + useq foo ; test_return_code + useq bar ; test_return_code + ! useq baz ; test_return_code + ! useq foofoo ; test_return_code + ! useq fo ; test_return_code + + ! useq !foo ; test_return_code + ! useq !bar ; test_return_code + useq !baz ; test_return_code + useq !foofoo ; test_return_code + useq !fo ; test_return_code +} + diff --git a/0.4.0/ebuild/multilib_functions.bash b/0.4.0/ebuild/multilib_functions.bash new file mode 100644 index 000000000..181339609 --- /dev/null +++ b/0.4.0/ebuild/multilib_functions.bash @@ -0,0 +1,67 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +# Default values. Those used on a non-multilib profile. +export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} +export DEFAULT_ABI=${DEFAULT_ABI:-"default"} +export CFLAGS_default +export LDFLAGS_default +export CHOST_default=${CHOST_default:-${CHOST}} +export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}} +export LIBDIR_default=${CONF_LIBDIR:-"lib"} +export CDEFINE_default + + +ebuild_get_libdir() { + local CONF_LIBDIR + if [[ -n "${CONF_LIBDIR_OVERRIDE}" ]]; then + echo ${CONF_LIBDIR_OVERRIDE} + else + ebuild_get_abi_LIBDIR + fi +} + +ebuild_get_abi_var() { + local flag=$1 + local abi + if [[ $# -gt 1 ]]; then + abi=${2} + elif [[ -n "${ABI}" ]]; then + abi=${ABI} + elif [[ -n "${DEFAULT_ABI}" ]]; then + abi=${DEFAULT_ABI} + else + abi="default" + fi + + local var="${flag}_${abi}" + echo ${!var} +} + +ebuild_get_abi_CFLAGS() { ebuild_get_abi_var CFLAGS "$@"; } +ebuild_get_abi_LDFLAGS() { ebuild_get_abi_var LDFLAGS "$@"; } +ebuild_get_abi_CHOST() { ebuild_get_abi_var CHOST "$@"; } +ebuild_get_abi_CTARGET() { ebuild_get_abi_var CTARGET "$@"; } +ebuild_get_abi_FAKE_TARGETS() { ebuild_get_abi_var FAKE_TARGETS "$@"; } +ebuild_get_abi_CDEFINE() { ebuild_get_abi_var CDEFINE "$@"; } +ebuild_get_abi_LIBDIR() { ebuild_get_abi_var LIBDIR "$@"; } diff --git a/0.4.0/ebuild/pkg_config.bash b/0.4.0/ebuild/pkg_config.bash new file mode 100644 index 000000000..a141d7a31 --- /dev/null +++ b/0.4.0/ebuild/pkg_config.bash @@ -0,0 +1,28 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_config() +{ + eerror "No configuration function is defined" +} + diff --git a/0.4.0/ebuild/pkg_nofetch.bash b/0.4.0/ebuild/pkg_nofetch.bash new file mode 100644 index 000000000..fb509db33 --- /dev/null +++ b/0.4.0/ebuild/pkg_nofetch.bash @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_nofetch() +{ + [[ -z "${A}" ]] && return + + local f g= + for f in ${A} ; do + [[ -f "${DISTDIR}/${A}" ]] && continue + if [[ -z "${g}" ]] ; then + echo "The following files could not be fetched automatically for ${PN}:" + g=no + fi + echo "* ${f}" + done +} + +ebuild_f_nofetch() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${DISTDIR}" + if hasq "nofetch" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_nofetch (SKIP_FUNCTIONS)" + else + local a f= + for a in ${A} ; do + [[ -f "${DISTDIR}/${a}" ]] && continue + f=yes + done + + if [[ -z "${f}" ]] ; then + ebuild_section "Skipping pkg_nofetch (fully fetched already)" + else + ebuild_section "Starting pkg_nofetch" + pkg_nofetch + ebuild_section "Done pkg_nofetch" + die "Manual fetching is required" + fi + fi + SANDBOX_WRITE="${old_sandbox_write}" +} diff --git a/0.4.0/ebuild/pkg_postinst.bash b/0.4.0/ebuild/pkg_postinst.bash new file mode 100644 index 000000000..ac28a4b0d --- /dev/null +++ b/0.4.0/ebuild/pkg_postinst.bash @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_postinst() +{ + : +} + +ebuild_f_postinst() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + + if hasq "postinst" ${RESTRICT} ; then + ebuild_section "Skipping pkg_postinst (RESTRICT)" + elif hasq "postinst" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_postinst (SKIP_FUNCTIONS)" + else + ebuild_section "Starting pkg_postinst" + pkg_postinst + ebuild_section "Done pkg_postinst" + fi + + SANDBOX_WRITE="${old_sandbox_write}" +} + diff --git a/0.4.0/ebuild/pkg_postrm.bash b/0.4.0/ebuild/pkg_postrm.bash new file mode 100644 index 000000000..ac8d76a40 --- /dev/null +++ b/0.4.0/ebuild/pkg_postrm.bash @@ -0,0 +1,47 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_postrm() +{ + : +} + +ebuild_f_postrm() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + + if hasq "postrm" ${RESTRICT} ; then + ebuild_section "Skipping pkg_postrm (RESTRICT)" + elif hasq "postrm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_postrm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting pkg_postrm" + pkg_postrm + ebuild_section "Done pkg_postrm" + fi + + SANDBOX_WRITE="${old_sandbox_write}" +} + + diff --git a/0.4.0/ebuild/pkg_preinst.bash b/0.4.0/ebuild/pkg_preinst.bash new file mode 100644 index 000000000..943e7bdc0 --- /dev/null +++ b/0.4.0/ebuild/pkg_preinst.bash @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_preinst() +{ + : +} + +ebuild_f_preinst() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + + if hasq "preinst" ${RESTRICT} ; then + ebuild_section "Skipping pkg_preinst (RESTRICT)" + elif hasq "preinst" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_preinst (SKIP_FUNCTIONS)" + else + ebuild_section "Starting pkg_preinst" + pkg_preinst + ebuild_section "Done pkg_preinst" + fi + + SANDBOX_WRITE="${old_sandbox_write}" +} + diff --git a/0.4.0/ebuild/pkg_prerm.bash b/0.4.0/ebuild/pkg_prerm.bash new file mode 100644 index 000000000..cc353f1d5 --- /dev/null +++ b/0.4.0/ebuild/pkg_prerm.bash @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_prerm() +{ + : +} + +ebuild_f_prerm() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + + if hasq "prerm" ${RESTRICT} ; then + ebuild_section "Skipping pkg_prerm (RESTRICT)" + elif hasq "prerm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_prerm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting pkg_prerm" + pkg_prerm + ebuild_section "Done pkg_prerm" + fi + + SANDBOX_WRITE="${old_sandbox_write}" +} + diff --git a/0.4.0/ebuild/pkg_setup.bash b/0.4.0/ebuild/pkg_setup.bash new file mode 100644 index 000000000..75cf2f638 --- /dev/null +++ b/0.4.0/ebuild/pkg_setup.bash @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +pkg_setup() +{ + : +} + +ebuild_f_setup() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + + if hasq "setup" ${RESTRICT} ; then + ebuild_section "Skipping pkg_setup (RESTRICT)" + elif hasq "setup" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_setup (SKIP_FUNCTIONS)" + else + ebuild_section "Starting pkg_setup" + pkg_setup + ebuild_section "Done pkg_setup" + fi + + SANDBOX_WRITE="${old_sandbox_write}" +} + diff --git a/0.4.0/ebuild/portage_stubs.bash b/0.4.0/ebuild/portage_stubs.bash new file mode 100644 index 000000000..30a14114e --- /dev/null +++ b/0.4.0/ebuild/portage_stubs.bash @@ -0,0 +1,78 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +has_version() +{ + ${PALUDIS_COMMAND} --has-version "$@" +} + +portageq() +{ + # \todo Make this suck less... + if [[ "$1" == "has_version" ]] ; then + if [[ "$(canonicalise $2 )" != "$(canonicalise $ROOT )" ]] ; then + eerror "Error emulating 'portageq $@':" + die "portageq has_version emulation only works on current ROOT" + else + shift ; shift + has_version "$@" + fi + elif [[ "$1" == "best_version" ]] ; then + if [[ "$(canonicalise $2 )" != "$(canonicalise $ROOT )" ]] ; then + eerror "Error emulating 'portageq $@':" + die "portageq best_version emulation only works on current ROOT" + else + shift ; shift + best_version "$@" + fi + else + eerror "Error emulating 'portageq $@':" + die "portageq emulation for $1 not implemented" + fi +} + +best_version() +{ + ${PALUDIS_COMMAND} --best-version "$@" +} + +check_KV() +{ + die "check_KV not implenented" +} + +debug-print() +{ + : +} + +debug-print-function() +{ + : +} + +debug-print-section() +{ + : +} + diff --git a/0.4.0/ebuild/run_test.bash b/0.4.0/ebuild/run_test.bash new file mode 100644 index 000000000..b5587b9d1 --- /dev/null +++ b/0.4.0/ebuild/run_test.bash @@ -0,0 +1,47 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +shopt -s expand_aliases +shopt -s extglob +set +o posix + +export TEST_STATUS= +export PALUDIS_IN_TEST_FRAMEWORK="yes" + +test_return_code() +{ + local r="$?" + if [[ "0" == "${r}" ]] ; then + echo -n "." + else + echo -n "!{retcode: ${r}}" + export local_test_status="fail" + export TEST_STATUS="fail" + fi +} + +test_equality() +{ + if [[ "${1}" == "${2}" ]] ; then + echo -n "." + else + echo -n "!{'${1}' not equal to '${2}'}" + export local_test_status="fail" + export TEST_STATUS="fail" + fi +} + +echo "Test program ${1}:" +source "$(dirname ${1} )/ebuild.bash" || exit 200 +source "${1}" || exit 200 + +for testname in $(set | grep '_TEST *() *$' ) ; do + [[ ${testname/()} != ${testname} ]] && continue + echo -n "* ${testname%_TEST}: " + export local_test_status="" + ${testname} + [[ -z "$local_test_status" ]] && echo " OK" || echo " FAIL" +done + +[[ -z "$TEST_STATUS" ]] + diff --git a/0.4.0/ebuild/sandbox.bash b/0.4.0/ebuild/sandbox.bash new file mode 100644 index 000000000..d54325c5b --- /dev/null +++ b/0.4.0/ebuild/sandbox.bash @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +addread() +{ + export SANDBOX_READ="${SANDBOX_READ+${SANDBOX_READ}:}${1}" +} + +addwrite() +{ + export SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${1}" +} + +adddeny() +{ + export SANDBOX_DENY="${SANDBOX_DENY+${SANDBOX_DENY}:}${1}" +} + +addpredict() +{ + export SANDBOX_PREDICT="${SANDBOX_PREDICT+${SANDBOX_PREDICT}:}${1}" +} + diff --git a/0.4.0/ebuild/src_compile.bash b/0.4.0/ebuild/src_compile.bash new file mode 100644 index 000000000..8bf66a5bc --- /dev/null +++ b/0.4.0/ebuild/src_compile.bash @@ -0,0 +1,47 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +src_compile() +{ + [[ -x ./configure ]] && econf + if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then + emake || die "emake failed" + fi +} + +ebuild_f_compile() +{ + mkdir -p ${S} + cd ${S} || die "cd to \${S} (\"${S}\") failed" + + if hasq "compile" ${RESTRICT} ; then + ebuild_section "Skipping src_compile (RESTRICT)" + elif hasq "compile" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping src_compile (SKIP_FUNCTIONS)" + else + ebuild_section "Starting src_compile" + src_compile + ebuild_section "Done src_compile" + fi +} + diff --git a/0.4.0/ebuild/src_install.bash b/0.4.0/ebuild/src_install.bash new file mode 100644 index 000000000..42fe02996 --- /dev/null +++ b/0.4.0/ebuild/src_install.bash @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +src_install() +{ + : +} + +ebuild_f_install() +{ + cd ${S} || die "cd to \${S} (\"${S}\") failed" + + if hasq "install" ${RESTRICT} ; then + ebuild_section "Skipping src_install (RESTRICT)" + elif hasq "install" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping src_install (SKIP_FUNCTIONS)" + else + ebuild_section "Starting src_install" + src_install + ebuild_section "Done src_install" + fi +} + diff --git a/0.4.0/ebuild/src_test.bash b/0.4.0/ebuild/src_test.bash new file mode 100644 index 000000000..a34013c30 --- /dev/null +++ b/0.4.0/ebuild/src_test.bash @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +src_test() +{ + if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then + echo "Makefile found, looking for potential test targets" + if make -j1 -n check ; then + echo "Found check target" + emake -j1 check || die "make check failed" + elif make -j1 -n test ; then + echo "Found test target" + emake -j1 test || die "make test failed" + else + echo "No check or test target, skipping tests" + fi + else + echo "No Makefile, skipping tests" + fi +} + +ebuild_f_test() +{ + local old_sandbox_predict="${SANDBOX_PREDICT}" + SANDBOX_PREDICT="${SANDBOX_PREDICT+${SANDBOX_PREDICT}:}/" + + if hasq "test" ${RESTRICT} ; then + ebuild_section "Skipping src_test (RESTRICT)" + elif hasq "test" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping src_test (SKIP_FUNCTIONS)" + else + ebuild_section "Starting src_test" + src_test + ebuild_section "Done src_test" + fi + + SANDBOX_PREDICT="${old_sandbox_predict}" +} + diff --git a/0.4.0/ebuild/src_unpack.bash b/0.4.0/ebuild/src_unpack.bash new file mode 100644 index 000000000..a309c6054 --- /dev/null +++ b/0.4.0/ebuild/src_unpack.bash @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +src_unpack() +{ + [[ -n "${A}" ]] && unpack ${A} +} + +ebuild_f_unpack() +{ + cd ${WORKDIR} || die "cd to \${WORKDIR} (\"${WORKDIR}\") failed" + + if hasq "unpack" ${RESTRICT} ; then + ebuild_section "Skipping src_unpack (RESTRICT)" + elif hasq "unpack" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping src_unpack (SKIP_FUNCTIONS)" + else + ebuild_section "Starting src_unpack" + src_unpack + ebuild_section "Done src_unpack" + fi +} + diff --git a/0.4.0/ebuild/usage_error.bash b/0.4.0/ebuild/usage_error.bash new file mode 100644 index 000000000..165d8a91c --- /dev/null +++ b/0.4.0/ebuild/usage_error.bash @@ -0,0 +1,32 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +ebuild_f_usage_error() +{ + if [[ -z ${1} ]] ; then + die "Usage error" + else + die "Usage error: ${1}" + fi +} + diff --git a/0.4.0/ebuild/utils/Makefile.am b/0.4.0/ebuild/utils/Makefile.am new file mode 100644 index 000000000..063e944f1 --- /dev/null +++ b/0.4.0/ebuild/utils/Makefile.am @@ -0,0 +1,124 @@ +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *~ newlib.so newlib.a dolib.so dolib.a sed + +libexecprogdir = $(libexecdir)/paludis/utils + +if NEED_SED_WRAPPER +libexecprog_SCRIPTS_extra = sed +endif + +libexecprog_SCRIPTS = \ + canonicalise \ + dobin \ + doconfd \ + dodir \ + dodoc \ + doenvd \ + doexe \ + dohard \ + dohtml \ + doinfo \ + doinitd \ + doins \ + dolib \ + dolib.a \ + dolib.so \ + doman \ + domo \ + donewins \ + dosbin \ + dosed \ + dosym \ + dounpack \ + emake \ + fowners \ + fperms \ + getmtime \ + newbin \ + newconfd \ + newdoc \ + newenvd \ + newexe \ + newinitd \ + newins \ + newlib.a \ + newlib.so \ + newman \ + newsbin \ + prepall \ + prepallstrip \ + prepstrip \ + prepallman \ + prepman \ + prepallinfo \ + prepinfo \ + $(libexecprog_SCRIPTS_extra) + +libexecprog_PROGRAMS = merge unmerge +AM_CXXFLAGS = -I$(top_srcdir) + +merge_SOURCES = merge.cc merge_common.cc merge_common.hh +merge_LDADD = \ + $(top_builddir)/paludis/util/libpaludisutil.a \ + $(top_builddir)/paludis/digests/libpaludisdigests.a \ + $(top_builddir)/paludis/selinux/libpaludisselinux.a \ + $(DYNAMIC_LD_LIBS) + +unmerge_SOURCES = unmerge.cc merge_common.cc merge_common.hh +unmerge_LDADD = \ + $(top_builddir)/paludis/util/libpaludisutil.a \ + $(top_builddir)/paludis/digests/libpaludisdigests.a + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \ + TOP_BUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/`" \ + PALUDIS_EBUILD_LOG_LEVEL="silent" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/ebuild/utils/run_test.bash + +TESTS = merge_TEST.bash dobin_TEST.bash unmerge_TEST.bash +check_SCRIPTS = $(TESTS) \ + merge_TEST_setup.sh merge_TEST_cleanup.sh \ + unmerge_TEST_setup.sh unmerge_TEST_cleanup.sh + +EXTRA_DIST = $(libexecprog_SCRIPTS) $(check_SCRIPTS) run_test.bash \ + newlib.so.in newlib.a.in dolib.so.in dolib.a.in prep.in + +newlib.a : newlib.a.in + cat $< > $@ + +newlib.so : newlib.so.in + cat $< > $@ + +dolib.so : dolib.so.in + cat $< > $@ + +dolib.a : dolib.a.in + cat $< > $@ + +sed : sed.in + cat $< > $@ + +prepall: prep.in + cat $< >$@ + +prepallstrip: prep.in + cat $< >$@ + +prepstrip: prep.in + cat $< >$@ + +prepallman: prep.in + cat $< >$@ + +prepman: prep.in + cat $< >$@ + +prepallinfo: prep.in + cat $< >$@ + +prepinfo: prep.in + cat $< >$@ + +check_PROGRAMS = + diff --git a/0.4.0/ebuild/utils/canonicalise b/0.4.0/ebuild/utils/canonicalise new file mode 100755 index 000000000..d070f3450 --- /dev/null +++ b/0.4.0/ebuild/utils/canonicalise @@ -0,0 +1,6 @@ +#!/bin/bash +case $(uname -s) in + FreeBSD) realpath $@ ;; + *) readlink -f $@ ;; +esac + diff --git a/0.4.0/ebuild/utils/dobin b/0.4.0/ebuild/utils/dobin new file mode 100755 index 000000000..506f50f0f --- /dev/null +++ b/0.4.0/ebuild/utils/dobin @@ -0,0 +1,48 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dobin from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ ! -d "${D}${DESTTREE}/bin" ]]; then + install -d "${D}${DESTTREE}/bin" || exit 3 +fi + +ret=0 +for x in "$@" ; do + if [[ -x "${x}" ]]; then + install "${x}" "${D}${DESTTREE}/bin" || ret=2 + else + echo ">>> ${0}: making ${x} executable..." + install -m0755 -o root -g 0 "${x}" "${D}${DESTTREE}/bin" || ret=2 + fi +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/dobin_TEST.bash b/0.4.0/ebuild/utils/dobin_TEST.bash new file mode 100644 index 000000000..b9d0d9c43 --- /dev/null +++ b/0.4.0/ebuild/utils/dobin_TEST.bash @@ -0,0 +1,70 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis is free software; +# you can redistribute it and/or modify it under the terms of the GNU General +# Public License version 2, as published by the Free Software Foundation. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +source ${PALUDIS_EBUILD_DIR}/install_functions.bash + +dobin_TEST() +{ + mkdir -p dobin_TEST_dir/src dobin_TEST_dir/dst ; test_return_code + + echo "one contents" > dobin_TEST_dir/src/one ; test_return_code + chmod +x dobin_TEST_dir/src/one ; test_return_code + + echo "two contents" > dobin_TEST_dir/src/two ; test_return_code + chmod +x dobin_TEST_dir/src/two ; test_return_code + + echo "three contents" > dobin_TEST_dir/src/three ; test_return_code + chmod +x dobin_TEST_dir/src/three ; test_return_code + + export D=dobin_TEST_dir/dst + ${PALUDIS_EBUILD_DIR}/utils/dobin dobin_TEST_dir/src/one &>/dev/null ; test_return_code + ${PALUDIS_EBUILD_DIR}/utils/dobin dobin_TEST_dir/src/two dobin_TEST_dir/src/three &>/dev/null ; test_return_code + + [[ -f dobin_TEST_dir/dst/usr/bin/one ]] ; test_return_code + [[ -f dobin_TEST_dir/dst/usr/bin/two ]] ; test_return_code + [[ -f dobin_TEST_dir/dst/usr/bin/three ]] ; test_return_code + + test_equality "$(< dobin_TEST_dir/dst/usr/bin/one)" "one contents" + test_equality "$(< dobin_TEST_dir/dst/usr/bin/two)" "two contents" + test_equality "$(< dobin_TEST_dir/dst/usr/bin/three)" "three contents" + + rm -fr dobin_TEST_dir +} + +dobin_fail_TEST() +{ + mkdir -p dobin_TEST_dir/src dobin_TEST_dir/dst ; test_return_code + echo "one contents" > dobin_TEST_dir/src/one ; test_return_code + echo "two contents" > dobin_TEST_dir/src/two ; test_return_code + echo "three contents" > dobin_TEST_dir/src/three ; test_return_code + + export D=dobin_TEST_dir/dst + ! ${PALUDIS_EBUILD_DIR}/utils/dobin dobin_TEST_dir/src/four &>/dev/null ; test_return_code + ! ${PALUDIS_EBUILD_DIR}/utils/dobin dobin_TEST_dir/src/one dobin_TEST_dir/src/seven &>/dev/null ; test_return_code + ! ${PALUDIS_EBUILD_DIR}/utils/dobin dobin_TEST_dir/src/eight dobin_TEST_dir/src/one &>/dev/null ; test_return_code + + [[ -f dobin_TEST_dir/dst/usr/bin/one ]] ; test_return_code + ! [[ -f dobin_TEST_dir/dst/usr/bin/four ]] ; test_return_code + ! [[ -f dobin_TEST_dir/dst/usr/bin/five ]] ; test_return_code + ! [[ -f dobin_TEST_dir/dst/usr/bin/six ]] ; test_return_code + + test_equality "$(< dobin_TEST_dir/dst/usr/bin/one)" "one contents" + + rm -fr dobin_TEST_dir +} + diff --git a/0.4.0/ebuild/utils/doconfd b/0.4.0/ebuild/utils/doconfd new file mode 100644 index 000000000..37c453cc9 --- /dev/null +++ b/0.4.0/ebuild/utils/doconfd @@ -0,0 +1,32 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doconfd from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [ ${#} -lt 1 ]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +INSDESTTREE=/etc/conf.d/ +doins "$@" || exit 2 diff --git a/0.4.0/ebuild/utils/dodir b/0.4.0/ebuild/utils/dodir new file mode 100644 index 000000000..52b7c2090 --- /dev/null +++ b/0.4.0/ebuild/utils/dodir @@ -0,0 +1,34 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dodir from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +ret=0 +for x in "$@"; do + install -d ${DIROPTIONS} "${D}${x}" || ret=2 +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/dodoc b/0.4.0/ebuild/utils/dodoc new file mode 100644 index 000000000..bfff299dd --- /dev/null +++ b/0.4.0/ebuild/utils/dodoc @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dodoc from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ $# -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ -z ${PALUDIS_COMPRESS} ]]; then + PALUDIS_COMPRESS="gzip -f -9" +fi + +dir="${D}usr/share/doc/${PF}/${DOCDESTTREE}" +if [[ ! -d "${dir}" ]]; then + install -d "${dir}" || exit 3 +fi + +ret=0 + +for x in "$@"; do + if [[ -s "${x}" ]]; then + install -m0644 "${x}" "${dir}" + ${PALUDIS_COMPRESS} "${dir}/${x##*/}" + elif [[ ! -e "${x}" ]]; then + echo "${0}: ${x} does not exist" >&2 + ret=2 + fi +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/doenvd b/0.4.0/ebuild/utils/doenvd new file mode 100644 index 000000000..7299776f9 --- /dev/null +++ b/0.4.0/ebuild/utils/doenvd @@ -0,0 +1,32 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doenvd from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +export INSDESTTREE=/etc/env.d/ +doins "$@" diff --git a/0.4.0/ebuild/utils/doexe b/0.4.0/ebuild/utils/doexe new file mode 100644 index 000000000..a67166b09 --- /dev/null +++ b/0.4.0/ebuild/utils/doexe @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doexe from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" + exit 1 +fi + +if [[ ! -d "${D}${EXEDESTTREE}" ]]; then + install -d "${D}${EXEDESTTREE}" || exit 3 +fi + +ret=0 + +for x in "$@"; do + if [[ -L ${x} ]]; then + cp "${x}" "${T}" + mysrc="${T}/$(/usr/bin/basename "${x}")" + elif [[ -d ${x} ]]; then + echo "${0}: skipping directory ${x}" >&2 + continue + else + mysrc="${x}" + fi + install ${EXEOPTIONS} "${mysrc}" "${D}${EXEDESTTREE}" || ret=2 +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/dohard b/0.4.0/ebuild/utils/dohard new file mode 100644 index 000000000..b0758e5ae --- /dev/null +++ b/0.4.0/ebuild/utils/dohard @@ -0,0 +1,34 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dohard from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +ln -f "${D}${1}" "${D}${2}" diff --git a/0.4.0/ebuild/utils/dohtml b/0.4.0/ebuild/utils/dohtml new file mode 100644 index 000000000..66d16109c --- /dev/null +++ b/0.4.0/ebuild/utils/dohtml @@ -0,0 +1,115 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dohtml from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +source ${PALUDIS_EBUILD_DIR}/list_functions.bash + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +allowed_exts="png gif html htm jpg css jps" +disallowed_dirs="" +recurse=0 +args=( ) + +split_names() { + list=$1 + if [[ ${list} == *,* ]]; then + echo -n "${list%%,*} " + split_names ${list#*,} + else + echo ${list} + fi +} + +parse_args() { + while [[ ${#} -gt 0 ]]; do + case $1 in + -r) + recurse=1 ;; + -V) + verbose=1 ;; + -A) + allowed_exts="${allowed_exts} $(split_names $2)" + shift + ;; + -a) + allowed_exts="$(split_names $2)" + shift + ;; + -x) + disallowed_dirs="$(split_names $2)" + shift + ;; + *) + args=( "${args[@]}" "$1" ) ;; + esac + shift + done +} + +install_file() { + bn=${1} + dn=${2} + prefix=${3} + local ret=0 + + path=${bn} + [[ -n ${prefix} ]] && path="${prefix}/${path}" + [[ -n ${dn} ]] && path="${dn}/${path}" + + [[ -z ${DOCDESTTREE} ]] && DOCDESTTREE="html" + + dir="${D}usr/share/doc/${PF}/${DOCDESTTREE}/${prefix}" + + if [[ -f ${path} ]]; then + ext="${path##*.}" + if [[ -n ${ext} ]] && has $ext $allowed_exts; then + [[ ! -d ${dir} ]] && install -d "${dir}" + echo "install -m0644 ${path} ${dir}" + install -m0644 "${path}" "${dir}/${bn}" + fi + elif [[ $recurse == 1 && -d ${path} ]] && + ! has "${bn}" ${disallowed_dirs}; then + for f in ${path}/*; do + pfx=${bn} + [[ -n ${prefix} ]] && pfx="${prefix}/${pfx}" + install_file "$(basename "${f}")" "${dn}" "${pfx}" + (( ret += $? )) + done + else + (( ++ret )) + fi + return ${ret} +} + +parse_args "$@" + +retval=0 +for i in "${args[@]}"; do + install_file "$(basename "${i}")" "$(dirname "${i}")" + (( retval += $? )) +done + +exit $retval diff --git a/0.4.0/ebuild/utils/doinfo b/0.4.0/ebuild/utils/doinfo new file mode 100644 index 000000000..746812c9c --- /dev/null +++ b/0.4.0/ebuild/utils/doinfo @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doinfo from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 1 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ ! -d "${D}usr/share/info" ]]; then + install -d "${D}usr/share/info" || exit 3 +fi + +if [[ -z ${PALUDIS_COMPRESS} ]]; then + PALUDIS_COMPRESS="gzip -f -9" +fi + +ret=0 + +for x in "$@"; do + if [[ -e "${x}" ]]; then + install -m0644 "${x}" "${D}usr/share/info" + ${PALUDIS_COMPRESS} "${D}usr/share/info/$(basename "${x}")" + else + echo "${0}: ${x} does not exist" + ret=2 + fi +done + +exit ${ret} + diff --git a/0.4.0/ebuild/utils/doinitd b/0.4.0/ebuild/utils/doinitd new file mode 100644 index 000000000..8fc7080da --- /dev/null +++ b/0.4.0/ebuild/utils/doinitd @@ -0,0 +1,32 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doinitd from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +EXEDESTTREE=/etc/init.d +doexe "$@" diff --git a/0.4.0/ebuild/utils/doins b/0.4.0/ebuild/utils/doins new file mode 100644 index 000000000..2d70f5acf --- /dev/null +++ b/0.4.0/ebuild/utils/doins @@ -0,0 +1,89 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doins from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ ${1} == "-r" ]]; then + DOINSRECUR=y + shift +else + DOINSRECUR=n +fi + +if [[ -z "${INSDEPTH}" ]]; then + declare -i INSDEPTH=0 +fi + +if [[ ${INSDESTTREE} == ${D}* ]]; then + echo "-------------------------------------------------------" >&2 + echo "You should not use \${D} with helpers." >&2 + echo " --> ${INSDESTTREE}" >&2 + echo "-------------------------------------------------------" >&2 + exit 248 +fi + +if [[ ! -d "${D}${INSDESTTREE}" ]]; then + dodir "${INSDESTTREE}" +fi + +ret=0 + +for x in "$@"; do + if [[ -L ${x} ]]; then + cp "${x}" "${T}" + mysrc="${T}/$(basename "${x}")" + elif [[ -d ${x} ]]; then + if [[ ${DOINSRECUR} == "n" ]]; then + continue + fi + + mydir="${INSDESTTREE}/$(basename "${x}")" + find "${x}" -mindepth 1 -maxdepth 1 -exec \ + env \ + INSDESTTREE="${mydir}" \ + INSDEPTH=$((INSDEPTH+1)) \ + ${0} -r {} \; + continue + else + mysrc="${x}" + fi + + install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}" || ret=2 +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/dolib b/0.4.0/ebuild/utils/dolib new file mode 100644 index 000000000..c35b20245 --- /dev/null +++ b/0.4.0/ebuild/utils/dolib @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dolib from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ! -d ${PALUDIS_EBUILD_MODULES_DIR} ]]; then + echo "${0}: \${PALUDIS_EBUILD_MODULES_DIR} not valid; aborting" >&2 + exit 1 +fi + +source "${PALUDIS_EBUILD_MODULES_DIR}/multilib_functions.bash" + +libdir="${D}${DESTTREE}/$(ebuild_get_libdir)" + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" + exit 1 +fi + +if [[ ! -d ${libdir} ]]; then + install -d "${libdir}" || exit 3 +fi + +ret=0 + +for x in "$@"; do + if [[ -e ${x} ]]; then + if [[ ! -L ${x} ]]; then + install ${LIBOPTIONS} "${x}" "${libdir}" || ret=2 + else + ln -s "$(readlink "${x}")" "${libdir}/$(basename "${x}")" || ret=2 + fi + else + echo "${0}: ${x} does not exist" + ret=2 + fi +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/dolib.a.in b/0.4.0/ebuild/utils/dolib.a.in new file mode 100644 index 000000000..e766554dd --- /dev/null +++ b/0.4.0/ebuild/utils/dolib.a.in @@ -0,0 +1,27 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dolib.a from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +LIBOPTIONS="-m0644" dolib "$@" + diff --git a/0.4.0/ebuild/utils/dolib.so.in b/0.4.0/ebuild/utils/dolib.so.in new file mode 100644 index 000000000..d4dcb4a46 --- /dev/null +++ b/0.4.0/ebuild/utils/dolib.so.in @@ -0,0 +1,26 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dolib.so from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +LIBOPTIONS="-m0755" dolib "$@" diff --git a/0.4.0/ebuild/utils/doman b/0.4.0/ebuild/utils/doman new file mode 100644 index 000000000..db13a1821 --- /dev/null +++ b/0.4.0/ebuild/utils/doman @@ -0,0 +1,84 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon doman from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ -z ${PALUDIS_COMPRESS} ]]; then + PALUDIS_COMPRESS="gzip -f -9" +fi + +BASE="/usr/share" +i18n="" + +for x in "$@"; do + if [[ ${x:0:6} == "-i18n=" ]]; then + i18n="${x:6}/" + continue + fi + if [[ ${x} == .keep ]]; then + continue + fi + + suffix=${x##*.} + + if [[ ${suffix} == "gz" ]]; then + compressed="gz" + realname=${x%.*} + suffix=${realname##*.} + else + realname=${x} + compressed="" + fi + + mandir="${i18n}man${suffix:0:1}" + + if [[ ${mandir} =~ 'man[0-9n](|f|p|pm)$' ]]; then + if [[ -s ${x} ]]; then + if [[ ! -d "${D}${BASE}/man/${mandir}" ]]; then + install -d "${D}${BASE}/man/${mandir}" + fi + + install -m0644 "${x}" "${D}${BASE}/man/${mandir}" || ret=2 + + if [[ -z ${compressed} ]]; then + ${PALUDIS_COMPRESS} "${D}${BASE}/man/${mandir}/$(basename "${x}")" + fi + else + echo "${0}: ${x} does not exist" >&2 + ret=2 + fi + else + echo "${0}: '${x}' is probably not a man page; skipping" >&2 + ret=2 + fi +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/domo b/0.4.0/ebuild/utils/domo new file mode 100644 index 000000000..b7a0dd413 --- /dev/null +++ b/0.4.0/ebuild/utils/domo @@ -0,0 +1,54 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon domo from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ ! -d "${D}${DESTTREE}/share/locale" ]]; then + install -d "${D}${DESTTREE}/share/locale" || exit 3 +fi + +ret=0 + +for x in "$@"; do + if [[ -e ${x} ]]; then + mytiny="$(basename "${x}")" + mydir="${D}${DESTTREE}/share/local/${mytiny%.*}/LC_MESSAGES" + if [[ ! -d ${mydir} ]]; then + install -d "${mydir}" + fi + install -m0644 "${x}" "${mydir}/${MOPREFIX}.mo" || ret=2 + else + echo "${0}: ${x} does not exist" >&2 + ret=2 + fi +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/donewins b/0.4.0/ebuild/utils/donewins new file mode 100644 index 000000000..90f037799 --- /dev/null +++ b/0.4.0/ebuild/utils/donewins @@ -0,0 +1,40 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon donewins from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed." >&2 + exit 1 +fi + +ebuild_notice "qa" "${0} is retarded. Don't use it; use newins instead." + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doins "${T}/${2}" diff --git a/0.4.0/ebuild/utils/dosbin b/0.4.0/ebuild/utils/dosbin new file mode 100644 index 000000000..25c625801 --- /dev/null +++ b/0.4.0/ebuild/utils/dosbin @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dosbin from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +if [[ ! -d "${D}${DESTTREE}/sbin" ]]; then + install -d "${D}${DESTTREE}/sbin" || exit 3 +fi + +for x in "$@"; do + if [[ -x ${x} ]]; then + install -m0755 "${x}" "${D}${DESTTREE}/sbin" || exit 2 + else + echo ">>> dosbin: making ${x} executable..." + install -m0755 -o root -g 0 "${x}" "${D}${DESTTREE}/sbin" || exit 2 + fi +done diff --git a/0.4.0/ebuild/utils/dosed b/0.4.0/ebuild/utils/dosed new file mode 100644 index 000000000..ca9dc0429 --- /dev/null +++ b/0.4.0/ebuild/utils/dosed @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dosed from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -lt 1 ]]; then + echo "${0}: at least one argument needed" >&2 + exit 1 +fi + +mysed="s:${D}::g" + +ret=0 + +for x in "$@"; do + y="${D}${x}" + if [[ -e ${y} ]]; then + if [[ -f "${y}" ]]; then + sed -i -e "${mysed}" "${y}" || ret=2 + else + echo "${0}: ${y} is not a regular file" + ret=2 + fi + else + mysed="${x}" + fi +done + +exit ${ret} diff --git a/0.4.0/ebuild/utils/dosym b/0.4.0/ebuild/utils/dosym new file mode 100644 index 000000000..b4a43be9c --- /dev/null +++ b/0.4.0/ebuild/utils/dosym @@ -0,0 +1,42 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon dosym from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" +source ${PALUDIS_EBUILD_DIR}/echo_functions.bash + +if [[ ! -d ${D} ]]; then + echo "${0}: \${D} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +if [[ ! -d $(dirname $2) ]]; then + ebuild_notice "qa" "$0: target directory $2 does not exist; creating. Please fix the ebuild to create it explicitly." + dodir $(dirname $2) +fi + +ln -snf "${1}" "${D}${2}" diff --git a/0.4.0/ebuild/utils/dounpack b/0.4.0/ebuild/utils/dounpack new file mode 100755 index 000000000..65463d221 --- /dev/null +++ b/0.4.0/ebuild/utils/dounpack @@ -0,0 +1,97 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +die() +{ + echo "dounpack: error: $@" 1>&2 + exit 123 +} + +unpack_one() +{ + [[ -z "$1" ]] && die "Bad argument for unpack_one" + [[ -e "$1" ]] || die "${1} doesn't exist" + + case "${x}" in + *.tar) + echo tar xf "${1}" 1>&2 + tar xf "${1}" || die "Couldn't unpack ${1}" + ;; + + *.tar.gz|*.tgz|*.tar.Z) + echo tar zxf "${1}" 1>&2 + tar zxf "${1}" || die "Couldn't unpack ${1}" + ;; + + *.tar.bz2|*.tbz2) + echo tar jxf "${1}" 1>&2 + tar jxf "${1}" || die "Couldn't unpack ${1}" + ;; + + *.zip|*.ZIP|*.jar) + echo unzip -qo "${1}" 1>&2 + unzip -qo "${1}" || die "Couldn't unpack ${1}" + ;; + + *.gz|*.Z|*.z) + echo gzip -dc "${1}" > ${WORKDIR}/$(basename "${1%.*}" ) 1>&2 + gzip -dc "${1}" > ${WORKDIR}/$(basename "${1%.*}" ) || die "Couldn't unpack ${1}" + ;; + + *.bz2) + echo bzip2 -dc "${1}" > ${WORKDIR}/$(basename "${1%.*}" ) 1>&2 + bzip2 -dc "${1}" > ${WORKDIR}/$(basename "${1%.*}" ) || die "Couldn't unpack ${1}" + ;; + + *.rar|*.RAR) + echo unrar x -idq "${1}" 1>&2 + unrar x -idq "${1}" || die "Couldn't unpack ${1}" + ;; + + *.LHa|*.LHA|*.lha|*.lzh) + echo lha xqf "${1}" 1>&2 + lha xqf "${1}" || die "Couldn't unpack ${1}" + ;; + + *.a|*.deb) + echo ar x "${1}" 1&>2 + ar x "${1}" 1>&2 + ;; + + *) + echo "Skipping unpack for ${1}" + ;; + esac + +} + +[[ -z "$@" ]] && die "No arguments given to unpack" + +for x in "$@" ; do + x=$(echo $x ) + echo ">>> Unpacking ${x} to ${PWD}" + [[ "${x:0:2}" == "./" ]] || x="${DISTDIR}/${x}" + unpack_one "${x}" +done + + diff --git a/0.4.0/ebuild/utils/emake b/0.4.0/ebuild/utils/emake new file mode 100755 index 000000000..642d06054 --- /dev/null +++ b/0.4.0/ebuild/utils/emake @@ -0,0 +1,22 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +echo ${EMAKE_WRAPPER} ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@" 1>&2 +${EMAKE_WRAPPER} ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@" + diff --git a/0.4.0/ebuild/utils/fowners b/0.4.0/ebuild/utils/fowners new file mode 100644 index 000000000..4eb208c6e --- /dev/null +++ b/0.4.0/ebuild/utils/fowners @@ -0,0 +1,24 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon fowners from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +chown "${@/#\//${D}/}" diff --git a/0.4.0/ebuild/utils/fperms b/0.4.0/ebuild/utils/fperms new file mode 100644 index 000000000..04c5db7eb --- /dev/null +++ b/0.4.0/ebuild/utils/fperms @@ -0,0 +1,24 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon fperms from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +chmod "${@/#\//${D}/}" diff --git a/0.4.0/ebuild/utils/getmtime b/0.4.0/ebuild/utils/getmtime new file mode 100755 index 000000000..81a78e45f --- /dev/null +++ b/0.4.0/ebuild/utils/getmtime @@ -0,0 +1,5 @@ +#!/bin/bash +case $(uname -s) in + FreeBSD) stat -f '%m' $@ ;; + *) stat -c '%Y' $@ ;; +esac diff --git a/0.4.0/ebuild/utils/merge.cc b/0.4.0/ebuild/utils/merge.cc new file mode 100644 index 000000000..23cb64a55 --- /dev/null +++ b/0.4.0/ebuild/utils/merge.cc @@ -0,0 +1,481 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "merge_common.hh" + +#include <paludis/digests/md5.hh> +#include <paludis/util/dir_iterator.hh> +#include <paludis/util/fs_entry.hh> +#include <paludis/util/log.hh> +#include <paludis/util/pstream.hh> +#include <paludis/util/stringify.hh> +#include <paludis/util/strip.hh> +#include <paludis/util/system.hh> +#include <paludis/util/tokeniser.hh> +#include <paludis/selinux/security_context.hh> + +#include <algorithm> +#include <fstream> +#include <iomanip> +#include <iostream> +#include <iterator> +#include <string> +#include <vector> + +#include <cstdlib> +#include <errno.h> +#include <fcntl.h> +#include <fnmatch.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include "config.h" + +using namespace paludis; +using namespace merge; + +using std::cout; +using std::cerr; +using std::endl; +using std::ifstream; +using std::ofstream; +using std::istreambuf_iterator; +using std::ostreambuf_iterator; + +namespace +{ + int exit_status; + + FSEntry + make_config_protect_name(const FSEntry & name, const FSEntry & file_to_install) + { + int n(0); + + ifstream our_md5_file(stringify(file_to_install).c_str()); + if (! our_md5_file) + throw Failure("Could not get md5 for '" + stringify(file_to_install) + "'"); + MD5 our_md5(our_md5_file); + + FSEntry result(name); + while (true) + { + if (! result.exists()) + return result; + else if (result.is_regular_file()) + { + ifstream other_md5_file(stringify(result).c_str()); + if (! other_md5_file) + throw Failure("Could not get md5 for '" + stringify(result) + "'"); + MD5 other_md5(other_md5_file); + + if (our_md5.hexsum() == other_md5.hexsum()) + return result; + } + + std::stringstream s; + s << std::setw(4) << std::setfill('0') << std::right << n++; + result = FSEntry(stringify(name.dirname() / ("._cfg" + s.str() + "_" + + name.basename()))); + } + } + + /** + * Output stream buffer class that's opened via an FD, so that we can avoid race + * conditions that would be present on the non-Unix-specific standard file + * stream classes. + * + * See \ref TCppSL Ch. 13.13 for what we're doing here. The buffer code is + * based upon the "io/outbuf2.hpp" example in section 13.13.3. + */ + class FDOutputStreamBuf : + public std::streambuf + { + protected: + int fd; + + virtual int_type + overflow(int_type c) + { + if (c != EOF) + { + char z = c; + if (1 != write(fd, &z, 1)) + return EOF; + } + return c; + } + + virtual std::streamsize + xsputn(const char * s, std::streamsize num) + { + return write(fd, s, num); + } + + public: + FDOutputStreamBuf(const int f) : + fd(f) + { + } + }; + + /** + * Member from base initialisation for FDOutputStream. + */ + class FDOutputStreamBase + { + protected: + FDOutputStreamBuf buf; + + public: + FDOutputStreamBase(const int fd) : + buf(fd) + { + } + }; + /** + * Output stream buffer class that's opened via an FD, so that we can avoid race + * conditions that would be present on the non-Unix-specific standard file + * stream classes. + */ + class FDOutputStream : + protected FDOutputStreamBase, + public std::ostream + { + public: + FDOutputStream(const int fd) : + FDOutputStreamBase(fd), + std::ostream(&buf) + { + } + }; + + /** + * RAII holder for a file descriptor. + */ + class FDHolder + { + private: + const int _fd; + + public: + FDHolder(const int fd) : + _fd(fd) + { + } + + ~FDHolder() + { + if (-1 != _fd) + { + ::fsync(_fd); + ::close(_fd); + } + } + + operator int () const + { + return _fd; + } + }; + + void + do_dir(const FSEntry & root, const FSEntry & src_dir, + const FSEntry & dst_dir, ofstream * const contents) + { + Context context("Installing directory in root '" + stringify(root) + "' from '" + + stringify(src_dir) + "' to '" + stringify(dst_dir) + "':"); + + std::string root_str(stringify(root)), dst_dir_str(stringify(dst_dir.dirname())); + if (root_str == "/") + root_str.clear(); + if (0 != dst_dir_str.compare(0, root_str.length(), root_str)) + throw Failure("do_dir confused: '" + root_str + "' '" + dst_dir_str + "'"); + + cout << ">>> " << std::setw(5) << std::left << "[dir]" << " " << + dst_dir_str.substr(root_str.length()) << "/" << dst_dir.basename() << endl; + + if (dst_dir.is_directory()) + /* nothing */; + else if (dst_dir.is_symbolic_link() && dst_dir.realpath().is_directory()) + Log::get_instance()->message(ll_qa, lc_no_context, "Expected '" + stringify(dst_dir) + + "' to be a directory or non-existent, but found a symlink to a directory"); + else if (dst_dir.exists()) + throw Failure("Expected '" + stringify(dst_dir) + + "' to be a directory or non-existent, but found a file"); + else + { + mode_t mode(src_dir.permissions()); + +#ifdef HAVE_SELINUX + CountedPtr<FSCreateCon, count_policy::ExternalCountTag> createcon(0); + if (MatchPathCon::get_instance()->good()) + { + FSCreateCon *p = new FSCreateCon(MatchPathCon::get_instance()->match(dst_dir_str.substr(root_str.length()), + mode)); + createcon.assign(p); + } +#endif + + FSEntry(dst_dir).mkdir(mode); + FSEntry(stringify(dst_dir)).chown(src_dir.owner(), src_dir.group()); + /* the chmod is needed to pick up fancy set*id bits */ + FSEntry(stringify(dst_dir)).chmod(src_dir.permissions()); + } + + *contents << "dir " << dst_dir_str.substr(root_str.length()) << "/" << + dst_dir.basename() << endl; + } + + void + do_obj(const FSEntry & root, const FSEntry & src, + const FSEntry & dst, ofstream * const contents) + { + Context context("Installing object in root '" + stringify(root) + "' from '" + + stringify(src) + "' to '" + stringify(dst) + "':"); + + std::string root_str(stringify(root)), dst_dir_str(stringify(dst.dirname())); + if (root_str == "/") + root_str.clear(); + if (0 != dst_dir_str.compare(0, root_str.length(), root_str)) + throw Failure("do_obj confused: '" + root_str + "' '" + dst_dir_str + "'"); + + cout << ">>> " << std::setw(5) << std::left << "[obj]" << " " << + dst_dir_str.substr(root_str.length()) << "/" << dst.basename(); + + if (dst.is_directory()) + throw Failure("Cannot overwrite directory '" + stringify(dst) + "' with a file"); + else + { + FSEntry real_dst(dst); + + ifstream input_file(stringify(src).c_str()); + if (! input_file) + throw Failure("Cannot read '" + stringify(src) + "'"); + + if (dst.exists()) + { + if (is_config_protected(root, dst)) + { + real_dst = make_config_protect_name(dst, src); + if (dst != real_dst) + cout << " -> " << real_dst << endl; + else + cout << endl; + } + else + { + FSEntry(dst).unlink(); + cout << endl; + } + } + else + cout << endl; + + /* FDHolder must be destroyed before we do the md5 thing, or the + * disk write may not have synced. */ + { +#ifdef HAVE_SELINUX + CountedPtr<FSCreateCon, count_policy::ExternalCountTag> createcon(0); + if (MatchPathCon::get_instance()->good()) + createcon.assign(new + FSCreateCon(MatchPathCon::get_instance()->match(dst_dir_str.substr(root_str.length()) + "/" + + dst.basename(), src.permissions()))); +#endif + FDHolder fd(::open(stringify(real_dst).c_str(), O_WRONLY | O_CREAT, src.permissions())); + if (-1 == fd) + throw Failure("Cannot open '" + stringify(real_dst) + "' for write"); + + if (0 != ::fchown(fd, src.owner(), src.group())) + throw Failure("Cannot fchown '" + stringify(real_dst) + "': " + + stringify(::strerror(errno))); + + /* the chmod is needed for set*id bits, which are dropped by + * umask in the ::open */ + if (0 != ::fchmod(fd, src.permissions())) + throw Failure("Cannot fchmod '" + stringify(real_dst) + "': " + + stringify(::strerror(errno))); + + FDOutputStream output_file(fd); + if (! output_file) + throw Failure("Cannot write '" + stringify(dst) + "'"); + + std::copy((istreambuf_iterator<char>(input_file)), istreambuf_iterator<char>(), + ostreambuf_iterator<char>(output_file)); + } + + ifstream dst_file(stringify(dst).c_str()); + if (! dst_file) + throw Failure("Could not get md5 for '" + stringify(dst_file) + "'"); + MD5 md5(dst_file); + + *contents << "obj " << dst_dir_str.substr(root_str.length()) << "/" << + dst.basename() << " " << md5.hexsum() << " " << + FSEntry(stringify(dst)).mtime() << endl; + } + } + + void + do_sym(const FSEntry & root, const FSEntry & src, + const FSEntry & dst, ofstream * const contents) + { + Context context("Installing symlink in root '" + stringify(root) + "' from '" + + stringify(src) + "' to '" + stringify(dst) + "':"); + + std::string root_str(stringify(root)), dst_dir_str(stringify(dst.dirname())); + if (root_str == "/") + root_str.clear(); + if (0 != dst_dir_str.compare(0, root_str.length(), root_str)) + throw Failure("do_sym confused: '" + root_str + "' '" + dst_dir_str + "'"); + + cout << ">>> " << std::setw(5) << std::left << "[sym]" << " " << + dst_dir_str.substr(root_str.length()) << "/" << dst.basename() << endl; + + if (dst.exists()) + { + if (dst.is_directory()) + throw Failure("Can't overwrite directory '" + stringify(dst) + + "' with symlink to '" + src.readlink() + "'"); + else + FSEntry(dst).unlink(); + } + +#ifdef HAVE_SELINUX + // permissions() on a symlink does weird things, but matchpathcon only cares about the file type, + // so just pass S_IFLNK. + CountedPtr<FSCreateCon, count_policy::ExternalCountTag> createcon(0); + if (MatchPathCon::get_instance()->good()) + createcon.assign(new + FSCreateCon(MatchPathCon::get_instance()->match(dst_dir_str.substr(root_str.length()) + "/" + + dst.basename(), S_IFLNK))); +#endif + + if (0 != ::symlink(src.readlink().c_str(), stringify(dst).c_str())) + { + Log::get_instance()->message(ll_warning, lc_no_context, "Couldn't create symlink '" + + src.readlink() + "' at '" + stringify(dst) + "'"); + exit_status |= 2; + } + + *contents << "sym " << dst_dir_str.substr(root_str.length()) << "/" << + dst.basename() << " -> " << dst.readlink() << " " << + FSEntry(stringify(dst)).mtime() << endl; + } + + void + merge_this(const FSEntry & root, const FSEntry & src_dir, const FSEntry & dst_dir, + ofstream * const contents) + { + Context context("Merging under root '" + stringify(root) + "' from '" + + stringify(src_dir) + "' to '" + stringify(dst_dir) + "':"); + + if (! root.is_directory()) + throw Failure("merge_this called with bad root '" + stringify(root) + "'"); + if (! src_dir.is_directory()) + throw Failure("merge_this called with bad src_dir '" + stringify(src_dir) + "'"); + if (! dst_dir.is_directory()) + throw Failure("merge_this called with bad dst_dir '" + stringify(dst_dir) + "'"); + + for (DirIterator d(src_dir, false), d_end ; d != d_end ; ++d) + { + if (d->is_regular_file()) + do_obj(root, src_dir / d->basename(), dst_dir / d->basename(), contents); + else if (d->is_symbolic_link()) + do_sym(root, src_dir / d->basename(), dst_dir / d->basename(), contents); + else if (d->is_directory()) + { + do_dir(root, src_dir / d->basename(), dst_dir / d->basename(), contents); + merge_this(root, (src_dir / d->basename()).realpath(), (dst_dir / d->basename()).realpath(), contents); + } + else + throw Failure("Don't know how to merge '" + stringify(*d) + "'"); + } + } +} + +int +main(int argc, char * argv[]) +{ + Context context("In main program:"); + +#ifdef HAVE_SELINUX + // If the MatchPathCon initialisation fails, don't attempt to match contexts when merging. + if (! MatchPathCon::get_instance()->good()) + Log::get_instance()->message(ll_warning, lc_no_context, + "matchpathcon_init failed; not setting security contexts"); +#endif + + exit_status = 0; + try + { + if (argc != 4) + throw Failure("Usage: " + stringify(argv[0]) + " src dst contents"); + + Log::get_instance()->set_program_name(argv[0]); + std::string log_level(getenv_with_default("PALUDIS_EBUILD_LOG_LEVEL", "qa")); + + if (log_level == "debug") + Log::get_instance()->set_log_level(ll_debug); + else if (log_level == "qa") + Log::get_instance()->set_log_level(ll_qa); + else if (log_level == "warning") + Log::get_instance()->set_log_level(ll_warning); + else if (log_level == "silent") + Log::get_instance()->set_log_level(ll_silent); + else + throw Failure("bad value for log level"); + + Log::get_instance()->message(ll_debug, lc_no_context, + "CONFIG_PROTECT is " + getenv_with_default("CONFIG_PROTECT", "(unset)")); + Log::get_instance()->message(ll_debug, lc_no_context, + "CONFIG_PROTECT_MASK is " + getenv_with_default("CONFIG_PROTECT_MASK", "(unset)")); + + FSEntry src(argv[1]), dst(argv[2]), contents(argv[3]); + + if (! ((src = src.realpath())).is_directory()) + throw Failure(stringify(argv[1]) + ": not a directory"); + if (! ((dst = dst.realpath())).is_directory()) + throw Failure(stringify(argv[2]) + ": not a directory"); + + ofstream contents_file(stringify(contents).c_str()); + if (! contents_file) + throw Failure(stringify(contents) + ": not writeable"); + + ::umask(0000); + merge_this(dst, src, dst, &contents_file); + return exit_status; + } + catch (const Failure & f) + { + cerr << argv[0] << ": fatal error: " << f.message << endl; + return EXIT_FAILURE; + } + catch (const Exception & e) + { + cerr << argv[0] << ": fatal error:" << endl + << " * " << e.backtrace("\n * ") << e.message() + << " (" << e.what() << ")" << endl; + return EXIT_FAILURE; + } + catch (const std::exception & e) + { + cerr << argv[0] << ": fatal error: " << e.what() << endl; + return EXIT_FAILURE; + } +} + diff --git a/0.4.0/ebuild/utils/merge_TEST.bash b/0.4.0/ebuild/utils/merge_TEST.bash new file mode 100644 index 000000000..ac1cb4db1 --- /dev/null +++ b/0.4.0/ebuild/utils/merge_TEST.bash @@ -0,0 +1,130 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis is free software; +# you can redistribute it and/or modify it under the terms of the GNU General +# Public License version 2, as published by the Free Software Foundation. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +merge_empty_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/empty_src" \ + "merge_TEST_dir/empty_dst" \ + "merge_TEST_dir/empty_contents" 1>/dev/null + test_return_code +} + +merge_files_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/files_src" \ + "merge_TEST_dir/files_dst" \ + "merge_TEST_dir/files_contents" 1>/dev/null + test_return_code + + [[ -f "merge_TEST_dir/files_dst/one" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/files_dst/one)" "contents of one" + + [[ -f "merge_TEST_dir/files_dst/two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/files_dst/two)" "contents of two" +} + +merge_dirs_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/dirs_src" \ + "merge_TEST_dir/dirs_dst" \ + "merge_TEST_dir/dirs_contents" 1>/dev/null + test_return_code + + [[ -d "merge_TEST_dir/dirs_dst/dir_one" ]] ; test_return_code + [[ -d "merge_TEST_dir/dirs_dst/dir_two" ]] ; test_return_code + [[ -d "merge_TEST_dir/dirs_dst/dir_two/dir_three" ]] ; test_return_code + + [[ -f "merge_TEST_dir/dirs_dst/dir_one/one" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/dirs_dst/dir_one/one)" "contents of one" + + [[ -f "merge_TEST_dir/dirs_dst/dir_two/two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/dirs_dst/dir_two/two)" "contents of two" + + [[ -f "merge_TEST_dir/dirs_dst/dir_two/dir_three/three" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/dirs_dst/dir_two/dir_three/three)" "contents of three" +} + +merge_dirs_over_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/dirs_over_src" \ + "merge_TEST_dir/dirs_over_dst" \ + "merge_TEST_dir/dirs_over_contents" 1>/dev/null + test_return_code + + [[ -d "merge_TEST_dir/dirs_over_dst/dir_one/" ]] ; test_return_code + [[ -d "merge_TEST_dir/dirs_over_dst/dir_two/" ]] ; test_return_code + [[ -d "merge_TEST_dir/dirs_over_dst/dir_two/dir_three/" ]] ; test_return_code + + [[ -f "merge_TEST_dir/dirs_over_dst/dir_one/one" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/dirs_over_dst/dir_one/one)" "contents of one" + + [[ -f "merge_TEST_dir/dirs_over_dst/dir_two/two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/dirs_over_dst/dir_two/two)" "contents of two" + + [[ -f "merge_TEST_dir/dirs_over_dst/dir_two/dir_three/three" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/dirs_over_dst/dir_two/dir_three/three)" "contents of three" +} + +merge_links_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/links_src" \ + "merge_TEST_dir/links_dst" \ + "merge_TEST_dir/links_contents" 1>/dev/null + test_return_code + + [[ -f "merge_TEST_dir/links_dst/one" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_dst/one)" "contents of one" + + [[ -f "merge_TEST_dir/links_dst/two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_dst/two)" "contents of two" + + [[ -f "merge_TEST_dir/links_dst/link_to_two" ]] ; test_return_code + [[ -L "merge_TEST_dir/links_dst/link_to_two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_dst/link_to_two)" "contents of two" +} + +merge_links_over_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/links_over_src" \ + "merge_TEST_dir/links_over_dst" \ + "merge_TEST_dir/links_over_contents" 1>/dev/null + test_return_code + + [[ -f "merge_TEST_dir/links_over_dst/one" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_over_dst/one)" "contents of one" + + [[ -f "merge_TEST_dir/links_over_dst/two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_over_dst/two)" "contents of two" + + [[ -f "merge_TEST_dir/links_over_dst/link_to_two" ]] ; test_return_code + [[ -L "merge_TEST_dir/links_over_dst/link_to_two" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_over_dst/link_to_two)" "contents of two" + + [[ -f "merge_TEST_dir/links_over_dst/link_to_three" ]] ; test_return_code + [[ -L "merge_TEST_dir/links_over_dst/link_to_three" ]] ; test_return_code + test_equality "$(< merge_TEST_dir/links_over_dst/link_to_three)" "contents of three" +} +merge_links_over_dir_TEST() +{ + ! ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/links_over_dir_src" \ + "merge_TEST_dir/links_over_dir_dst" \ + "merge_TEST_dir/links_over_dir_contents" &>/dev/null + test_return_code +} + + diff --git a/0.4.0/ebuild/utils/merge_TEST_cleanup.sh b/0.4.0/ebuild/utils/merge_TEST_cleanup.sh new file mode 100755 index 000000000..4b40b8f65 --- /dev/null +++ b/0.4.0/ebuild/utils/merge_TEST_cleanup.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# vim: set ft=sh sw=4 sts=4 et : + +if [ -d merge_TEST_dir ] ; then + rm -fr merge_TEST_dir +else + true +fi + + diff --git a/0.4.0/ebuild/utils/merge_TEST_setup.sh b/0.4.0/ebuild/utils/merge_TEST_setup.sh new file mode 100755 index 000000000..33b23e7bf --- /dev/null +++ b/0.4.0/ebuild/utils/merge_TEST_setup.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# vim: set ft=sh sw=4 sts=4 et : + +mkdir -p merge_TEST_dir/{empty_src,empty_dst} || exit 2 + +mkdir -p merge_TEST_dir/{files_src,files_dst} || exit 2 +echo "contents of one" > merge_TEST_dir/files_src/one +echo "contents of two" > merge_TEST_dir/files_src/two + +mkdir -p merge_TEST_dir/{dirs_src/{dir_one,dir_two/dir_three},dirs_dst} || exit 3 +echo "contents of one" > merge_TEST_dir/dirs_src/dir_one/one +echo "contents of two" > merge_TEST_dir/dirs_src/dir_two/two +echo "contents of three" > merge_TEST_dir/dirs_src/dir_two/dir_three/three + +mkdir -p merge_TEST_dir/{dirs_over_src/{dir_one,dir_two/dir_three},dirs_over_dst} || exit 4 +mkdir -p merge_TEST_dir/dirs_over_dst/{one,real} +ln -s real merge_TEST_dir/dirs_over_dst/two +echo "contents of one" > merge_TEST_dir/dirs_over_src/dir_one/one +echo "contents of two" > merge_TEST_dir/dirs_over_src/dir_two/two +echo "contents of three" > merge_TEST_dir/dirs_over_src/dir_two/dir_three/three + +mkdir -p merge_TEST_dir/{links_src,links_dst} || exit 5 +echo "contents of one" > merge_TEST_dir/links_src/one +echo "contents of two" > merge_TEST_dir/links_src/two +ln -s two merge_TEST_dir/links_src/link_to_two + +mkdir -p merge_TEST_dir/{links_over_src,links_over_dst} || exit 5 +echo "contents of one" > merge_TEST_dir/links_over_src/one +echo "contents of two" > merge_TEST_dir/links_over_src/two +echo "contents of three" > merge_TEST_dir/links_over_src/three +ln -s two merge_TEST_dir/links_over_src/link_to_two +ln -s three merge_TEST_dir/links_over_src/link_to_three +echo "existing file" > merge_TEST_dir/link_to_two +ln -s ../ merge_TEST_dir/links_over_dst/link_to_three + +mkdir -p merge_TEST_dir/{links_over_dir_src,links_over_dir_dst} || exit 5 +echo "contents of one" > merge_TEST_dir/links_over_dir_src/one +echo "contents of two" > merge_TEST_dir/links_over_dir_src/two +echo "contents of three" > merge_TEST_dir/links_over_dir_src/three +ln -s two merge_TEST_dir/links_over_dir_src/link_to_two +ln -s three merge_TEST_dir/links_over_dir_src/link_to_three +mkdir merge_TEST_dir/links_over_dir_dst/link_to_two +echo "existing file" > merge_TEST_dir/links_over_dir_dst/link_to_three + diff --git a/0.4.0/ebuild/utils/merge_common.cc b/0.4.0/ebuild/utils/merge_common.cc new file mode 100644 index 000000000..abb42a2d4 --- /dev/null +++ b/0.4.0/ebuild/utils/merge_common.cc @@ -0,0 +1,83 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "merge_common.hh" + +#include <paludis/util/dir_iterator.hh> +#include <paludis/util/fs_entry.hh> +#include <paludis/util/log.hh> +#include <paludis/util/pstream.hh> +#include <paludis/util/stringify.hh> +#include <paludis/util/strip.hh> +#include <paludis/util/system.hh> +#include <paludis/util/tokeniser.hh> + +#include <algorithm> +#include <fstream> +#include <iomanip> +#include <iostream> +#include <iterator> +#include <string> +#include <vector> + +#include <cstdlib> +#include <errno.h> +#include <fcntl.h> +#include <fnmatch.h> +#include <sys/stat.h> +#include <sys/types.h> + +using namespace paludis; + +std::vector<std::string> +merge::get_config_var(const std::string & var) +{ + std::vector<std::string> result; + WhitespaceTokeniser::get_instance()->tokenise(getenv_with_default(var, ""), + std::back_inserter(result)); + return result; +} + +bool +merge::is_config_protected(const FSEntry & root, const FSEntry & file) +{ + static std::vector<std::string> cfg_pro(get_config_var("CONFIG_PROTECT")), + cfg_pro_mask(get_config_var("CONFIG_PROTECT_MASK")); + + std::string file_str(stringify(file)), root_str(stringify(root)); + if (0 != file_str.compare(0, root_str.length(), root_str)) + throw Failure("is_config_protected confused: '" + root_str + "' '" + file_str + "'"); + file_str.erase(0, root_str.length()); + if (file_str.empty()) + file_str = "/"; + + bool result(false); + for (std::vector<std::string>::const_iterator c(cfg_pro.begin()), + c_end(cfg_pro.end()) ; c != c_end && ! result ; ++c) + if (0 == fnmatch((*c + "/*").c_str(), file_str.c_str(), 0)) + result = true; + + for (std::vector<std::string>::const_iterator c(cfg_pro_mask.begin()), + c_end(cfg_pro_mask.end()) ; c != c_end && result ; ++c) + if (0 == fnmatch((*c + "/*").c_str(), file_str.c_str(), 0)) + result = false; + + return result; +} + diff --git a/0.4.0/ebuild/utils/merge_common.hh b/0.4.0/ebuild/utils/merge_common.hh new file mode 100644 index 000000000..5e0e247c8 --- /dev/null +++ b/0.4.0/ebuild/utils/merge_common.hh @@ -0,0 +1,50 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PALUDIS_GUARD_EBUILD_UTILS_MERGE_COMMON_HH +#define PALUDIS_GUARD_EBUILD_UTILS_MERGE_COMMON_HH 1 + +#include <string> +#include <vector> + +namespace paludis +{ + class FSEntry; +} + +namespace merge +{ + struct Failure + { + std::string message; + + Failure(const std::string & m) : + message(m) + { + }; + }; + + std::vector<std::string> + get_config_var(const std::string & var); + + bool + is_config_protected(const paludis::FSEntry & root, const paludis::FSEntry & file); +} + +#endif diff --git a/0.4.0/ebuild/utils/newbin b/0.4.0/ebuild/utils/newbin new file mode 100644 index 000000000..21792c697 --- /dev/null +++ b/0.4.0/ebuild/utils/newbin @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newbin from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +dobin "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newconfd b/0.4.0/ebuild/utils/newconfd new file mode 100644 index 000000000..77838656c --- /dev/null +++ b/0.4.0/ebuild/utils/newconfd @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newconfd from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doconfd "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newdoc b/0.4.0/ebuild/utils/newdoc new file mode 100644 index 000000000..b4cb50700 --- /dev/null +++ b/0.4.0/ebuild/utils/newdoc @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newdoc from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +dodoc "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newenvd b/0.4.0/ebuild/utils/newenvd new file mode 100644 index 000000000..76f0a7f5e --- /dev/null +++ b/0.4.0/ebuild/utils/newenvd @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newenvd from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doenvd "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newexe b/0.4.0/ebuild/utils/newexe new file mode 100644 index 000000000..9a5cb35df --- /dev/null +++ b/0.4.0/ebuild/utils/newexe @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newexe from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doexe "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newinitd b/0.4.0/ebuild/utils/newinitd new file mode 100644 index 000000000..01ca12b2d --- /dev/null +++ b/0.4.0/ebuild/utils/newinitd @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newinitd from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doinitd "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newins b/0.4.0/ebuild/utils/newins new file mode 100644 index 000000000..2b692adb6 --- /dev/null +++ b/0.4.0/ebuild/utils/newins @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newins from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doins "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newlib.a.in b/0.4.0/ebuild/utils/newlib.a.in new file mode 100644 index 000000000..415a0571c --- /dev/null +++ b/0.4.0/ebuild/utils/newlib.a.in @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newlib.a from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +dolib.a "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newlib.so.in b/0.4.0/ebuild/utils/newlib.so.in new file mode 100644 index 000000000..0701351d8 --- /dev/null +++ b/0.4.0/ebuild/utils/newlib.so.in @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newlib.so from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +dolib.so "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newman b/0.4.0/ebuild/utils/newman new file mode 100644 index 000000000..0dab5fc16 --- /dev/null +++ b/0.4.0/ebuild/utils/newman @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newman from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +doman "${T}/${2}" diff --git a/0.4.0/ebuild/utils/newsbin b/0.4.0/ebuild/utils/newsbin new file mode 100644 index 000000000..da94577f7 --- /dev/null +++ b/0.4.0/ebuild/utils/newsbin @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# Based in part upon newsbin from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +export PATH="${PALUDIS_EBUILD_DIR:+${PALUDIS_EBUILD_DIR}/utils:}${PATH}" + +if [[ ! -d ${T} ]]; then + echo "${0}: \${T} not valid; aborting" >&2 + exit 247 +fi + +if [[ ${#} -ne 2 ]]; then + echo "${0}: exactly two arguments needed" >&2 + exit 1 +fi + +rm -rf "${T}/${2}" +cp "${1}" "${T}/${2}" +dosbin "${T}/${2}" diff --git a/0.4.0/ebuild/utils/prep.in b/0.4.0/ebuild/utils/prep.in new file mode 100644 index 000000000..fcb64959d --- /dev/null +++ b/0.4.0/ebuild/utils/prep.in @@ -0,0 +1,21 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Stephen Bennett <spb@gentoo.org> +# +# This file is part of the Paludis package manager. Paludis 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 +# 2 of the License, or (at your option) any later version. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +ebuild_notice "qa" "Ebuilds shouldn't be calling $0 manually." + diff --git a/0.4.0/ebuild/utils/run_test.bash b/0.4.0/ebuild/utils/run_test.bash new file mode 100644 index 000000000..1f9db4e38 --- /dev/null +++ b/0.4.0/ebuild/utils/run_test.bash @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +shopt -s expand_aliases +shopt -s extglob +set +o posix + +export TEST_STATUS= +export PALUDIS_IN_TEST_FRAMEWORK="yes" + +test_return_code() +{ + local r="$?" + if [[ "0" == "${r}" ]] ; then + echo -n "." + else + echo -n "!{retcode: ${r}}" + export local_test_status="fail" + export TEST_STATUS="fail" + fi +} + +test_equality() +{ + if [[ "${1}" == "${2}" ]] ; then + echo -n "." + else + echo -n "!{'${1}' not equal to '${2}'}" + export local_test_status="fail" + export TEST_STATUS="fail" + fi +} + +if test -f "$TEST_SCRIPT_DIR""${1%.bash}"_"setup.sh" ; then + echo ">>> setup for test ${1%.bash}" + if ! "$TEST_SCRIPT_DIR""${1%.bash}"_"setup.sh" ; then + echo ">>> exiting with error for test ${1%.bash}" + exit 255 + fi +fi + +echo "Test program ${1%.bash}:" +source "${1}" || exit 200 + +for testname in $(set | grep '_TEST *() *$' ) ; do + [[ ${testname/()} != ${testname} ]] && continue + echo -n "* ${testname%_TEST}: " + export local_test_status="" + ${testname} + [[ -z "$local_test_status" ]] && echo " OK" || echo " FAIL" +done + +if test -f "$TEST_SCRIPT_DIR""${1%.bash}"_"cleanup.sh" ; then + echo ">>> cleanup for test ${1%.bash}" + if ! "$TEST_SCRIPT_DIR""${1%.bash}"_"cleanup.sh" ; then + echo ">>> exiting with error for test ${1%.bash}" + exit 255 + fi +fi + +[[ -z "$TEST_STATUS" ]] + diff --git a/0.4.0/ebuild/utils/sed.in b/0.4.0/ebuild/utils/sed.in new file mode 100755 index 000000000..8be311a90 --- /dev/null +++ b/0.4.0/ebuild/utils/sed.in @@ -0,0 +1,2 @@ +#!/bin/bash +gsed $@ diff --git a/0.4.0/ebuild/utils/unmerge.cc b/0.4.0/ebuild/utils/unmerge.cc new file mode 100644 index 000000000..fe455a019 --- /dev/null +++ b/0.4.0/ebuild/utils/unmerge.cc @@ -0,0 +1,235 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "merge_common.hh" + +#include <paludis/digests/md5.hh> + +#include <paludis/util/dir_iterator.hh> +#include <paludis/util/fs_entry.hh> +#include <paludis/util/log.hh> +#include <paludis/util/pstream.hh> +#include <paludis/util/stringify.hh> +#include <paludis/util/strip.hh> +#include <paludis/util/system.hh> +#include <paludis/util/tokeniser.hh> + +#include <algorithm> +#include <fstream> +#include <iomanip> +#include <iostream> +#include <iterator> +#include <string> +#include <deque> +#include <vector> + +#include <cstdlib> +#include <errno.h> +#include <fcntl.h> +#include <fnmatch.h> +#include <sys/stat.h> +#include <sys/types.h> + +using namespace paludis; +using namespace merge; + +using std::cout; +using std::cerr; +using std::endl; +using std::ifstream; + +namespace +{ + int exit_status; + + template <typename Iter_> + void unmerge_contents(const FSEntry & root, const Iter_ begin, const Iter_ end) + { + using std::istreambuf_iterator; + + for (Iter_ cur(begin) ; cur != end ; ++cur) + { + std::vector<std::string> tokens; + WhitespaceTokeniser::get_instance()->tokenise(*cur, std::back_inserter(tokens)); + if (tokens.empty()) + continue; + + if ("obj" == tokens.at(0)) + { + if (tokens.size() != 4) + { + Log::get_instance()->message(ll_warning, lc_no_context, + "Malformed VDB entry '" + *cur + "'"); + exit_status |= 4; + } + else if (! (root / tokens.at(1)).is_regular_file()) + cout << "--- [!type] " << tokens.at(1) << endl; + else if (stringify((root / tokens.at(1)).mtime()) != tokens.at(3)) + cout << "--- [!time] " << tokens.at(1) << endl; + else + { + ifstream md5_file(stringify(root / tokens.at(1)).c_str()); + if (! md5_file) + { + Log::get_instance()->message(ll_warning, lc_no_context, + "Couldn't get md5 for '" + stringify(root / tokens.at(1)) + "'"); + cout << "--- [!md5?] " << tokens.at(1) << endl; + } + else if (MD5(md5_file).hexsum() != tokens.at(2)) + cout << "--- [!md5 ] " << tokens.at(1) << endl; + else if (is_config_protected(root, root / tokens.at(1))) + cout << "--- [cfgpr] " << tokens.at(1) << endl; + else + { + cout << "<<< " << tokens.at(1) << endl; + (root / tokens.at(1)).unlink(); + } + } + } + else if ("sym" == tokens.at(0)) + { + if (tokens.size() != 5) + { + Log::get_instance()->message(ll_warning, lc_no_context, + "Malformed VDB entry '" + *cur + "'"); + exit_status |= 4; + } + else if (! (root / tokens.at(1)).is_symbolic_link()) + cout << "--- [!type] " << tokens.at(1) << endl; + else if (stringify((root / tokens.at(1)).mtime()) != tokens.at(4)) + cout << "--- [!time] " << tokens.at(1) << endl; + else if ((root / tokens.at(1)).readlink() != tokens.at(3)) + cout << "--- [!dest] " << tokens.at(1) << endl; + else + { + cout << "<<< " << tokens.at(1) << endl; + (root / tokens.at(1)).unlink(); + } + } + else if ("misc" == tokens.at(0)) + { + + } + else if ("dir" == tokens.at(0)) + /* nothing */ ; + else + { + Log::get_instance()->message(ll_warning, lc_no_context, + "Skipping unknown VDB entry '" + *cur + "'"); + exit_status |= 2; + } + } + } + + template <typename Iter_> + void unmerge_directories(const FSEntry & root, const Iter_ begin, const Iter_ end) + { + using std::istreambuf_iterator; + + for (Iter_ cur(begin) ; cur != end ; ++cur) + { + std::vector<std::string> tokens; + WhitespaceTokeniser::get_instance()->tokenise(*cur, std::back_inserter(tokens)); + if (tokens.empty()) + continue; + + if ("dir" == tokens.at(0)) + { + if (tokens.size() != 2) + { + Log::get_instance()->message(ll_warning, lc_no_context, + "Malformed VDB entry '" + *cur + "'"); + exit_status |= 8; + } + else if (! (root / tokens.at(1)).is_directory()) + cout << "--- [!type] " << tokens.at(1) << endl; + else if (DirIterator((root / tokens.at(1)), false) != DirIterator()) + cout << "--- [!empt] " << tokens.at(1) << endl; + else + { + cout << "<<< " << tokens.at(1) << endl; + (root / tokens.at(1)).rmdir(); + } + } + } + } +} + +int +main(int argc, char * argv[]) +{ + Context context("In main program:"); + exit_status = 0; + try + { + if (argc != 3) + throw Failure("Usage: " + stringify(argv[0]) + " root contents"); + + Log::get_instance()->set_program_name(argv[0]); + std::string log_level(getenv_with_default("PALUDIS_EBUILD_LOG_LEVEL", "qa")); + + if (log_level == "debug") + Log::get_instance()->set_log_level(ll_debug); + else if (log_level == "qa") + Log::get_instance()->set_log_level(ll_qa); + else if (log_level == "warning") + Log::get_instance()->set_log_level(ll_warning); + else if (log_level == "silent") + Log::get_instance()->set_log_level(ll_silent); + else + throw Failure("bad value for log level"); + + FSEntry root(argv[1]), contents(argv[2]); + + if (! ((root = root.realpath())).is_directory()) + throw Failure(stringify(argv[1]) + ": not a directory"); + + ifstream contents_file(stringify(contents).c_str()); + if (! contents_file) + throw Failure(stringify(contents) + ": not readable"); + + std::deque<std::string> lines; + std::string line; + while (std::getline(contents_file, line)) + lines.push_back(line); + + unmerge_contents(root, lines.begin(), lines.end()); + unmerge_directories(root, lines.rbegin(), lines.rend()); + return exit_status; + } + catch (const Failure & f) + { + cerr << argv[0] << ": fatal error: " << f.message << endl; + return EXIT_FAILURE; + } + catch (const Exception & e) + { + cerr << argv[0] << ": fatal error:" << endl + << " * " << e.backtrace("\n * ") << e.message() + << " (" << e.what() << ")" << endl; + return EXIT_FAILURE; + } + catch (const std::exception & e) + { + cerr << argv[0] << ": fatal error: " << e.what() << endl; + return EXIT_FAILURE; + } +} + + diff --git a/0.4.0/ebuild/utils/unmerge_TEST.bash b/0.4.0/ebuild/utils/unmerge_TEST.bash new file mode 100644 index 000000000..4a168da94 --- /dev/null +++ b/0.4.0/ebuild/utils/unmerge_TEST.bash @@ -0,0 +1,66 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk> +# +# This file is part of the Paludis package manager. Paludis is free software; +# you can redistribute it and/or modify it under the terms of the GNU General +# Public License version 2, as published by the Free Software Foundation. +# +# Paludis 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, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +unmerge_empty_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "unmerge_TEST_dir/empty_src" \ + "unmerge_TEST_dir/empty_dst" \ + "unmerge_TEST_dir/empty_contents" 1>/dev/null + test_return_code + + ${TOP_BUILD_DIR}/ebuild/utils/unmerge "unmerge_TEST_dir/empty_dst" \ + "unmerge_TEST_dir/empty_contents" 1>/dev/null + test_return_code + + ok= + for a in unmerge_TEST_dir/empty_dst/* ; do + [[ -e "$a" ]] || continue + test_equality "$a" "" + ok=no + done + test_equality "$ok" "" +} + +unmerge_files_TEST() +{ + ${TOP_BUILD_DIR}/ebuild/utils/merge "unmerge_TEST_dir/files_src" \ + "unmerge_TEST_dir/files_dst" \ + "unmerge_TEST_dir/files_contents" 1>/dev/null + test_return_code + + ok= + for a in unmerge_TEST_dir/files_dst/* ; do + [[ -e "$a" ]] || continue + ok=yes + break + done + test_equality "$ok" "yes" + + ${TOP_BUILD_DIR}/ebuild/utils/unmerge "unmerge_TEST_dir/files_dst" \ + "unmerge_TEST_dir/files_contents" 1>/dev/null + test_return_code + + ok= + for a in unmerge_TEST_dir/files_dst/* ; do + [[ -e "$a" ]] || continue + test_equality "$a" "" + ok=no + done + test_equality "$ok" "" +} + diff --git a/0.4.0/ebuild/utils/unmerge_TEST_cleanup.sh b/0.4.0/ebuild/utils/unmerge_TEST_cleanup.sh new file mode 100755 index 000000000..e0f01b607 --- /dev/null +++ b/0.4.0/ebuild/utils/unmerge_TEST_cleanup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# vim: set ft=sh sw=4 sts=4 et : + +if [ -d unmerge_TEST_dir ] ; then + rm -fr unmerge_TEST_dir +else + true +fi + + + diff --git a/0.4.0/ebuild/utils/unmerge_TEST_setup.sh b/0.4.0/ebuild/utils/unmerge_TEST_setup.sh new file mode 100755 index 000000000..158e2ae9d --- /dev/null +++ b/0.4.0/ebuild/utils/unmerge_TEST_setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# vim: set ft=sh sw=4 sts=4 et : + +mkdir -p unmerge_TEST_dir/{empty_src,empty_dst} || exit 2 + +mkdir -p unmerge_TEST_dir/{files_src,files_dst} || exit 3 +echo "file one" > unmerge_TEST_dir/files_src/one +echo "file two" > unmerge_TEST_dir/files_src/two |