diff options
Diffstat (limited to 'paludis/repositories')
146 files changed, 6411 insertions, 177 deletions
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/gentoo/Makefile.am index 225039cc3..7d8f1662d 100644 --- a/paludis/repositories/portage/Makefile.am +++ b/paludis/repositories/gentoo/Makefile.am @@ -1,8 +1,10 @@ +SUBDIRS = ebuild . CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda DISTCLEANFILES = \ portage_repository-sr.hh portage_repository-sr.cc \ glsa-sr.hh glsa-sr.cc \ - portage_repository_params-sr.hh portage_repository_params-sr.cc + portage_repository_params-sr.hh portage_repository_params-sr.cc \ + vdb_repository-sr.hh vdb_repository-sr.cc MAINTAINERCLEANFILES = Makefile.in AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ @@ -19,32 +21,32 @@ if MONOLITHIC if ENABLE_GLSA noinst_LTLIBRARIES = \ - libpaludisportagerepository.la \ - libpaludisportagerepositoryxmlthings.la + libpaludisgentoorepository.la \ + libpaludisgentoorepositoryxmlthings.la else noinst_LTLIBRARIES = \ - libpaludisportagerepository.la + libpaludisgentoorepository.la endif else -paludis_repositories_lib_LTLIBRARIES = libpaludisportagerepository.la +paludis_repositories_lib_LTLIBRARIES = libpaludisgentoorepository.la if ENABLE_GLSA -lib_LTLIBRARIES = libpaludisportagerepositoryxmlthings.la +lib_LTLIBRARIES = libpaludisgentoorepositoryxmlthings.la endif endif -paludis_repositories_portage_includedir = $(includedir)/paludis/repositories/portage/ -libpaludisportagerepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 +paludis_repositories_gentoo_includedir = $(includedir)/paludis/repositories/gentoo/ +libpaludisgentoorepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 -paludis_repositories_portage_include_HEADERS = \ +paludis_repositories_gentoo_include_HEADERS = \ glsa.hh \ glsa-sr.hh \ portage_repository-sr.hh \ @@ -62,9 +64,12 @@ paludis_repositories_portage_include_HEADERS = \ eclass_mtimes.hh \ make_ebuild_repository.hh \ use_desc.hh \ - portage_virtual_version_metadata.hh + portage_virtual_version_metadata.hh \ + vdb_repository.hh \ + vdb_version_metadata.hh \ + vdb_repository-sr.hh -libpaludisportagerepository_la_SOURCES = \ +libpaludisgentoorepository_la_SOURCES = \ glsa.cc \ portage_repository.cc \ portage_repository_profile_file.cc \ @@ -81,17 +86,19 @@ libpaludisportagerepository_la_SOURCES = \ use_desc.cc \ portage_virtual_version_metadata.cc \ registration.cc \ - $(paludis_repositories_portage_include_HEADERS) + vdb_repository.cc \ + vdb_version_metadata.cc + $(paludis_repositories_gentoo_include_HEADERS) if MONOLITHIC -libpaludisportagerepository_la_LIBADD = \ - libpaludisportagerepositoryxmlthings.la \ +libpaludisgentoorepository_la_LIBADD = \ + libpaludisgentoorepositoryxmlthings.la \ $(DYNAMIC_LD_LIBS) else -libpaludisportagerepository_la_LIBADD = \ +libpaludisgentoorepository_la_LIBADD = \ $(top_builddir)/paludis/util/libpaludisutil.la \ $(top_builddir)/paludis/libpaludis.la \ $(DYNAMIC_LD_LIBS) @@ -103,7 +110,7 @@ portage_repository_TEST_SOURCES = portage_repository_TEST.cc if MONOLITHIC portage_repository_TEST_LDADD = \ - libpaludisportagerepository.la \ + libpaludisgentoorepository.la \ $(top_builddir)/paludis/util/libpaludisutil.la \ $(top_builddir)/paludis/util/test_extras.o \ $(top_builddir)/paludis/libpaludis.la \ @@ -114,7 +121,7 @@ portage_repository_TEST_LDADD = \ else portage_repository_TEST_LDADD = \ - libpaludisportagerepository.la \ + libpaludisgentoorepository.la \ $(top_builddir)/paludis/util/libpaludisutil.la \ $(top_builddir)/paludis/util/test_extras.o \ $(top_builddir)/paludis/libpaludis.la \ @@ -139,7 +146,13 @@ EXTRA_DIST = \ portage_repository.sr \ xml_things_TEST.cc \ xml_things_TEST_setup.sh \ - xml_things_TEST_cleanup.sh + xml_things_TEST_cleanup.sh \ + vdb_repository_TEST.cc \ + vdb_repository_TEST_setup.sh \ + vdb_repository_TEST_cleanup.sh \ + vdb_repository-sr.hh \ + vdb_repository-sr.cc \ + vdb_repository.sr BUILT_SOURCES = \ portage_repository_params-sr.hh \ @@ -147,18 +160,22 @@ BUILT_SOURCES = \ portage_repository-sr.hh \ portage_repository-sr.cc \ glsa-sr.hh \ - glsa-sr.cc + glsa-sr.cc \ + vdb_repository-sr.hh \ + vdb_repository-sr.cc check_SCRIPTS = \ portage_repository_TEST_setup.sh portage_repository_TEST_cleanup.sh \ - xml_things_TEST_setup.sh xml_things_TEST_cleanup.sh + xml_things_TEST_setup.sh xml_things_TEST_cleanup.sh \ + vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh TESTS_ENVIRONMENT = env \ - PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \ + PALUDIS_EBUILD_DIR="$(top_srcdir)/paludis/repositories/gentoo/ebuild/" \ PALUDIS_SKIP_CONFIG="yes" \ TEST_SCRIPT_DIR="$(srcdir)/" \ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \ - LD_LIBRARY_PATH="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/portage/`" \ + LD_LIBRARY_PATH="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gentoo/`:` \ + $(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gentoo/.libs/`" \ bash $(top_srcdir)/test/run_test.sh portage_repository-sr.hh : portage_repository.sr $(top_srcdir)/misc/make_sr.bash @@ -179,23 +196,30 @@ glsa-sr.hh : glsa.sr $(top_srcdir)/misc/make_sr.bash glsa-sr.cc : glsa.sr $(top_srcdir)/misc/make_sr.bash $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/glsa.sr > $@ -libpaludisportagerepositoryxmlthings_la_SOURCES = xml_things.cc xml_things.hh -libpaludisportagerepositoryxmlthings_la_CXXFLAGS = $(AM_CXXFLAGS) @LIBXML2DEPS_CFLAGS@ +vdb_repository-sr.hh : vdb_repository.sr $(top_srcdir)/misc/make_sr.bash + $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/vdb_repository.sr > $@ + +vdb_repository-sr.cc : vdb_repository.sr $(top_srcdir)/misc/make_sr.bash + $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/vdb_repository.sr > $@ + + +libpaludisgentoorepositoryxmlthings_la_SOURCES = xml_things.cc xml_things.hh +libpaludisgentoorepositoryxmlthings_la_CXXFLAGS = $(AM_CXXFLAGS) @LIBXML2DEPS_CFLAGS@ if MONOLITHIC -libpaludisportagerepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \ +libpaludisgentoorepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \ $(DYNAMIC_LD_LIBS) else -libpaludisportagerepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \ +libpaludisgentoorepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \ $(top_builddir)/paludis/util/libpaludisutil.la \ $(top_builddir)/paludis/libpaludis.la endif -libpaludisportagerepositoryxmlthings_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 +libpaludisgentoorepositoryxmlthings_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 if ENABLE_GLSA @@ -207,11 +231,11 @@ if MONOLITHIC xml_things_TEST_LDADD = \ $(top_builddir)/paludis/util/test_extras.o \ $(top_builddir)/test/libtest.a \ - libpaludisportagerepository.la \ + libpaludisgentoorepository.la \ $(top_builddir)/paludis/libpaludis.la \ $(top_builddir)/paludis/environment/test/libpaludistestenvironment.la \ $(top_builddir)/test/libtest.a \ - $(top_builddir)/paludis/repositories/portage/libpaludisportagerepositoryxmlthings.la \ + libpaludisgentoorepositoryxmlthings.la \ $(top_builddir)/paludis/util/libpaludisutil.la \ $(DYNAMIC_LD_LIBS) @@ -220,7 +244,7 @@ else xml_things_TEST_LDADD = \ $(top_builddir)/paludis/util/test_extras.o \ $(top_builddir)/test/libtest.a \ - libpaludisportagerepository.la \ + libpaludisgentoorepository.la \ $(top_builddir)/paludis/util/libpaludisutil.la \ $(top_builddir)/paludis/libpaludis.la \ $(top_builddir)/paludis/environment/test/libpaludistestenvironment.la \ diff --git a/paludis/repositories/gentoo/ebuild/Makefile.am b/paludis/repositories/gentoo/ebuild/Makefile.am new file mode 100644 index 000000000..431ebc87b --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/Makefile.am @@ -0,0 +1,75 @@ +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *~ +SUBDIRS = . digests utils + +AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ + +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 \ + work_around_broken_utilities.bash + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="$(top_srcdir)/paludis/repositories/gentoo/ebuild/" \ + PALUDIS_EBUILD_LOG_LEVEL="warning" \ + TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/`" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/test/run_test.sh $(top_srcdir)/paludis/repositories/gentoo/ebuild/run_test.bash + +TESTS = echo_functions_TEST.bash list_functions_TEST.bash kernel_functions_TEST.bash \ + merge_TEST.bash unmerge_TEST.bash + +libexecprog_PROGRAMS = merge unmerge +merge_SOURCES = merge.cc merge_common.cc merge_common.hh +merge_LDADD = \ + $(top_builddir)/paludis/util/libpaludisutil.la \ + $(top_builddir)/paludis/digests/libpaludisdigests.la \ + $(top_builddir)/paludis/selinux/libpaludisselinux.la \ + $(DYNAMIC_LD_LIBS) + +unmerge_SOURCES = unmerge.cc merge_common.cc merge_common.hh +unmerge_LDADD = \ + $(top_builddir)/paludis/util/libpaludisutil.la \ + $(top_builddir)/paludis/digests/libpaludisdigests.la + +check_SCRIPTS = $(TESTS) \ + merge_TEST_setup.sh merge_TEST_cleanup.sh \ + unmerge_TEST_setup.sh unmerge_TEST_cleanup.sh \ + run_test.bash $(TESTS) + +EXTRA_DIST = $(libexecprog_SCRIPTS) run_test.bash $(TESTS) $(check_SCRIPTS) + +built-sources : $(BUILT_SOURCES) + for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done + + diff --git a/paludis/repositories/gentoo/ebuild/build_functions.bash b/paludis/repositories/gentoo/ebuild/build_functions.bash new file mode 100644 index 000000000..6e7aa11be --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/build_functions.bash @@ -0,0 +1,110 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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}" + + # If the ebuild passed in --prefix, use that to set --libdir. KDE at least needs this. + + ECONF_PREFIX=/usr + for i in "$@"; do + if [[ ${i} == --prefix=* ]]; then + ECONF_PREFIX=${i#--prefix=} + elif [[ ${i} == --exec-prefix=* ]]; then + ECONF_PREFIX=${i#--exec-prefix=} + fi + done + + local libcmd= + if [[ -n "${ABI}" ]] ; then + local v="LIBDIR_${ABI}" + if [[ -n "${!v}" ]] ; then + libcmd="--libdir=${ECONF_PREFIX}/$(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 makecmd="" + type -p gmake &>/dev/null && makecmd="gmake" || makecmd="make" + local cmd="${EINSTALL_WRAPPER} ${makecmd} 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/paludis/repositories/gentoo/ebuild/builtin_fetch.bash b/paludis/repositories/gentoo/ebuild/builtin_fetch.bash new file mode 100644 index 000000000..c3f6402d0 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_fetch.bash @@ -0,0 +1,137 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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" != $(getfsize "${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 + local d + for d in ${PALUDIS_FETCHERS_DIRS:-${PALUDIS_EBUILD_DIR}/fetchers/} ; do + prg=${d}/do$(echo ${a%%://*} | tr '[:upper:]' '[:lower:]' ) + ebuild_notice "debug" "fetcher program candidate for '${a}' is '${prg}'" + [[ -x "${prg}" ]] && break + done + 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_unhooked "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_unhooked "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}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + + diff --git a/paludis/repositories/gentoo/ebuild/builtin_init.bash b/paludis/repositories/gentoo/ebuild/builtin_init.bash new file mode 100644 index 000000000..d7c5042be --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_init.bash @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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 + if type -p chflags &>/dev/null; then + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" || die "Couldn't remove flags from workdir" + fi + 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 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/paludis/repositories/gentoo/ebuild/builtin_merge.bash b/paludis/repositories/gentoo/ebuild/builtin_merge.bash new file mode 100644 index 000000000..452468e65 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_merge.bash @@ -0,0 +1,140 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +builtin_merge() +{ + ebuild_section "Merging to '${ROOT:-/}'..." + + shopt -q dotglob + local olddotglob=$? + shopt -s dotglob + + local v=$(vdb_path) + if [[ -z "${v}" ]] ; then + v=${ROOT}/var/db/pkg + fi + local dbdir="${v}/${CATEGORY}/${PF}" + ebuild_section "Writing VDB entry to '${dbdir}'..." + install -d "${dbdir}" || die "couldn't make pkg db directory (\"${dbdir}\")" + install -d "${v}/".cache || die "couldn't make pkg db cache" + + local v VDB_FORMAT="paludis-2" COUNTER="$(date +%s )" + for v in CATEGORY CBUILD CHOST COUNTER DEPEND DESCRIPTION EAPI \ + FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \ + PROVIDE RDEPEND SLOT SRC_URI USE CONFIG_PROTECT CONFIG_PROTECT_MASK \ + VDB_FORMAT PKGMANAGER ; do + echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed" + ebuild_notice "debug" "Writing VDB key ${v}=${!v}" + 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" + ebuild_notice "debug" "Writing VDB key ${v}=${!v}" + 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 + + ebuild_notice "debug" "Writing VDB environment.bz2" + for v in ${USE_EXPAND} ; do + ebuild_notice "debug" "USE_EXPAND ${v}=${!v}" + done + ( set ; export -p | sed 's:^declare -rx:declare -x:' ) | bzip2 > ${dbdir}/environment.bz2 + > ${dbdir}/CONTENTS + + local merge=${PALUDIS_EBUILD_DIR}/merge + [[ -x "${merge}" ]] || merge="${PALUDIS_EBUILD_DIR_FALLBACK}"/merge + [[ -x "${merge}" ]] || die "Couldn't find merge" + + local unmerge=${PALUDIS_EBUILD_DIR}/unmerge + [[ -x "${unmerge}" ]] || unmerge="${PALUDIS_EBUILD_DIR_FALLBACK}"/unmerge + [[ -x "${unmerge}" ]] || die "Couldn't find unmerge" + + 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 + + echo hash -r + hash -r + + 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" + + echo hash -r + hash -r + + 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}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + local old_sandbox_on="${SANDBOX_ON}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && [[ "$(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 + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_ON="${old_sandbox_on}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/builtin_metadata.bash b/paludis/repositories/gentoo/ebuild/builtin_metadata.bash new file mode 100644 index 000000000..dbc951fdd --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_metadata.bash @@ -0,0 +1,38 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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/paludis/repositories/gentoo/ebuild/builtin_strip.bash b/paludis/repositories/gentoo/ebuild/builtin_strip.bash new file mode 100644 index 000000000..9a4168e7c --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_strip.bash @@ -0,0 +1,80 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org> +# 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, 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 + +builtin_strip() +{ + STRIP=${STRIP:-${CHOST}-strip} + if ! type -p -- ${STRIP} >/dev/null; then + STRIP=strip + fi + PALUDIS_STRIP_FLAGS=${PALUDIS_STRIP_FLAGS:---strip-unneeded} + + if [[ "${PALUDIS_DEBUG_BUILD}" == "split" ]] ; then + OBJCOPY=${OBJCOPY:-${CHOST}-objcopy} + if ! type -p -- "${OBJCOPY}" &>/dev/null ; then + OBJCOPY=objcopy + fi + if ! type -p -- "${OBJCOPY}" &>/dev/null ; then + die "Can't work out what OBJCOPY should be" + fi + fi + + 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 + if [[ "${PALUDIS_DEBUG_BUILD}" != "internal" ]] ; then + echo ${STRIP} -g "${fn}" + ${STRIP} -g "${fn}" + fi + elif [[ ${ft} == *"SB executable"* || ${ft} == *"SB shared object"* ]]; then + if [[ "${PALUDIS_DEBUG_BUILD}" == "split" ]] ; then + local fd="${D}usr/lib/debug/${fn:${#D}}.debug" + mkdir -p "$(dirname "${fd}" )" + echo ${OBJCOPY} --only-keep-debug "${fn}" "${fd}" + ${OBJCOPY} --only-keep-debug "${fn}" "${fd}" + echo ${OBJCOPY} --add-gnu-debuglink="${fd}" "${fn}" + ${OBJCOPY} --add-gnu-debuglink="${fd}" "${fn}" + chmod a-x,o-w "${fd}" + fi + if [[ "${PALUDIS_DEBUG_BUILD}" != "internal" ]] ; then + echo ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}" + ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}" + fi + 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/paludis/repositories/gentoo/ebuild/builtin_tidyup.bash b/paludis/repositories/gentoo/ebuild/builtin_tidyup.bash new file mode 100644 index 000000000..8927d23b8 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_tidyup.bash @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +builtin_tidyup() +{ + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" ]] ; then + if type -p chflags &>/dev/null; then + echo chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" 1>&2 + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" || die "Couldn't remove flags from workdir" + fi + 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/paludis/repositories/gentoo/ebuild/builtin_unmerge.bash b/paludis/repositories/gentoo/ebuild/builtin_unmerge.bash new file mode 100644 index 000000000..e358d8a3a --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_unmerge.bash @@ -0,0 +1,115 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +builtin_unmerge() +{ + local v=$(${PALUDIS_COMMAND} --configuration-variable installed location 2>/dev/null ) + if [[ -z "${v}" ]] ; then + v=${ROOT}/var/db/pkg + fi + + local dbdir="${v}/${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 + local old_CONFIG_PROTECT="${CONFIG_PROTECT:+${CONFIG_PROTECT} }/etc" + 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) + + # catalyst creates things with an empty CONFIG_PROTECT... + if [[ -z "${CONFIG_PROTECT// }" ]] ; then + ewarn "CONFIG_PROTECT from environment.bz2 is empty" + ewarn "Using a fallback of '${old_CONFIG_PROTECT}'" + CONFIG_PROTECT="${old_CONFIG_PROTECT}" + fi + 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}" + + local unmerge=${PALUDIS_EBUILD_DIR}/unmerge + [[ -x "${unmerge}" ]] || unmerge="${PALUDIS_EBUILD_DIR_FALLBACK}"/unmerge + [[ -x "${unmerge}" ]] || die "Couldn't find unmerge" + + ${unmerge} "${ROOT}/" "${dbdir}/CONTENTS" || die "unmerge failed" + + echo hash -r + hash -r + + 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}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + local old_sandbox_on="${SANDBOX_ON}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && [[ "$(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 + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_ON="${old_sandbox_on}" + true +} + + diff --git a/paludis/repositories/gentoo/ebuild/builtin_variable.bash b/paludis/repositories/gentoo/ebuild/builtin_variable.bash new file mode 100644 index 000000000..e140188d7 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/builtin_variable.bash @@ -0,0 +1,23 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +ebuild_f_variable() +{ + echo "${!PALUDIS_VARIABLE}" +} + diff --git a/paludis/repositories/gentoo/ebuild/digests/Makefile.am b/paludis/repositories/gentoo/ebuild/digests/Makefile.am new file mode 100644 index 000000000..d4ad64597 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/digests/Makefile.am @@ -0,0 +1,31 @@ +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.la + +dormd160_SOURCES = dormd160.cc +dormd160_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.la + +domd5_SOURCES = domd5.cc +domd5_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.la + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/test/run_test.sh + +AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ + +built-sources : $(BUILT_SOURCES) + for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done + + diff --git a/paludis/repositories/gentoo/ebuild/digests/domd5.cc b/paludis/repositories/gentoo/ebuild/digests/domd5.cc new file mode 100644 index 000000000..d139f472e --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/digests/domd5.cc @@ -0,0 +1,54 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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/paludis/repositories/gentoo/ebuild/digests/dormd160.cc b/paludis/repositories/gentoo/ebuild/digests/dormd160.cc new file mode 100644 index 000000000..47fcd7f00 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/digests/dormd160.cc @@ -0,0 +1,53 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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/paludis/repositories/gentoo/ebuild/digests/dosha256.cc b/paludis/repositories/gentoo/ebuild/digests/dosha256.cc new file mode 100644 index 000000000..056ce5a2a --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/digests/dosha256.cc @@ -0,0 +1,52 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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/paludis/repositories/gentoo/ebuild/ebuild.bash b/paludis/repositories/gentoo/ebuild/ebuild.bash new file mode 100755 index 000000000..ec3b1795f --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/ebuild.bash @@ -0,0 +1,352 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +unalias -a +set +C +unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE +eval unset LANG ${!LC_*} + +if [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] ; then + 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:/proc/self/task:/selinux/context" + export SANDBOX_ON="1" + export SANDBOX_BASHRC="/dev/null" + unset BASH_ENV +fi +export REAL_CHOST="${CHOST}" + +shopt -s expand_aliases +shopt -s extglob + +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=${BASH_SOURCE[${n}]} + lineno=${BASH_LINENO[$(( n - 1 ))]} + echo "!!! * ${funcname} (${sourcefile}:${lineno})" 1>&2 + done + echo 1>&2 + + if [[ -n "${PALUDIS_EXTRA_DIE_MESSAGE}" ]] ; then + echo "${PALUDIS_EXTRA_DIE_MESSAGE}" 1>&2 + echo 1>&2 + fi + + 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_load_module work_around_broken_utilities + +export PALUDIS_HOME="$(canonicalise ${PALUDIS_HOME:-${HOME}} )" + +ebuild_source_profile() +{ + if [[ -f ${1}/parent ]] ; then + while read line ; do + grep --silent '^[[:space:]]*#' <<<"${line}" && continue + grep --silent '[^[:space:]]' <<<"${line}" || continue + 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 USE_EXPAND_HIDDEN ${USE_EXPAND}" +default_save_vars="CONFIG_PROTECT CONFIG_PROTECT_MASK" + +for var in ${save_vars} ${default_save_vars} ; do + ebuild_notice "debug" "Saving ${var}=${!var}" + 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 + +for var in ${default_save_vars} ; do + if [[ -z ${!var} ]] ; then + eval "export ${var}=\${save_var_${var}}" + else + ebuild_notice "debug" "Not restoring ${var}" + fi +done + +[[ -z "${CBUILD}" ]] && export CBUILD="${CHOST}" + +ebuild_load_ebuild() +{ + if [[ -n "${PALUDIS_LOAD_ENVIRONMENT}" ]] ; then + [[ -d ${PALUDIS_TMPDIR} ]] \ + || die "You need to create PALUDIS_TMPDIR (${PALUDIS_TMPDIR})." + + local save_PALUDIS_EXTRA_DIE_MESSAGE="${PALUDIS_EXTRA_DIE_MESSAGE}" + local real_PALUDIS_EXTRA_DIE_MESSAGE=" +!!! Could not extract the saved environment file. This is usually +!!! caused by a broken environment.bz2 that was generated by an old +!!! Portage version. The file that needs repairing is: +!!! ${PALUDIS_LOAD_ENVIRONMENT} +!!! Try copying this file, bunzip2ing it and sourcing it using a new +!!! bash shell (do not continue to use said shell afterwards). You +!!! should get an error that give you a rough idea of where the +!!! problem lies. +" + export PALUDIS_EXTRA_DIE_MESSAGE="${real_PALUDIS_EXTRA_DIE_MESSAGE}" + + 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 '/^inherit ()/,/^}/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?ROOTPATH=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PATH=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?T=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_TMPDIR=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_EBUILD_LOG_LEVEL=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PORTDIR=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?FILESDIR=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?ECLASSDIR=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?DISTDIR=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_EBUILD_DIR=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_COMMAND=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_CLIENT=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?\(PALUDIS\|CONTRARIUS\|GTKPALUDIS\)_CMDLINE_.*=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?\(ADJUTRIX\|QUALUDIS\)_CMDLINE_.*=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?\(PALUDIS\|CONTRARIUS\|GTKPALUDIS\)_OPTIONS=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?\(ADJUTRIX\|QUALUDIS\)_OPTIONS=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_HOME=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?PALUDIS_PID=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?EBUILD_KILL_PID=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?ROOT=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?SANDBOX/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?BASH_/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?SHELLOPTS/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?..\?ID=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?LD_/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?CATEGORY=/d' \ + -e '/^\(declare \(-[^ ]\+ \)\?\)\?\(PN\|PV\|P\|PVR\|PF\)=/d' \ + "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" + + export PALUDIS_EXTRA_DIE_MESSAGE="${real_PALUDIS_EXTRA_DIE_MESSAGE}" + + echo source "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" 1>&2 + source "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" \ + || die "Can't load saved environment" + + export PALUDIS_EXTRA_DIE_MESSAGE="${save_PALUDIS_EXTRA_DIE_MESSAGE}" + + rm "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" + fi + + export EBUILD="${1}" + unset IUSE DEPEND RDEPEND PDEPEND KEYWORDS + + 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}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 ! ( source "${hook_file}" ) ; then + ebuild_notice "warning" "Hook '${hook_file}' returned failure" + else + ebuild_notice "debug" "Hook '${hook_file}' returned success" + fi + done + done + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && export SANDBOX_ON="${old_sandbox_on}" + true +} + +ebuild_main() +{ + if ! [[ -e /proc/self ]] && [[ "$(uname -s)" == Linux ]] ; then + ebuild_notice "warning" "/proc appears to be unmounted or unreadable." + ebuild_notice "warning" "This will cause problems." + fi + + 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 + if ! ebuild_f_${1} ; then + perform_hook ebuild_${action}_fail + die "${1} failed" + fi + perform_hook ebuild_${action}_post + else + ebuild_load_ebuild "${ebuild}" + for action in $@ ; do + export EBUILD_PHASE="${action}" + perform_hook ebuild_${action}_pre + if ! ebuild_f_${action} ; then + perform_hook ebuild_${action}_fail + die "${action} failed" + fi + if [[ ${action} == "init" ]] ; then + ebuild_load_ebuild "${ebuild}" + fi + perform_hook ebuild_${action}_post + done + fi +} + +ebuild_main $@ + diff --git a/paludis/repositories/gentoo/ebuild/echo_functions.bash.in b/paludis/repositories/gentoo/ebuild/echo_functions.bash.in new file mode 100644 index 000000000..279121c82 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/echo_functions.bash.in @@ -0,0 +1,238 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +@GENERATED_FILE@ + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +[[ -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' + +paludis_ecmd() +{ + local cmd="$1" hook="$2" prefix="$3" message="$4" newline="$5" + + echo -n "${prefix}${message}" + [[ -z "${newline}" ]] && echo + + if type perform_hook &>/dev/null ; then + if [[ -n "${hook}" ]] ; then + MESSAGE="${message}" perform_hook "${hook}" + fi + fi +} + +einfon() +{ + paludis_ecmd \ + "einfon" \ + "einfo" \ + "`echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "`" \ + "$*" \ + "no" +} + +einfo() +{ + paludis_ecmd \ + "einfo" \ + "einfo" \ + "`echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "`" \ + "$*" +} + +einfo_unhooked() +{ + paludis_ecmd \ + "einfo" \ + "" \ + "`echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "`" \ + "$*" +} + +elog() +{ + paludis_ecmd \ + "elog" \ + "einfo" \ + "`echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "`" \ + "$*" + + if [[ -n "${PALUDIS_ELOG_FILE}" ]] ; then + echo "$@" >> "${PALUDIS_ELOG_FILE}" + fi +} + +ewarn() +{ + paludis_ecmd \ + "ewarn" \ + "ewarn" \ + "`echo -ne " ${COLOUR_WARN}*${COLOUR_NORMAL} "`" \ + "$*" +} + +eerror() +{ + paludis_ecmd \ + "eerror" \ + "eerror" \ + "`echo -ne " ${COLOUR_BAD}*${COLOUR_NORMAL} "`" \ + "$*" +} + +ebegin() +{ + paludis_ecmd \ + "ebegin" \ + "einfo" \ + "`echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "`" \ + "$* ..." +} + +ebegin_unhooked() +{ + paludis_ecmd \ + "ebegin" \ + "" \ + "`echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "`" \ + "$* ..." +} + +_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 + + echo -e "${PALUDIS_ENDCOL} ${msg}" + + return ${retval} +} + +eend() +{ + local retval=${1:-0} + shift + _eend ${retval} eerror "$*" + return ${retval} +} + +ewend() +{ + local retval=${1:-0} + shift + _eend ${retval} ewarn "$*" + 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/paludis/repositories/gentoo/ebuild/echo_functions_TEST.bash b/paludis/repositories/gentoo/ebuild/echo_functions_TEST.bash new file mode 100644 index 000000000..6e4ad2786 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/echo_functions_TEST.bash @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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/paludis/repositories/gentoo/ebuild/eclass_functions.bash b/paludis/repositories/gentoo/ebuild/eclass_functions.bash new file mode 100644 index 000000000..9c6334dfb --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/eclass_functions.bash @@ -0,0 +1,85 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +EXPORT_FUNCTIONS() +{ + [[ -z "${ECLASS}" ]] && die "EXPORT_FUNCTIONS called but ECLASS undefined" + + local e + for e in "$@" ; do + case "$e" in + pkg_nofetch|pkg_setup|pkg_prerm|pkg_postrm|pkg_preinst|pkg_postinst|pkg_config) + 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}" unset_IUSE="${IUSE-unset}" + local current_DEPEND="${DEPEND}" unset_DEPEND="${DEPEND-unset}" + local current_RDEPEND="${RDEPEND}" unset_RDEPEND="${RDEPEND-unset}" + local current_PDEPEND="${PDEPEND}" unset_PDEPEND="${PDEPEND-unset}" + local current_KEYWORDS="${KEYWORDS}" unset_KEYWORDS="${KEYWORDS-unset}" + + 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}" + + [[ "unset" == "${unset_IUSE}" ]] && unset IUSE || IUSE="${current_IUSE}" + [[ "unset" == "${unset_DEPEND}" ]] && unset DEPEND || DEPEND="${current_DEPEND}" + [[ "unset" == "${unset_RDEPEND}" ]] && unset RDEPEND || RDEPEND="${current_RDEPEND}" + [[ "unset" == "${unset_PDEPEND}" ]] && unset PDEPEND || PDEPEND="${current_PDEPEND}" + [[ "unset" == "${unset_KEYWORDS}" ]] && unset KEYWORDS || KEYWORDS="${current_KEYWORDS}" + + export ECLASS="${old_ECLASS}" + done +} + diff --git a/paludis/repositories/gentoo/ebuild/install_functions.bash b/paludis/repositories/gentoo/ebuild/install_functions.bash new file mode 100644 index 000000000..e23628c7b --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/install_functions.bash @@ -0,0 +1,109 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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/paludis/repositories/gentoo/ebuild/kernel_functions.bash b/paludis/repositories/gentoo/ebuild/kernel_functions.bash new file mode 100644 index 000000000..9126376e6 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/kernel_functions.bash @@ -0,0 +1,59 @@ +#!/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, 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 + +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/paludis/repositories/gentoo/ebuild/kernel_functions_TEST.bash b/paludis/repositories/gentoo/ebuild/kernel_functions_TEST.bash new file mode 100644 index 000000000..4b3271df3 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/kernel_functions_TEST.bash @@ -0,0 +1,41 @@ +#!/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, 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 + +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/paludis/repositories/gentoo/ebuild/list_functions.bash b/paludis/repositories/gentoo/ebuild/list_functions.bash new file mode 100644 index 000000000..d34ba64eb --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/list_functions.bash @@ -0,0 +1,70 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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() +{ + 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/paludis/repositories/gentoo/ebuild/list_functions_TEST.bash b/paludis/repositories/gentoo/ebuild/list_functions_TEST.bash new file mode 100644 index 000000000..c3ba14fbb --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/list_functions_TEST.bash @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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/paludis/repositories/gentoo/ebuild/merge.cc b/paludis/repositories/gentoo/ebuild/merge.cc new file mode 100644 index 000000000..1b1781e17 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/merge.cc @@ -0,0 +1,451 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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 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/fd_output_stream.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/util/fd_holder.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); + std::string file_to_install_name(stringify(file_to_install)); + + ifstream our_md5_file(file_to_install_name.c_str()); + if (! our_md5_file) + throw Failure("Could not get md5 for '" + file_to_install_name + "'"); + MD5 our_md5(our_md5_file); + + FSEntry result(name); + std::string result_name(stringify(name)); + while (true) + { + if (! result.exists()) + return result; + else if (result.is_regular_file()) + { + ifstream other_md5_file(result_name.c_str()); + if (! other_md5_file) + throw Failure("Could not get md5 for '" + result_name + "'"); + 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()))); + result_name = stringify(result); + } + } + + void + do_dir(const FSEntry & root, const FSEntry & src_dir, + const FSEntry & dst_dir, ofstream * const contents) + { + std::string root_str(stringify(root)), dst_dir_str(stringify(dst_dir.dirname())); + + Context context("Installing directory in root '" + root_str + "' from '" + + stringify(src_dir) + "' to '" + stringify(dst_dir) + "':"); + + 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 + "'"); + if (dst_dir_str == "/") + dst_dir_str.clear(); + + cout << ">>> " << std::setw(5) << std::left << "[dir]" << " " << + dst_dir_str.substr(root_str.length()) << "/" << dst_dir.basename(); + + if (dst_dir.is_directory()) + { + cout << " <dir>" << endl; + } + 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"); + cout << " <sym -> dir>" << endl; + } + else if (dst_dir.exists()) + { + cout << " <obj>" << endl; + throw Failure("Expected '" + stringify(dst_dir) + + "' to be a directory or non-existent, but found a file"); + } + else + { + cout << " <new>" << endl; + + mode_t mode(src_dir.permissions()); + +#ifdef HAVE_SELINUX + std::tr1::shared_ptr<FSCreateCon> createcon; + if (MatchPathCon::get_instance()->good()) + { + FSCreateCon *p = new FSCreateCon(MatchPathCon::get_instance()->match(dst_dir_str.substr(root_str.length()), + mode)); + createcon.reset(p); + } +#endif + + FSEntry dst_dir_copy(dst_dir); + dst_dir_copy.mkdir(mode); + dst_dir_copy.chown(src_dir.owner(), src_dir.group()); + /* the chmod is needed to pick up fancy set*id bits */ + dst_dir_copy.chmod(src_dir.permissions()); + } + + *contents << "dir " << dst_dir_str.substr(root_str.length()) << "/" << + dst_dir.basename() << endl; + } + + void + copy_file_contents(int input_fd, int fd) + { + char buf[4096]; + ssize_t count; + while ((count = read(input_fd, buf, 4096)) > 0) + write(fd, buf, count); + } + + void + do_obj(const FSEntry & root, const FSEntry & src, + const FSEntry & dst, ofstream * const contents) + { + std::string root_str(stringify(root)), dst_dir_str(stringify(dst.dirname())), + src_str(stringify(src)); + + Context context("Installing object in root '" + root_str + "' from '" + + stringify(src) + "' to '" + stringify(dst) + "':"); + + 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 + "'"); + if (dst_dir_str == "/") + dst_dir_str.clear(); + + cout << ">>> " << std::setw(5) << std::left << "[obj]" << " " << + dst_dir_str.substr(root_str.length()) << "/" << dst.basename(); + + if (dst.is_directory()) + { + cout << " <dir>" << endl; + throw Failure("Cannot overwrite directory '" + stringify(dst) + "' with a file"); + } + else + { + FSEntry real_dst(dst); + + FDHolder input_fd(::open(src_str.c_str(), O_RDONLY), false); + if (-1 == input_fd) + throw Failure("Cannot read '" + src_str + "'"); + + 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 + { + if (dst.is_regular_file()) + { + cout << " <obj>" << endl; + + mode_t mode(dst.permissions()); + if ((mode & S_ISUID) || (mode & S_ISGID)) + { + mode &= 0400; + FSEntry(dst).chmod(mode); + } + FSEntry(dst).unlink(); + } + else if (dst.is_symbolic_link()) + { + cout << " <sym>" << endl; + FSEntry(dst).unlink(); + } + else + { + cout << " <?""?""?>" << endl; + FSEntry(dst).unlink(); + } + } + } + else + cout << " <new>" << endl; + + /* FDHolder must be destroyed before we do the md5 thing, or the + * disk write may not have synced. */ + { +#ifdef HAVE_SELINUX + std::tr1::shared_ptr<FSCreateCon> createcon; + if (MatchPathCon::get_instance()->good()) + createcon.reset(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))); + + copy_file_contents(input_fd, fd); + } + + 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) + { + std::string root_str(stringify(root)), dst_dir_str(stringify(dst.dirname())); + + Context context("Installing symlink in root '" + root_str + "' from '" + + stringify(src) + "' to '" + stringify(dst) + "':"); + + 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 + "'"); + if (dst_dir_str == "/") + dst_dir_str.clear(); + + cout << ">>> " << std::setw(5) << std::left << "[sym]" << " " << + dst_dir_str.substr(root_str.length()) << "/" << dst.basename(); + + if (dst.exists()) + { + if (dst.is_directory()) + throw Failure("Can't overwrite directory '" + stringify(dst) + + "' with symlink to '" + src.readlink() + "'"); + else if (dst.is_symbolic_link()) + { + cout << " <sym>" << endl; + FSEntry(dst).unlink(); + } + else + { + cout << " <obj>" << endl; + mode_t mode(dst.permissions()); + if ((mode & S_ISUID) || (mode & S_ISGID)) + { + mode &= 0400; + FSEntry(dst).chmod(mode); + } + FSEntry(dst).unlink(); + } + } + else + cout << " <new>" << endl; + +#ifdef HAVE_SELINUX + // permissions() on a symlink does weird things, but matchpathcon only cares about the file type, + // so just pass S_IFLNK. + std::tr1::shared_ptr<FSCreateCon> createcon; + if (MatchPathCon::get_instance()->good()) + createcon.reset(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/paludis/repositories/gentoo/ebuild/merge_TEST.bash b/paludis/repositories/gentoo/ebuild/merge_TEST.bash new file mode 100644 index 000000000..c4f525331 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/merge_TEST.bash @@ -0,0 +1,223 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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 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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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 +} + +merge_config_protect_TEST() +{ + export CONFIG_PROTECT=/dir + + ${TOP_BUILD_DIR}/paludis/repositories/gentoo/ebuild/merge "merge_TEST_dir/config_pro_src" \ + "merge_TEST_dir/config_pro_dst" \ + "merge_TEST_dir/config_pro_contents" 1>/dev/null + test_return_code + + echo -n "[one]" + + [[ -f merge_TEST_dir/config_pro_dst/dir/one ]] ; test_return_code + [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_one ]] ; test_return_code + ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0001_one ]] ; test_return_code + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/one)" "i am a fish" + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0000_one)" "contents of one" + + echo -n "[two]" + + [[ -f merge_TEST_dir/config_pro_dst/dir/two ]] ; test_return_code + ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_two ]] ; test_return_code + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/two)" "contents of two" + + echo -n "[three]" + + [[ -f merge_TEST_dir/config_pro_dst/dir/three ]] ; test_return_code + [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_three ]] ; test_return_code + [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0001_three ]] ; test_return_code + [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0002_three ]] ; test_return_code + ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0003_three ]] ; test_return_code + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/three)" "i am a fish" + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0000_three)" "i am a dish" + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0001_three)" "i am a fist" + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0002_three)" "contents of three" + + echo -n "[four]" + + [[ -f merge_TEST_dir/config_pro_dst/dir/four ]] ; test_return_code + [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_four ]] ; test_return_code + [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0001_four ]] ; test_return_code + ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0002_four ]] ; test_return_code + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/four)" "i am a fish" + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0000_four)" "contents of four" + test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0001_four)" "i am a fist" +} + +merge_config_protect_noroot_TEST() +{ + export CONFIG_PROTECT=$(${PALUDIS_EBUILD_DIR}/utils/canonicalise `pwd` )/merge_TEST_dir/noroot_dst/dir + + ${TOP_BUILD_DIR}/paludis/repositories/gentoo/ebuild/merge "merge_TEST_dir/config_pro_noroot_src" \ + "/" \ + "merge_TEST_dir/config_pro_slash_root_contents" 1>/dev/null + test_return_code + + echo -n "[one]" + + [[ -f merge_TEST_dir/noroot_dst/dir/one ]] ; test_return_code + [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_one ]] ; test_return_code + ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0001_one ]] ; test_return_code + test_equality "$(< merge_TEST_dir/noroot_dst/dir/one)" "i am a fish" + test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0000_one)" "contents of one" + + echo -n "[two]" + + [[ -f merge_TEST_dir/noroot_dst/dir/two ]] ; test_return_code + ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_two ]] ; test_return_code + test_equality "$(< merge_TEST_dir/noroot_dst/dir/two)" "contents of two" + + echo -n "[three]" + + [[ -f merge_TEST_dir/noroot_dst/dir/three ]] ; test_return_code + [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_three ]] ; test_return_code + [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0001_three ]] ; test_return_code + [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0002_three ]] ; test_return_code + ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0003_three ]] ; test_return_code + test_equality "$(< merge_TEST_dir/noroot_dst/dir/three)" "i am a fish" + test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0000_three)" "i am a dish" + test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0001_three)" "i am a fist" + test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0002_three)" "contents of three" + + echo -n "[four]" + + [[ -f merge_TEST_dir/noroot_dst/dir/four ]] ; test_return_code + [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_four ]] ; test_return_code + [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0001_four ]] ; test_return_code + ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0002_four ]] ; test_return_code + test_equality "$(< merge_TEST_dir/noroot_dst/dir/four)" "i am a fish" + test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0000_four)" "contents of four" + test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0001_four)" "i am a fist" + +} + diff --git a/paludis/repositories/gentoo/ebuild/merge_TEST_cleanup.sh b/paludis/repositories/gentoo/ebuild/merge_TEST_cleanup.sh new file mode 100755 index 000000000..4b40b8f65 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/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/paludis/repositories/gentoo/ebuild/merge_TEST_setup.sh b/paludis/repositories/gentoo/ebuild/merge_TEST_setup.sh new file mode 100755 index 000000000..4af857d16 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/merge_TEST_setup.sh @@ -0,0 +1,74 @@ +#!/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 + +mkdir -p merge_TEST_dir/{config_pro_src/dir,config_pro_dst/dir} || exit 6 +echo "contents of one" > merge_TEST_dir/config_pro_src/dir/one +echo "contents of two" > merge_TEST_dir/config_pro_src/dir/two +echo "contents of three" > merge_TEST_dir/config_pro_src/dir/three +echo "contents of four" > merge_TEST_dir/config_pro_src/dir/four +echo "i am a fish" > merge_TEST_dir/config_pro_dst/dir/one +echo "contents of two" > merge_TEST_dir/config_pro_dst/dir/two +echo "i am a fish" > merge_TEST_dir/config_pro_dst/dir/three +echo "i am a dish" > merge_TEST_dir/config_pro_dst/dir/._cfg0000_three +echo "i am a fist" > merge_TEST_dir/config_pro_dst/dir/._cfg0001_three +echo "i am a fish" > merge_TEST_dir/config_pro_dst/dir/four +echo "contents of four" > merge_TEST_dir/config_pro_dst/dir/._cfg0000_four +echo "i am a fist" > merge_TEST_dir/config_pro_dst/dir/._cfg0001_four + +d=merge_TEST_dir/config_pro_noroot_src/$(${PALUDIS_EBUILD_DIR}/utils/canonicalise `pwd` )/merge_TEST_dir/noroot_dst/dir +mkdir -p "${d}" || exit 7 +mkdir -p merge_TEST_dir/noroot_dst/dir || exit 7 +echo "contents of one" > ${d}/one +echo "contents of two" > ${d}/two +echo "contents of three" > ${d}/three +echo "contents of four" > ${d}/four +echo "i am a fish" > merge_TEST_dir/noroot_dst/dir/one +echo "contents of two" > merge_TEST_dir/noroot_dst/dir/two +echo "i am a fish" > merge_TEST_dir/noroot_dst/dir/three +echo "i am a dish" > merge_TEST_dir/noroot_dst/dir/._cfg0000_three +echo "i am a fist" > merge_TEST_dir/noroot_dst/dir/._cfg0001_three +echo "i am a fish" > merge_TEST_dir/noroot_dst/dir/four +echo "contents of four" > merge_TEST_dir/noroot_dst/dir/._cfg0000_four +echo "i am a fist" > merge_TEST_dir/noroot_dst/dir/._cfg0001_four + diff --git a/paludis/repositories/gentoo/ebuild/merge_common.cc b/paludis/repositories/gentoo/ebuild/merge_common.cc new file mode 100644 index 000000000..27b9e11ef --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/merge_common.cc @@ -0,0 +1,99 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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, preresult; + WhitespaceTokeniser::get_instance()->tokenise(getenv_with_default(var, ""), + std::back_inserter(preresult)); + result.reserve(preresult.size()); + + for (std::vector<std::string>::const_iterator i(preresult.begin()), i_end(preresult.end()) ; + i != i_end ; ++i) + { + if (i->empty()) + continue; + if ("-*" == *i) + result.clear(); + else if ('-' == i->at(0)) + result.erase(std::remove(result.begin(), result.end(), i->substr(1)), result.end()); + else + result.push_back(*i); + } + 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 = "/"; + if ('/' != file_str.at(0)) + file_str = "/" + 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/paludis/repositories/vdb/registration.cc b/paludis/repositories/gentoo/ebuild/merge_common.hh index 95eb9a2fd..6f066489a 100644 --- a/paludis/repositories/vdb/registration.cc +++ b/paludis/repositories/gentoo/ebuild/merge_common.hh @@ -17,24 +17,34 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/repository_maker.hh> -#include <paludis/repositories/vdb/vdb_repository.hh> -#include "config.h" +#ifndef PALUDIS_GUARD_EBUILD_UTILS_MERGE_COMMON_HH +#define PALUDIS_GUARD_EBUILD_UTILS_MERGE_COMMON_HH 1 -using namespace paludis; +#include <string> +#include <vector> -#ifndef MONOLITHIC - -extern "C" +namespace paludis { - void register_repositories(RepositoryMaker * maker); + class FSEntry; } -void register_repositories(RepositoryMaker * maker) +namespace merge { - maker->register_maker("vdb", &VDBRepository::make_vdb_repository); -} + struct Failure + { + std::string message; -#endif + 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/paludis/repositories/gentoo/ebuild/multilib_functions.bash b/paludis/repositories/gentoo/ebuild/multilib_functions.bash new file mode 100644 index 000000000..f6569334e --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/multilib_functions.bash @@ -0,0 +1,66 @@ +#!/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, 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 + +# 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/paludis/repositories/gentoo/ebuild/pkg_config.bash b/paludis/repositories/gentoo/ebuild/pkg_config.bash new file mode 100644 index 000000000..f0bb49ab4 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_config.bash @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +pkg_config() +{ + eerror "No configuration function is defined" +} + +ebuild_f_config() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/" + + if hasq "config" ${RESTRICT} ; then + ebuild_section "Skipping pkg_config (RESTRICT)" + elif hasq "config" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping pkg_config (SKIP_FUNCTIONS)" + else + if [[ $(type -t pre_pkg_config ) == "function" ]] ; then + ebuild_section "Starting pre_pkg_config" + pre_pkg_config + ebuild_section "Done pre_pkg_config" + fi + + ebuild_section "Starting pkg_config" + pkg_config + ebuild_section "Done pkg_config" + + if [[ $(type -t post_pkg_config ) == "function" ]] ; then + ebuild_section "Starting post_pkg_config" + post_pkg_config + ebuild_section "Done post_pkg_config" + fi + fi + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/pkg_nofetch.bash b/paludis/repositories/gentoo/ebuild/pkg_nofetch.bash new file mode 100644 index 000000000..09c179125 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_nofetch.bash @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} diff --git a/paludis/repositories/gentoo/ebuild/pkg_postinst.bash b/paludis/repositories/gentoo/ebuild/pkg_postinst.bash new file mode 100644 index 000000000..9eb7c6c8f --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_postinst.bash @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +pkg_postinst() +{ + : +} + +ebuild_f_postinst() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + if [[ $(type -t pre_pkg_postinst ) == "function" ]] ; then + ebuild_section "Starting pre_pkg_postinst" + pre_pkg_postinst + ebuild_section "Done pre_pkg_postinst" + fi + + ebuild_section "Starting pkg_postinst" + pkg_postinst + ebuild_section "Done pkg_postinst" + + if [[ $(type -t post_pkg_postinst ) == "function" ]] ; then + ebuild_section "Starting post_pkg_postinst" + post_pkg_postinst + ebuild_section "Done post_pkg_postinst" + fi + fi + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/pkg_postrm.bash b/paludis/repositories/gentoo/ebuild/pkg_postrm.bash new file mode 100644 index 000000000..9fc7855ac --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_postrm.bash @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +pkg_postrm() +{ + : +} + +ebuild_f_postrm() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + if [[ $(type -t pre_pkg_postrm ) == "function" ]] ; then + ebuild_section "Starting pre_pkg_postrm" + pre_pkg_postrm + ebuild_section "Done pre_pkg_postrm" + fi + + ebuild_section "Starting pkg_postrm" + pkg_postrm + ebuild_section "Done pkg_postrm" + + if [[ $(type -t post_pkg_postrm ) == "function" ]] ; then + ebuild_section "Starting post_pkg_postrm" + post_pkg_postrm + ebuild_section "Done post_pkg_postrm" + fi + fi + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + + diff --git a/paludis/repositories/gentoo/ebuild/pkg_preinst.bash b/paludis/repositories/gentoo/ebuild/pkg_preinst.bash new file mode 100644 index 000000000..70a346154 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_preinst.bash @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +pkg_preinst() +{ + : +} + +ebuild_f_preinst() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + if [[ $(type -t pre_pkg_preinst ) == "function" ]] ; then + ebuild_section "Starting pre_pkg_preinst" + pre_pkg_preinst + ebuild_section "Done pre_pkg_preinst" + fi + + ebuild_section "Starting pkg_preinst" + pkg_preinst + ebuild_section "Done pkg_preinst" + + if [[ $(type -t post_pkg_preinst ) == "function" ]] ; then + ebuild_section "Starting post_pkg_preinst" + post_pkg_preinst + ebuild_section "Done post_pkg_preinst" + fi + fi + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/pkg_prerm.bash b/paludis/repositories/gentoo/ebuild/pkg_prerm.bash new file mode 100644 index 000000000..ca28d79f1 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_prerm.bash @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +pkg_prerm() +{ + : +} + +ebuild_f_prerm() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + if [[ $(type -t pre_pkg_prerm ) == "function" ]] ; then + ebuild_section "Starting pre_pkg_prerm" + pre_pkg_prerm + ebuild_section "Done pre_pkg_prerm" + fi + + ebuild_section "Starting pkg_prerm" + pkg_prerm + ebuild_section "Done pkg_prerm" + + if [[ $(type -t post_pkg_prerm ) == "function" ]] ; then + ebuild_section "Starting post_pkg_prerm" + post_pkg_prerm + ebuild_section "Done post_pkg_prerm" + fi + fi + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/pkg_setup.bash b/paludis/repositories/gentoo/ebuild/pkg_setup.bash new file mode 100644 index 000000000..51b83a492 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/pkg_setup.bash @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +pkg_setup() +{ + : +} + +ebuild_f_setup() +{ + local old_sandbox_write="${SANDBOX_WRITE}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && 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 + if [[ $(type -t pre_pkg_setup ) == "function" ]] ; then + ebuild_section "Starting pre_pkg_setup" + pre_pkg_setup + ebuild_section "Done pre_pkg_setup" + fi + + ebuild_section "Starting pkg_setup" + pkg_setup + ebuild_section "Done pkg_setup" + + if [[ $(type -t post_pkg_setup ) == "function" ]] ; then + ebuild_section "Starting post_pkg_setup" + post_pkg_setup + ebuild_section "Done post_pkg_setup" + fi + fi + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/portage_stubs.bash b/paludis/repositories/gentoo/ebuild/portage_stubs.bash new file mode 100644 index 000000000..5fc68401a --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/portage_stubs.bash @@ -0,0 +1,86 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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 + elif [[ "$1" == "vdb_path" ]] ; then + vdb_path + else + eerror "Error emulating 'portageq $@':" + die "portageq emulation for $1 not implemented" + fi +} + +best_version() +{ + ${PALUDIS_COMMAND} --best-version "$@" +} + +vdb_path() +{ + if ! ${PALUDIS_COMMAND} --configuration-variable installed location ; then + die "Could not find vdb_path" + fi +} + +check_KV() +{ + die "check_KV not implemented" +} + +debug-print() +{ + : +} + +debug-print-function() +{ + : +} + +debug-print-section() +{ + : +} + diff --git a/paludis/repositories/gentoo/ebuild/run_test.bash b/paludis/repositories/gentoo/ebuild/run_test.bash new file mode 100755 index 000000000..b5587b9d1 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/sandbox.bash b/paludis/repositories/gentoo/ebuild/sandbox.bash new file mode 100644 index 000000000..cd504ae08 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/sandbox.bash @@ -0,0 +1,42 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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/paludis/repositories/gentoo/ebuild/src_compile.bash b/paludis/repositories/gentoo/ebuild/src_compile.bash new file mode 100644 index 000000000..42c8de1a1 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/src_compile.bash @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +src_compile() +{ + [[ -x ./configure ]] && econf + if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then + emake || die "emake failed" + fi +} + +ebuild_f_compile() +{ + if [[ -d "${S}" ]]; then + cd "${S}" || die "cd to \${S} (\"${S}\") failed" + fi + + 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 + if [[ $(type -t pre_src_compile ) == "function" ]] ; then + ebuild_section "Starting pre_src_compile" + pre_src_compile + ebuild_section "Done pre_src_compile" + fi + + ebuild_section "Starting src_compile" + src_compile + ebuild_section "Done src_compile" + + if [[ $(type -t post_src_compile ) == "function" ]] ; then + ebuild_section "Starting post_src_compile" + post_src_compile + ebuild_section "Done post_src_compile" + fi + fi +} + diff --git a/paludis/repositories/gentoo/ebuild/src_install.bash b/paludis/repositories/gentoo/ebuild/src_install.bash new file mode 100644 index 000000000..d7a67cd4f --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/src_install.bash @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +src_install() +{ + : +} + +ebuild_f_install() +{ + if [[ -d "${S}" ]]; then + cd "${S}" || die "cd to \${S} (\"${S}\") failed" + fi + + 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 + if [[ $(type -t pre_src_install ) == "function" ]] ; then + ebuild_section "Starting pre_src_install" + pre_src_install + ebuild_section "Done pre_src_install" + fi + + ebuild_section "Starting src_install" + src_install + ebuild_section "Done src_install" + + if [[ $(type -t post_src_install ) == "function" ]] ; then + ebuild_section "Starting post_src_install" + post_src_install + ebuild_section "Done post_src_install" + fi + fi +} + diff --git a/paludis/repositories/gentoo/ebuild/src_test.bash b/paludis/repositories/gentoo/ebuild/src_test.bash new file mode 100644 index 000000000..24ff3d6c5 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/src_test.bash @@ -0,0 +1,84 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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}" + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_PREDICT="${SANDBOX_PREDICT+${SANDBOX_PREDICT}:}/" + + local save_PALUDIS_EXTRA_DIE_MESSAGE="${PALUDIS_EXTRA_DIE_MESSAGE}" + export PALUDIS_EXTRA_DIE_MESSAGE=" +!!! This package failed inside the test phase. You should read +!!! http://paludis.pioto.org/faq.html +!!! for more information on packages with test phase failures. +" + + if [[ -d "${S}" ]]; then + cd "${S}" || die "cd to \${S} (\"${S}\") failed" + fi + + 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 + if [[ $(type -t pre_src_test ) == "function" ]] ; then + ebuild_section "Starting pre_src_test" + pre_src_test + ebuild_section "Done pre_src_test" + fi + + ebuild_section "Starting src_test" + src_test + ebuild_section "Done src_test" + + if [[ $(type -t post_src_test ) == "function" ]] ; then + ebuild_section "Starting post_src_test" + post_src_test + ebuild_section "Done post_src_test" + fi + fi + + export PALUDIS_EXTRA_DIE_MESSAGE="${save_PALUDIS_EXTRA_DIE_MESSAGE}" + + [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_PREDICT="${old_sandbox_predict}" + true +} + diff --git a/paludis/repositories/gentoo/ebuild/src_unpack.bash b/paludis/repositories/gentoo/ebuild/src_unpack.bash new file mode 100644 index 000000000..02ce83eee --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/src_unpack.bash @@ -0,0 +1,54 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +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 + if [[ $(type -t pre_src_unpack ) == "function" ]] ; then + ebuild_section "Starting pre_src_unpack" + pre_src_unpack + ebuild_section "Done pre_src_unpack" + fi + + ebuild_section "Starting src_unpack" + src_unpack + ebuild_section "Done src_unpack" + + if [[ $(type -t post_src_unpack ) == "function" ]] ; then + ebuild_section "Starting post_src_unpack" + post_src_unpack + ebuild_section "Done post_src_unpack" + fi + fi +} + diff --git a/paludis/repositories/gentoo/ebuild/unmerge.cc b/paludis/repositories/gentoo/ebuild/unmerge.cc new file mode 100644 index 000000000..367b42c65 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/unmerge.cc @@ -0,0 +1,320 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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 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 <vector> +#include <list> + +#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)) + { + while (tokens.size() > 4) + { + if (std::string::npos != tokens.at(4).find('=')) + break; + + tokens.at(1).append(" " + tokens.at(2)); + for (unsigned i = 2 ; i < tokens.size() - 1 ; ++i) + tokens.at(i) = tokens.at(i + 1); + tokens.pop_back(); + } + + 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; + + mode_t mode((root / tokens.at(1)).permissions()); + if ((mode & S_ISUID) || (mode & S_ISGID)) + { + mode &= 0400; + (root / tokens.at(1)).chmod(mode); + } + (root / tokens.at(1)).unlink(); + } + } + } + else if ("sym" == tokens.at(0)) + { + while (tokens.size() > 5) + { + if (std::string::npos != tokens.at(2).find('=')) + break; + + if (tokens.at(2) == "->") + break; + + tokens.at(1).append(" " + tokens.at(2)); + for (unsigned i = 2 ; i < tokens.size() - 1; ++i) + tokens.at(i) = tokens.at(i + 1); + tokens.pop_back(); + } + + while (tokens.size() > 5) + { + if (std::string::npos != tokens.at(2).find('=')) + break; + + if (tokens.at(4) == "->") + break; + + tokens.at(3).append(" " + tokens.at(4)); + for (unsigned i = 4 ; i < tokens.size() - 1; ++i) + tokens.at(i) = tokens.at(i + 1); + tokens.pop_back(); + } + + 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 ("fif" == tokens.at(0) || "dev" == tokens.at(0)) + { + while (tokens.size() > 2) + { + if (std::string::npos != tokens.at(2).find('=')) + break; + + tokens.at(1).append(" " + tokens.at(2)); + for (unsigned i = 2 ; i < tokens.size() - 1; ++i) + tokens.at(i) = tokens.at(i + 1); + tokens.pop_back(); + } + + if (tokens.size() != 2) + { + Log::get_instance()->message(ll_warning, lc_no_context, + "Malformed VDB entry '" + *cur + "'"); + exit_status |= 8; + } + else if ("fif" == tokens.at(0) && ! (root / tokens.at(1)).is_fifo()) + cout << "--- [!type] " << tokens.at(1) << endl; + else if ("dev" == tokens.at(0) && ! (root / tokens.at(1)).is_device()) + cout << "--- [!type] " << tokens.at(1) << endl; + else + { + cout << "<<< " << tokens.at(1) << endl; + (root / tokens.at(1)).unlink(); + } + } + 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)) + { + while (tokens.size() > 2) + { + if (std::string::npos != tokens.at(2).find('=')) + break; + + tokens.at(1).append(" " + tokens.at(2)); + for (unsigned i = 2 ; i < tokens.size() - 1; ++i) + tokens.at(i) = tokens.at(i + 1); + tokens.pop_back(); + } + + 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::list<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/paludis/repositories/gentoo/ebuild/unmerge_TEST.bash b/paludis/repositories/gentoo/ebuild/unmerge_TEST.bash new file mode 100644 index 000000000..bd59a914e --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/unmerge_TEST.bash @@ -0,0 +1,94 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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 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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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}/paludis/repositories/gentoo/ebuild/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" "" +} + +unmerge_spaces_TEST() +{ + ${TOP_BUILD_DIR}/paludis/repositories/gentoo/ebuild/merge "unmerge_TEST_dir/spaces_src" \ + "unmerge_TEST_dir/spaces_dst" \ + "unmerge_TEST_dir/spaces_contents" + test_return_code + + ok= + for a in unmerge_TEST_dir/spaces_dst/* ; do + [[ -e "$a" ]] || continue + ok=yes + break + done + test_equality "$ok" "yes" + + ${TOP_BUILD_DIR}/paludis/repositories/gentoo/ebuild/unmerge "unmerge_TEST_dir/spaces_dst" \ + "unmerge_TEST_dir/spaces_contents" + test_return_code + + ok= + for a in unmerge_TEST_dir/spaces_dst/* ; do + [[ -e "$a" ]] || continue + test_equality "$a" "" + ok=no + done + test_equality "$ok" "" +} + diff --git a/paludis/repositories/gentoo/ebuild/unmerge_TEST_cleanup.sh b/paludis/repositories/gentoo/ebuild/unmerge_TEST_cleanup.sh new file mode 100755 index 000000000..e0f01b607 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/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/paludis/repositories/gentoo/ebuild/unmerge_TEST_setup.sh b/paludis/repositories/gentoo/ebuild/unmerge_TEST_setup.sh new file mode 100755 index 000000000..33643aa89 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/unmerge_TEST_setup.sh @@ -0,0 +1,15 @@ +#!/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 + +mkdir -p unmerge_TEST_dir/{spaces_src,spaces_dst} || exit 4 +echo "file one" > unmerge_TEST_dir/spaces_src/"file one" +mkdir -p unmerge_TEST_dir/spaces_src/"dir two" +echo "file two" > unmerge_TEST_dir/spaces_src/"dir two"/"file two" +ln -s "link three" unmerge_TEST_dir/spaces_src/"link three" + diff --git a/paludis/repositories/gentoo/ebuild/usage_error.bash b/paludis/repositories/gentoo/ebuild/usage_error.bash new file mode 100644 index 000000000..0af5b2d47 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/usage_error.bash @@ -0,0 +1,31 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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, 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 + +ebuild_f_usage_error() +{ + if [[ -z ${1} ]] ; then + die "Usage error" + else + die "Usage error: ${1}" + fi +} + diff --git a/paludis/repositories/gentoo/ebuild/utils/Makefile.am b/paludis/repositories/gentoo/ebuild/utils/Makefile.am new file mode 100644 index 000000000..c0f244730 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/Makefile.am @@ -0,0 +1,92 @@ +MAINTAINERCLEANFILES = Makefile.in + +libexecprogdir = $(libexecdir)/paludis/utils + +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 \ + getfsize \ + newbin \ + newconfd \ + newdoc \ + newenvd \ + newexe \ + newinitd \ + newins \ + newlib.a \ + newlib.so \ + newman \ + newsbin \ + prepall \ + prepallstrip \ + prepstrip \ + prepallman \ + prepman \ + prepallinfo \ + prepinfo \ + prepdocs \ + prepalldocs + +AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ + +TESTS_ENVIRONMENT = env \ + PALUDIS_EBUILD_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise \ + $(top_srcdir)/paludis/repositories/gentoo/ebuild/`" \ + TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/`" \ + PALUDIS_EBUILD_LOG_LEVEL="silent" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + bash $(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/run_test.bash + +TESTS = dobin_TEST.bash getfsize_TEST.bash + +prep_scripts = prepall prepallstrip prepallman prepallinfo prepstrip prepman prepinfo prepdocs prepalldocs + +EXTRA_DIST = $(libexecprog_SCRIPTS) $(check_SCRIPTS) run_test.bash \ + newlib.so.in newlib.a.in dolib.so.in dolib.a.in prep.in $(TESTS) + +CLEANFILES = *~ newlib.so newlib.a dolib.so dolib.a $(prep_scripts) + +newlib.a : newlib.a.in + cat $? > $@ + +newlib.so : newlib.so.in + cat $? > $@ + +dolib.so : dolib.so.in + cat $? > $@ + +dolib.a : dolib.a.in + cat $? > $@ + +$(prep_scripts) : prep.in + cat $? > $@ + +check_PROGRAMS = + +built-sources : $(BUILT_SOURCES) + for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done + diff --git a/paludis/repositories/gentoo/ebuild/utils/canonicalise b/paludis/repositories/gentoo/ebuild/utils/canonicalise new file mode 100755 index 000000000..b186eba65 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/canonicalise @@ -0,0 +1,6 @@ +#!/bin/bash +case $(uname -s) in + FreeBSD) realpath "$@" ;; + *) readlink -f "$@" ;; +esac + diff --git a/paludis/repositories/gentoo/ebuild/utils/dobin b/paludis/repositories/gentoo/ebuild/utils/dobin new file mode 100755 index 000000000..506f50f0f --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dobin_TEST.bash b/paludis/repositories/gentoo/ebuild/utils/dobin_TEST.bash new file mode 100644 index 000000000..1af77004f --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/dobin_TEST.bash @@ -0,0 +1,70 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 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/paludis/repositories/gentoo/ebuild/utils/doconfd b/paludis/repositories/gentoo/ebuild/utils/doconfd new file mode 100644 index 000000000..37c453cc9 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dodir b/paludis/repositories/gentoo/ebuild/utils/dodir new file mode 100644 index 000000000..52b7c2090 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dodoc b/paludis/repositories/gentoo/ebuild/utils/dodoc new file mode 100644 index 000000000..bfff299dd --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/doenvd b/paludis/repositories/gentoo/ebuild/utils/doenvd new file mode 100644 index 000000000..7299776f9 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/doexe b/paludis/repositories/gentoo/ebuild/utils/doexe new file mode 100644 index 000000000..a67166b09 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dohard b/paludis/repositories/gentoo/ebuild/utils/dohard new file mode 100644 index 000000000..b0758e5ae --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dohtml b/paludis/repositories/gentoo/ebuild/utils/dohtml new file mode 100644 index 000000000..09743c9ce --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/dohtml @@ -0,0 +1,122 @@ +#!/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="" +allowed_files="" +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 + ;; + -f) + allowed_files="$(split_names $2)" + shift + ;; + -x) + disallowed_dirs="$(split_names $2)" + shift + ;; + *) + args=( "${args[@]}" "$1" ) ;; + esac + shift + done +} + +install_file() { + local bn=${1} + local dn=${2} + local 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="$(basename ${path})" + ext="${ext##*.}" + if ([[ -n ${ext} ]] && has $ext $allowed_exts) || has $bn $allowed_files + 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/paludis/repositories/gentoo/ebuild/utils/doinfo b/paludis/repositories/gentoo/ebuild/utils/doinfo new file mode 100644 index 000000000..746812c9c --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/doinitd b/paludis/repositories/gentoo/ebuild/utils/doinitd new file mode 100644 index 000000000..8fc7080da --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/doins b/paludis/repositories/gentoo/ebuild/utils/doins new file mode 100644 index 000000000..2d70f5acf --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dolib b/paludis/repositories/gentoo/ebuild/utils/dolib new file mode 100644 index 000000000..c35b20245 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dolib.a.in b/paludis/repositories/gentoo/ebuild/utils/dolib.a.in new file mode 100644 index 000000000..e766554dd --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dolib.so.in b/paludis/repositories/gentoo/ebuild/utils/dolib.so.in new file mode 100644 index 000000000..d4dcb4a46 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/doman b/paludis/repositories/gentoo/ebuild/utils/doman new file mode 100644 index 000000000..3a246892a --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/doman @@ -0,0 +1,85 @@ +#!/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}" + match='man[0-9n](|f|p|pm)$' + + if [[ ${mandir} =~ ${match} ]]; 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/paludis/repositories/gentoo/ebuild/utils/domo b/paludis/repositories/gentoo/ebuild/utils/domo new file mode 100644 index 000000000..b7a0dd413 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/donewins b/paludis/repositories/gentoo/ebuild/utils/donewins new file mode 100644 index 000000000..90f037799 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dosbin b/paludis/repositories/gentoo/ebuild/utils/dosbin new file mode 100644 index 000000000..25c625801 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dosed b/paludis/repositories/gentoo/ebuild/utils/dosed new file mode 100644 index 000000000..ca9dc0429 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/dosym b/paludis/repositories/gentoo/ebuild/utils/dosym new file mode 100644 index 000000000..818ef1aaa --- /dev/null +++ b/paludis/repositories/gentoo/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 "${D}$2") ]]; then + ebuild_notice "qa" "$0: target directory ${D}$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/paludis/repositories/gentoo/ebuild/utils/dounpack b/paludis/repositories/gentoo/ebuild/utils/dounpack new file mode 100755 index 000000000..2af875f0a --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/dounpack @@ -0,0 +1,114 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 + +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}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2 + tar xf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" || die "Couldn't unpack ${1}" + ;; + + *.tar.gz|*.tgz|*.tar.Z) + echo tar zxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2 + tar zxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" || die "Couldn't unpack ${1}" + ;; + + *.tar.bz2|*.tbz2) + echo tar jxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2 + tar jxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" || 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}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) 1>&2 + gzip -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) || die "Couldn't unpack ${1}" + ;; + + *.bz2) + echo bzip2 -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) 1>&2 + bzip2 -dc "${1}" > ${UNPACKTODIR}/$(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 + +} + +export UNPACKFROMDIR="${DISTDIR}" +export UNPACKTODIR="${PWD}" + +if [[ "${1}" == "--binary" ]] ; then + export UNPACKFROMDIR="${PKGDIR}" + export UNPACKTODIR="${IMAGE}" + shift +fi + +TAR_OPTIONS=( ) +while [[ "${1}" == --tar-option=* ]] ; do + TAR_OPTIONS+=( "${1#*=}" ) + shift +done + +[[ -z "$@" ]] && die "No arguments given to unpack" + +for x in "$@" ; do + x=$(echo $x ) + echo ">>> Unpacking ${x} to ${UNPACKTODIR}" + [[ "${x:0:2}" == "./" ]] || x="${UNPACKFROMDIR}/${x}" + mkdir -p ${UNPACKTODIR} + cd ${UNPACKTODIR} + unpack_one "${x}" +done + + diff --git a/paludis/repositories/gentoo/ebuild/utils/emake b/paludis/repositories/gentoo/ebuild/utils/emake new file mode 100755 index 000000000..57ffa4ca4 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/emake @@ -0,0 +1,22 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.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 + +echo ${EMAKE_WRAPPER} ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@" 1>&2 +${EMAKE_WRAPPER} ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@" + diff --git a/paludis/repositories/gentoo/ebuild/utils/fowners b/paludis/repositories/gentoo/ebuild/utils/fowners new file mode 100644 index 000000000..4eb208c6e --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/fperms b/paludis/repositories/gentoo/ebuild/utils/fperms new file mode 100644 index 000000000..04c5db7eb --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/getfsize b/paludis/repositories/gentoo/ebuild/utils/getfsize new file mode 100755 index 000000000..38a271b00 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/getfsize @@ -0,0 +1,5 @@ +#!/bin/bash +case $(uname -s) in + FreeBSD) stat -f '%z' "$@" ;; + *) stat -c '%s' "$@" ;; +esac diff --git a/paludis/repositories/gentoo/ebuild/utils/getfsize_TEST.bash b/paludis/repositories/gentoo/ebuild/utils/getfsize_TEST.bash new file mode 100755 index 000000000..3688bdf4c --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/getfsize_TEST.bash @@ -0,0 +1,44 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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 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 + +getfsize_TEST() +{ + mkdir -p getfsize_TEST_dir ; test_return_code + + echo -n "12345" > getfsize_TEST_dir/five + echo "12345" > getfsize_TEST_dir/six + + ${PALUDIS_EBUILD_DIR}/utils/getfsize getfsize_TEST_dir/five >/dev/null ; test_return_code + ${PALUDIS_EBUILD_DIR}/utils/getfsize getfsize_TEST_dir/six >/dev/null ; test_return_code + + [[ $(${PALUDIS_EBUILD_DIR}/utils/getfsize getfsize_TEST_dir/five ) == "5" ]] ; test_return_code + [[ $(${PALUDIS_EBUILD_DIR}/utils/getfsize getfsize_TEST_dir/six ) == "6" ]] ; test_return_code + + rm -fr getfsize_TEST_dir +} + +getfsize_fail_TEST() +{ + mkdir -p getfsize_TEST_dir ; test_return_code + + ! ${PALUDIS_EBUILD_DIR}/utils/getfsize getfsize_TEST_dir/seven 2>/dev/null ; test_return_code + + rm -fr getfsize_TEST_dir +} + + diff --git a/paludis/repositories/gentoo/ebuild/utils/getmtime b/paludis/repositories/gentoo/ebuild/utils/getmtime new file mode 100755 index 000000000..88a74b21f --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/utils/getmtime @@ -0,0 +1,5 @@ +#!/bin/bash +case $(uname -s) in + FreeBSD) stat -f '%m' "$@" ;; + *) stat -c '%Y' "$@" ;; +esac diff --git a/paludis/repositories/gentoo/ebuild/utils/newbin b/paludis/repositories/gentoo/ebuild/utils/newbin new file mode 100644 index 000000000..21792c697 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newconfd b/paludis/repositories/gentoo/ebuild/utils/newconfd new file mode 100644 index 000000000..77838656c --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newdoc b/paludis/repositories/gentoo/ebuild/utils/newdoc new file mode 100644 index 000000000..b4cb50700 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newenvd b/paludis/repositories/gentoo/ebuild/utils/newenvd new file mode 100644 index 000000000..76f0a7f5e --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newexe b/paludis/repositories/gentoo/ebuild/utils/newexe new file mode 100644 index 000000000..9a5cb35df --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newinitd b/paludis/repositories/gentoo/ebuild/utils/newinitd new file mode 100644 index 000000000..01ca12b2d --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newins b/paludis/repositories/gentoo/ebuild/utils/newins new file mode 100644 index 000000000..2b692adb6 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newlib.a.in b/paludis/repositories/gentoo/ebuild/utils/newlib.a.in new file mode 100644 index 000000000..415a0571c --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newlib.so.in b/paludis/repositories/gentoo/ebuild/utils/newlib.so.in new file mode 100644 index 000000000..0701351d8 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newman b/paludis/repositories/gentoo/ebuild/utils/newman new file mode 100644 index 000000000..0dab5fc16 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/newsbin b/paludis/repositories/gentoo/ebuild/utils/newsbin new file mode 100644 index 000000000..da94577f7 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/prep.in b/paludis/repositories/gentoo/ebuild/utils/prep.in new file mode 100644 index 000000000..fcb64959d --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/utils/run_test.bash b/paludis/repositories/gentoo/ebuild/utils/run_test.bash new file mode 100644 index 000000000..1f9db4e38 --- /dev/null +++ b/paludis/repositories/gentoo/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/paludis/repositories/gentoo/ebuild/work_around_broken_utilities.bash.in b/paludis/repositories/gentoo/ebuild/work_around_broken_utilities.bash.in new file mode 100644 index 000000000..cb97656b6 --- /dev/null +++ b/paludis/repositories/gentoo/ebuild/work_around_broken_utilities.bash.in @@ -0,0 +1,26 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006 Timothy Redaelli <drizzt@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, 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 + +@NEED_SED_WRAPPER_TRUE@alias sed=gsed +@NEED_AWK_WRAPPER_TRUE@alias awk=gawk +@NEED_MAKE_WRAPPER_TRUE@alias make=gmake +@NEED_PATCH_WRAPPER_TRUE@alias patch=gpatch diff --git a/paludis/repositories/portage/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc index c0240fea2..122f72b2b 100644 --- a/paludis/repositories/portage/ebuild_entries.cc +++ b/paludis/repositories/gentoo/ebuild_entries.cc @@ -17,9 +17,9 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/portage/ebuild_entries.hh> -#include <paludis/repositories/portage/ebuild_flat_metadata_cache.hh> -#include <paludis/repositories/portage/portage_repository.hh> +#include <paludis/repositories/gentoo/ebuild_entries.hh> +#include <paludis/repositories/gentoo/ebuild_flat_metadata_cache.hh> +#include <paludis/repositories/gentoo/portage_repository.hh> #include <paludis/dep_atom_flattener.hh> #include <paludis/ebuild.hh> diff --git a/paludis/repositories/portage/ebuild_entries.hh b/paludis/repositories/gentoo/ebuild_entries.hh index 711640598..7755081d4 100644 --- a/paludis/repositories/portage/ebuild_entries.hh +++ b/paludis/repositories/gentoo/ebuild_entries.hh @@ -20,8 +20,8 @@ #ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_PORTAGE_REPOSITORY_EBUILD_METADATA_HH #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_PORTAGE_REPOSITORY_EBUILD_METADATA_HH 1 -#include <paludis/repositories/portage/portage_repository_entries.hh> -#include <paludis/repositories/portage/portage_repository_params.hh> +#include <paludis/repositories/gentoo/portage_repository_entries.hh> +#include <paludis/repositories/gentoo/portage_repository_params.hh> #include <paludis/util/private_implementation_pattern.hh> /** \file diff --git a/paludis/repositories/portage/ebuild_flat_metadata_cache.cc b/paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc index e5873e4ed..e5873e4ed 100644 --- a/paludis/repositories/portage/ebuild_flat_metadata_cache.cc +++ b/paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc diff --git a/paludis/repositories/portage/ebuild_flat_metadata_cache.hh b/paludis/repositories/gentoo/ebuild_flat_metadata_cache.hh index 34abf6e2c..3310eed89 100644 --- a/paludis/repositories/portage/ebuild_flat_metadata_cache.hh +++ b/paludis/repositories/gentoo/ebuild_flat_metadata_cache.hh @@ -23,7 +23,7 @@ #include <paludis/ebuild.hh> #include <paludis/util/fs_entry.hh> #include <paludis/version_metadata.hh> -#include <paludis/repositories/portage/eclass_mtimes.hh> +#include <paludis/repositories/gentoo/eclass_mtimes.hh> namespace paludis { diff --git a/paludis/repositories/portage/eclass_mtimes.cc b/paludis/repositories/gentoo/eclass_mtimes.cc index abc7e2018..abc7e2018 100644 --- a/paludis/repositories/portage/eclass_mtimes.cc +++ b/paludis/repositories/gentoo/eclass_mtimes.cc diff --git a/paludis/repositories/portage/eclass_mtimes.hh b/paludis/repositories/gentoo/eclass_mtimes.hh index 1bfdc4630..1bfdc4630 100644 --- a/paludis/repositories/portage/eclass_mtimes.hh +++ b/paludis/repositories/gentoo/eclass_mtimes.hh diff --git a/paludis/repositories/portage/glsa.cc b/paludis/repositories/gentoo/glsa.cc index 4bdcb0960..28ddd51a1 100644 --- a/paludis/repositories/portage/glsa.cc +++ b/paludis/repositories/gentoo/glsa.cc @@ -214,18 +214,18 @@ GLSA::create_from_xml_file(const std::string & filename) # else if (0 == libxmlhandle.handle) - libxmlhandle.handle = dlopen("libpaludisportagerepositoryxmlthings.so", + libxmlhandle.handle = dlopen("libpaludisgentoorepositoryxmlthings.so", RTLD_NOW | RTLD_GLOBAL); if (0 == libxmlhandle.handle) throw NotAvailableError("Cannot create GLSA from XML file '" + filename + "' due to error '" - + stringify(dlerror()) + "' when dlopen(libpaludisportagerepositoryxmlthings.so)"); + + stringify(dlerror()) + "' when dlopen(libpaludisgentoorepositoryxmlthings.so)"); if (0 == libxmlhandle.create_glsa_from_xml_file_handle) libxmlhandle.create_glsa_from_xml_file_handle = STUPID_CAST(std::tr1::shared_ptr<GLSA> (*)(const std::string &), dlsym(libxmlhandle.handle, "create_glsa_from_xml_file")); if (0 == libxmlhandle.create_glsa_from_xml_file_handle) throw NotAvailableError("Cannot create GLSA from XML file '" + filename + "' due to error '" - + stringify(dlerror()) + "' when dlsym(libpaludisportagerepositoryxmlthings.so, create_glsa_from_xml_file)"); + + stringify(dlerror()) + "' when dlsym(libpaludisgentoorepositoryxmlthings.so, create_glsa_from_xml_file)"); # endif #else diff --git a/paludis/repositories/portage/glsa.hh b/paludis/repositories/gentoo/glsa.hh index f85507895..69e7a57d5 100644 --- a/paludis/repositories/portage/glsa.hh +++ b/paludis/repositories/gentoo/glsa.hh @@ -31,7 +31,7 @@ namespace paludis { -#include <paludis/repositories/portage/glsa-sr.hh> +#include <paludis/repositories/gentoo/glsa-sr.hh> /** * Thrown if a bad GLSA is found. diff --git a/paludis/repositories/portage/glsa.sr b/paludis/repositories/gentoo/glsa.sr index 359ffeeff..359ffeeff 100644 --- a/paludis/repositories/portage/glsa.sr +++ b/paludis/repositories/gentoo/glsa.sr diff --git a/paludis/repositories/portage/make_ebuild_repository.cc b/paludis/repositories/gentoo/make_ebuild_repository.cc index 976c6b5df..97e37d646 100644 --- a/paludis/repositories/portage/make_ebuild_repository.cc +++ b/paludis/repositories/gentoo/make_ebuild_repository.cc @@ -21,7 +21,7 @@ #include <paludis/util/log.hh> #include <paludis/util/collection_concrete.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/repositories/portage/portage_repository_exceptions.hh> +#include <paludis/repositories/gentoo/portage_repository_exceptions.hh> #include <paludis/environment.hh> using namespace paludis; diff --git a/paludis/repositories/portage/make_ebuild_repository.hh b/paludis/repositories/gentoo/make_ebuild_repository.hh index 3fb748411..d3c771326 100644 --- a/paludis/repositories/portage/make_ebuild_repository.hh +++ b/paludis/repositories/gentoo/make_ebuild_repository.hh @@ -20,7 +20,7 @@ #ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_MAKE_EBUILD_REPOSITORY_HH #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_MAKE_EBUILD_REPOSITORY_HH 1 -#include <paludis/repositories/portage/portage_repository.hh> +#include <paludis/repositories/gentoo/portage_repository.hh> namespace paludis { diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc index ed09904a7..850a66a50 100644 --- a/paludis/repositories/portage/portage_repository.cc +++ b/paludis/repositories/gentoo/portage_repository.cc @@ -20,14 +20,14 @@ #include "config.h" -#include <paludis/repositories/portage/portage_repository.hh> -#include <paludis/repositories/portage/portage_repository_profile.hh> -#include <paludis/repositories/portage/portage_repository_news.hh> -#include <paludis/repositories/portage/portage_repository_sets.hh> -#include <paludis/repositories/portage/portage_repository_exceptions.hh> -#include <paludis/repositories/portage/portage_repository_entries.hh> -#include <paludis/repositories/portage/portage_virtual_version_metadata.hh> -#include <paludis/repositories/portage/use_desc.hh> +#include <paludis/repositories/gentoo/portage_repository.hh> +#include <paludis/repositories/gentoo/portage_repository_profile.hh> +#include <paludis/repositories/gentoo/portage_repository_news.hh> +#include <paludis/repositories/gentoo/portage_repository_sets.hh> +#include <paludis/repositories/gentoo/portage_repository_exceptions.hh> +#include <paludis/repositories/gentoo/portage_repository_entries.hh> +#include <paludis/repositories/gentoo/portage_virtual_version_metadata.hh> +#include <paludis/repositories/gentoo/use_desc.hh> #include <paludis/config_file.hh> #include <paludis/dep_atom.hh> @@ -73,7 +73,7 @@ using namespace paludis; -#include <paludis/repositories/portage/portage_repository-sr.cc> +#include <paludis/repositories/gentoo/portage_repository-sr.cc> namespace paludis { diff --git a/paludis/repositories/portage/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh index 1331388f2..26a080383 100644 --- a/paludis/repositories/portage/portage_repository.hh +++ b/paludis/repositories/gentoo/portage_repository.hh @@ -24,8 +24,8 @@ #include <paludis/package_database.hh> #include <paludis/util/fs_entry.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/repositories/portage/portage_repository_params.hh> -#include <paludis/repositories/portage/portage_repository_profile.hh> +#include <paludis/repositories/gentoo/portage_repository_params.hh> +#include <paludis/repositories/gentoo/portage_repository_profile.hh> #include <string> /** \file @@ -39,7 +39,7 @@ namespace paludis class PortageRepositoryProfile; class PortageRepositoryNews; -#include <paludis/repositories/portage/portage_repository-sr.hh> +#include <paludis/repositories/gentoo/portage_repository-sr.hh> /** * A PortageRepository is a Repository that handles the layout used by diff --git a/paludis/repositories/portage/portage_repository.sr b/paludis/repositories/gentoo/portage_repository.sr index 5f4c5156c..5f4c5156c 100644 --- a/paludis/repositories/portage/portage_repository.sr +++ b/paludis/repositories/gentoo/portage_repository.sr diff --git a/paludis/repositories/portage/portage_repository_TEST.cc b/paludis/repositories/gentoo/portage_repository_TEST.cc index 396db9e65..3f8c7a382 100644 --- a/paludis/repositories/portage/portage_repository_TEST.cc +++ b/paludis/repositories/gentoo/portage_repository_TEST.cc @@ -17,8 +17,8 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/portage/portage_repository.hh> -#include <paludis/repositories/portage/make_ebuild_repository.hh> +#include <paludis/repositories/gentoo/portage_repository.hh> +#include <paludis/repositories/gentoo/make_ebuild_repository.hh> #include <paludis/util/collection_concrete.hh> #include <paludis/environment/test/test_environment.hh> #include <paludis/util/system.hh> diff --git a/paludis/repositories/portage/portage_repository_TEST_cleanup.sh b/paludis/repositories/gentoo/portage_repository_TEST_cleanup.sh index 8c0b2902d..8c0b2902d 100755 --- a/paludis/repositories/portage/portage_repository_TEST_cleanup.sh +++ b/paludis/repositories/gentoo/portage_repository_TEST_cleanup.sh diff --git a/paludis/repositories/portage/portage_repository_TEST_setup.sh b/paludis/repositories/gentoo/portage_repository_TEST_setup.sh index 5fc9373ba..5fc9373ba 100755 --- a/paludis/repositories/portage/portage_repository_TEST_setup.sh +++ b/paludis/repositories/gentoo/portage_repository_TEST_setup.sh diff --git a/paludis/repositories/portage/portage_repository_entries.cc b/paludis/repositories/gentoo/portage_repository_entries.cc index 6abed92ba..6abed92ba 100644 --- a/paludis/repositories/portage/portage_repository_entries.cc +++ b/paludis/repositories/gentoo/portage_repository_entries.cc diff --git a/paludis/repositories/portage/portage_repository_entries.hh b/paludis/repositories/gentoo/portage_repository_entries.hh index 2cee99324..bb85424d1 100644 --- a/paludis/repositories/portage/portage_repository_entries.hh +++ b/paludis/repositories/gentoo/portage_repository_entries.hh @@ -26,8 +26,8 @@ #include <paludis/version_metadata.hh> #include <paludis/util/instantiation_policy.hh> #include <paludis/util/virtual_constructor.hh> -#include <paludis/repositories/portage/portage_repository_profile.hh> -#include <paludis/repositories/portage/portage_repository_params.hh> +#include <paludis/repositories/gentoo/portage_repository_profile.hh> +#include <paludis/repositories/gentoo/portage_repository_params.hh> #include <string> /** \file diff --git a/paludis/repositories/portage/portage_repository_entry.cc b/paludis/repositories/gentoo/portage_repository_entry.cc index ea568cd1f..ea568cd1f 100644 --- a/paludis/repositories/portage/portage_repository_entry.cc +++ b/paludis/repositories/gentoo/portage_repository_entry.cc diff --git a/paludis/repositories/portage/portage_repository_exceptions.cc b/paludis/repositories/gentoo/portage_repository_exceptions.cc index f8e118697..f8e118697 100644 --- a/paludis/repositories/portage/portage_repository_exceptions.cc +++ b/paludis/repositories/gentoo/portage_repository_exceptions.cc diff --git a/paludis/repositories/portage/portage_repository_exceptions.hh b/paludis/repositories/gentoo/portage_repository_exceptions.hh index 945182e5c..945182e5c 100644 --- a/paludis/repositories/portage/portage_repository_exceptions.hh +++ b/paludis/repositories/gentoo/portage_repository_exceptions.hh diff --git a/paludis/repositories/portage/portage_repository_news.cc b/paludis/repositories/gentoo/portage_repository_news.cc index e8ec3fb28..4f89bac60 100644 --- a/paludis/repositories/portage/portage_repository_news.cc +++ b/paludis/repositories/gentoo/portage_repository_news.cc @@ -17,8 +17,8 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/portage/portage_repository.hh> -#include <paludis/repositories/portage/portage_repository_news.hh> +#include <paludis/repositories/gentoo/portage_repository.hh> +#include <paludis/repositories/gentoo/portage_repository_news.hh> #include <paludis/config_file.hh> #include <paludis/environment.hh> diff --git a/paludis/repositories/portage/portage_repository_news.hh b/paludis/repositories/gentoo/portage_repository_news.hh index bd1b67d18..bd1b67d18 100644 --- a/paludis/repositories/portage/portage_repository_news.hh +++ b/paludis/repositories/gentoo/portage_repository_news.hh diff --git a/paludis/repositories/portage/portage_repository_params.cc b/paludis/repositories/gentoo/portage_repository_params.cc index d52072565..eebc8f6cd 100644 --- a/paludis/repositories/portage/portage_repository_params.cc +++ b/paludis/repositories/gentoo/portage_repository_params.cc @@ -4,5 +4,5 @@ using namespace paludis; -#include <paludis/repositories/portage/portage_repository_params-sr.cc> +#include <paludis/repositories/gentoo/portage_repository_params-sr.cc> diff --git a/paludis/repositories/portage/portage_repository_params.hh b/paludis/repositories/gentoo/portage_repository_params.hh index 058ef4eaf..cfb905390 100644 --- a/paludis/repositories/portage/portage_repository_params.hh +++ b/paludis/repositories/gentoo/portage_repository_params.hh @@ -36,7 +36,7 @@ namespace paludis class PackageDatabase; class PortageRepository; -#include <paludis/repositories/portage/portage_repository_params-sr.hh> +#include <paludis/repositories/gentoo/portage_repository_params-sr.hh> } diff --git a/paludis/repositories/portage/portage_repository_params.sr b/paludis/repositories/gentoo/portage_repository_params.sr index e741dc6ca..e741dc6ca 100644 --- a/paludis/repositories/portage/portage_repository_params.sr +++ b/paludis/repositories/gentoo/portage_repository_params.sr diff --git a/paludis/repositories/portage/portage_repository_profile.cc b/paludis/repositories/gentoo/portage_repository_profile.cc index a411d9ca7..84b976f4a 100644 --- a/paludis/repositories/portage/portage_repository_profile.cc +++ b/paludis/repositories/gentoo/portage_repository_profile.cc @@ -17,9 +17,9 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/portage/portage_repository_profile.hh> -#include <paludis/repositories/portage/portage_repository_profile_file.hh> -#include <paludis/repositories/portage/portage_repository_exceptions.hh> +#include <paludis/repositories/gentoo/portage_repository_profile.hh> +#include <paludis/repositories/gentoo/portage_repository_profile_file.hh> +#include <paludis/repositories/gentoo/portage_repository_exceptions.hh> #include <paludis/util/log.hh> #include <paludis/util/tokeniser.hh> diff --git a/paludis/repositories/portage/portage_repository_profile.hh b/paludis/repositories/gentoo/portage_repository_profile.hh index e914b0a88..e914b0a88 100644 --- a/paludis/repositories/portage/portage_repository_profile.hh +++ b/paludis/repositories/gentoo/portage_repository_profile.hh diff --git a/paludis/repositories/portage/portage_repository_profile_file.cc b/paludis/repositories/gentoo/portage_repository_profile_file.cc index 04fa13a52..04fa13a52 100644 --- a/paludis/repositories/portage/portage_repository_profile_file.cc +++ b/paludis/repositories/gentoo/portage_repository_profile_file.cc diff --git a/paludis/repositories/portage/portage_repository_profile_file.hh b/paludis/repositories/gentoo/portage_repository_profile_file.hh index baa6552f6..baa6552f6 100644 --- a/paludis/repositories/portage/portage_repository_profile_file.hh +++ b/paludis/repositories/gentoo/portage_repository_profile_file.hh diff --git a/paludis/repositories/portage/portage_repository_sets.cc b/paludis/repositories/gentoo/portage_repository_sets.cc index 0699cef3b..dfa8b5d20 100644 --- a/paludis/repositories/portage/portage_repository_sets.cc +++ b/paludis/repositories/gentoo/portage_repository_sets.cc @@ -18,9 +18,9 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/portage/portage_repository.hh> -#include <paludis/repositories/portage/portage_repository_sets.hh> -#include <paludis/repositories/portage/glsa.hh> +#include <paludis/repositories/gentoo/portage_repository.hh> +#include <paludis/repositories/gentoo/portage_repository_sets.hh> +#include <paludis/repositories/gentoo/glsa.hh> #include <paludis/dep_list/dep_list.hh> #include <paludis/environment.hh> diff --git a/paludis/repositories/portage/portage_repository_sets.hh b/paludis/repositories/gentoo/portage_repository_sets.hh index 12cbabd62..12cbabd62 100644 --- a/paludis/repositories/portage/portage_repository_sets.hh +++ b/paludis/repositories/gentoo/portage_repository_sets.hh diff --git a/paludis/repositories/portage/portage_virtual_version_metadata.cc b/paludis/repositories/gentoo/portage_virtual_version_metadata.cc index a10d4bc99..a10d4bc99 100644 --- a/paludis/repositories/portage/portage_virtual_version_metadata.cc +++ b/paludis/repositories/gentoo/portage_virtual_version_metadata.cc diff --git a/paludis/repositories/portage/portage_virtual_version_metadata.hh b/paludis/repositories/gentoo/portage_virtual_version_metadata.hh index 79e602821..79e602821 100644 --- a/paludis/repositories/portage/portage_virtual_version_metadata.hh +++ b/paludis/repositories/gentoo/portage_virtual_version_metadata.hh diff --git a/paludis/repositories/portage/registration.cc b/paludis/repositories/gentoo/registration.cc index 1b80763a6..9904b2cbc 100644 --- a/paludis/repositories/portage/registration.cc +++ b/paludis/repositories/gentoo/registration.cc @@ -18,7 +18,8 @@ */ #include <paludis/repositories/repository_maker.hh> -#include <paludis/repositories/portage/make_ebuild_repository.hh> +#include <paludis/repositories/gentoo/make_ebuild_repository.hh> +#include <paludis/repositories/gentoo/vdb_repository.hh> #include <paludis/util/log.hh> #include "config.h" @@ -55,6 +56,7 @@ void register_repositories(RepositoryMaker * maker) { maker->register_maker("ebuild", &make_ebuild_repository_wrapped); maker->register_maker("portage", &make_portage_repository); + maker->register_maker("vdb", &VDBRepository::make_vdb_repository); } #endif diff --git a/paludis/repositories/portage/use_desc.cc b/paludis/repositories/gentoo/use_desc.cc index 1899d867a..1899d867a 100644 --- a/paludis/repositories/portage/use_desc.cc +++ b/paludis/repositories/gentoo/use_desc.cc diff --git a/paludis/repositories/portage/use_desc.hh b/paludis/repositories/gentoo/use_desc.hh index 64ffc0235..64ffc0235 100644 --- a/paludis/repositories/portage/use_desc.hh +++ b/paludis/repositories/gentoo/use_desc.hh diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc index 38538fa8d..838d665ef 100644 --- a/paludis/repositories/vdb/vdb_repository.cc +++ b/paludis/repositories/gentoo/vdb_repository.cc @@ -17,8 +17,8 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/vdb/vdb_repository.hh> -#include <paludis/repositories/vdb/vdb_version_metadata.hh> +#include <paludis/repositories/gentoo/vdb_repository.hh> +#include <paludis/repositories/gentoo/vdb_version_metadata.hh> #include <paludis/dep_atom.hh> #include <paludis/dep_atom_flattener.hh> @@ -57,7 +57,7 @@ using namespace paludis; -#include <paludis/repositories/vdb/vdb_repository-sr.cc> +#include <paludis/repositories/gentoo/vdb_repository-sr.cc> namespace { diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/gentoo/vdb_repository.hh index dff035581..ddf85d8f9 100644 --- a/paludis/repositories/vdb/vdb_repository.hh +++ b/paludis/repositories/gentoo/vdb_repository.hh @@ -34,7 +34,7 @@ namespace paludis { -#include <paludis/repositories/vdb/vdb_repository-sr.hh> +#include <paludis/repositories/gentoo/vdb_repository-sr.hh> /** * A VDBRepository represents the /var/db/pkg database used for diff --git a/paludis/repositories/vdb/vdb_repository.sr b/paludis/repositories/gentoo/vdb_repository.sr index 48df1551a..48df1551a 100644 --- a/paludis/repositories/vdb/vdb_repository.sr +++ b/paludis/repositories/gentoo/vdb_repository.sr diff --git a/paludis/repositories/vdb/vdb_repository_TEST.cc b/paludis/repositories/gentoo/vdb_repository_TEST.cc index c684ee06b..c684ee06b 100644 --- a/paludis/repositories/vdb/vdb_repository_TEST.cc +++ b/paludis/repositories/gentoo/vdb_repository_TEST.cc diff --git a/paludis/repositories/vdb/vdb_repository_TEST_cleanup.sh b/paludis/repositories/gentoo/vdb_repository_TEST_cleanup.sh index e9f03a6b0..e9f03a6b0 100755 --- a/paludis/repositories/vdb/vdb_repository_TEST_cleanup.sh +++ b/paludis/repositories/gentoo/vdb_repository_TEST_cleanup.sh diff --git a/paludis/repositories/vdb/vdb_repository_TEST_setup.sh b/paludis/repositories/gentoo/vdb_repository_TEST_setup.sh index 138a6b134..138a6b134 100755 --- a/paludis/repositories/vdb/vdb_repository_TEST_setup.sh +++ b/paludis/repositories/gentoo/vdb_repository_TEST_setup.sh diff --git a/paludis/repositories/vdb/vdb_version_metadata.cc b/paludis/repositories/gentoo/vdb_version_metadata.cc index c5e3171a8..c5e3171a8 100644 --- a/paludis/repositories/vdb/vdb_version_metadata.cc +++ b/paludis/repositories/gentoo/vdb_version_metadata.cc diff --git a/paludis/repositories/vdb/vdb_version_metadata.hh b/paludis/repositories/gentoo/vdb_version_metadata.hh index f22721bda..f22721bda 100644 --- a/paludis/repositories/vdb/vdb_version_metadata.hh +++ b/paludis/repositories/gentoo/vdb_version_metadata.hh diff --git a/paludis/repositories/portage/xml_things.cc b/paludis/repositories/gentoo/xml_things.cc index 50ba25682..a54ac0719 100644 --- a/paludis/repositories/portage/xml_things.cc +++ b/paludis/repositories/gentoo/xml_things.cc @@ -19,7 +19,7 @@ #include <libxml/tree.h> #include <libxml/parser.h> -#include <paludis/repositories/portage/glsa.hh> +#include <paludis/repositories/gentoo/glsa.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/join.hh> #include <paludis/config_file.hh> diff --git a/paludis/repositories/portage/xml_things.hh b/paludis/repositories/gentoo/xml_things.hh index 772def364..772def364 100644 --- a/paludis/repositories/portage/xml_things.hh +++ b/paludis/repositories/gentoo/xml_things.hh diff --git a/paludis/repositories/portage/xml_things_TEST.cc b/paludis/repositories/gentoo/xml_things_TEST.cc index e993de067..76d8313fa 100644 --- a/paludis/repositories/portage/xml_things_TEST.cc +++ b/paludis/repositories/gentoo/xml_things_TEST.cc @@ -17,7 +17,7 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/repositories/portage/glsa.hh> +#include <paludis/repositories/gentoo/glsa.hh> #include <paludis/util/join.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> diff --git a/paludis/repositories/portage/xml_things_TEST_cleanup.sh b/paludis/repositories/gentoo/xml_things_TEST_cleanup.sh index 5e0843fa2..5e0843fa2 100755 --- a/paludis/repositories/portage/xml_things_TEST_cleanup.sh +++ b/paludis/repositories/gentoo/xml_things_TEST_cleanup.sh diff --git a/paludis/repositories/portage/xml_things_TEST_setup.sh b/paludis/repositories/gentoo/xml_things_TEST_setup.sh index 530af804b..530af804b 100755 --- a/paludis/repositories/portage/xml_things_TEST_setup.sh +++ b/paludis/repositories/gentoo/xml_things_TEST_setup.sh diff --git a/paludis/repositories/vdb/Makefile.am b/paludis/repositories/vdb/Makefile.am deleted file mode 100644 index e01432f8e..000000000 --- a/paludis/repositories/vdb/Makefile.am +++ /dev/null @@ -1,90 +0,0 @@ -CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda -DISTCLEANFILES = vdb_repository-sr.hh vdb_repository-sr.cc -MAINTAINERCLEANFILES = Makefile.in - -AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ -DEFS= \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DDATADIR=\"$(datadir)\" - -paludis_repositories_libdir = $(libdir)/paludis/repositories - -if MONOLITHIC - -noinst_LTLIBRARIES = libpaludisvdbrepository.la - -else - -paludis_repositories_lib_LTLIBRARIES = libpaludisvdbrepository.la - -endif - -libpaludisvdbrepository_la_SOURCES = \ - vdb_repository.cc \ - vdb_repository.hh \ - vdb_version_metadata.hh \ - vdb_version_metadata.cc \ - registration.cc - -libpaludisvdbrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 -paludis_repositories_vdb_includedir = $(includedir)/paludis/repositories/vdb/ -paludis_repositories_vdb_include_HEADERS = \ - vdb_repository.hh \ - vdb_version_metadata.hh \ - vdb_repository-sr.hh - -if ! MONOLITHIC - -libpaludisvdbrepository_la_LIBADD = \ - $(top_builddir)/paludis/libpaludis.la \ - $(top_builddir)/paludis/util/libpaludisutil.la \ - $(DYNAMIC_LD_LIBS) - -endif - -TESTS = vdb_repository_TEST - -vdb_repository_TEST_SOURCES = vdb_repository_TEST.cc - -vdb_repository_TEST_LDADD = \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/test/libtest.a \ - $(top_builddir)/paludis/environment/test/libpaludistestenvironment.la \ - libpaludisvdbrepository.la \ - $(top_builddir)/paludis/libpaludis.la \ - $(top_builddir)/paludis/util/libpaludisutil.la - -vdb_repository_TEST_CXXFLAGS = -I$(top_srcdir) - -EXTRA_DIST = \ - vdb_repository_TEST.cc \ - vdb_repository_TEST_setup.sh \ - vdb_repository_TEST_cleanup.sh \ - vdb_repository-sr.hh \ - vdb_repository-sr.cc \ - vdb_repository.sr - -BUILT_SOURCES = \ - vdb_repository-sr.hh \ - vdb_repository-sr.cc - -check_PROGRAMS = $(TESTS) -check_SCRIPTS = vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh - -TESTS_ENVIRONMENT = env \ - PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \ - PALUDIS_SKIP_CONFIG="yes" \ - PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \ - TEST_SCRIPT_DIR="$(srcdir)/" \ - bash $(top_srcdir)/test/run_test.sh - -vdb_repository-sr.hh : vdb_repository.sr $(top_srcdir)/misc/make_sr.bash - $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/vdb_repository.sr > $@ - -vdb_repository-sr.cc : vdb_repository.sr $(top_srcdir)/misc/make_sr.bash - $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/vdb_repository.sr > $@ - -built-sources : $(BUILT_SOURCES) - for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done - |