chrooted-0.3.5/000075500000000000000000000000001066406614400133335ustar00rootroot00000000000000chrooted-0.3.5/chrooted.spec000064400000000000000000000077471066406614400160350ustar00rootroot00000000000000Name: chrooted Version: 0.3.5 Release: alt1 Summary: The chrooted environment helper License: GPL Group: File tools BuildArch: noarch Packager: Dmitry V. Levin %define _chrootdir %_sysconfdir/chroot.d Source: %name-%version.tar Provides: %_chrootdir Requires: coreutils, getopt, glibc-utils, grep, sed BuildPreReq: help2man %description This package is required for chroot-aware packages. %prep %setup -q %build sed -i 's/@VERSION@/%version/g' -- update_chrooted help2man -N -s8 -i update_chrooted.8.inc ./update_chrooted >update_chrooted.8 %install mkdir -p %buildroot{/sbin,%_sbindir,%_man8dir,%_chrootdir} install -pm755 update_chrooted %buildroot/sbin/ ln -s ../../sbin/update_chrooted %buildroot%_sbindir/ install -pm755 functions %buildroot%_chrootdir/ install -pm644 update_chrooted.8 %buildroot%_man8dir/ # Generate shell functions provides list. ( echo '# shell functions provides list' for f in %buildroot%_chrootdir/*; do [ -x "$f" ] || continue sed -ne 's/^\([A-Za-z][A-Za-z_0-9]*[[:space:]]*\)()$/\1/pg' "$f" done |LC_COLLATE=C sort -u ) >%buildroot%_chrootdir/.provides.sh %post /sbin/update_chrooted lib conf %files /sbin/* %_sbindir/* %_man8dir/* %config %_chrootdir %changelog * Fri Aug 24 2007 Sergey Bolshakov 0.3.5-alt1 - updated to play well with nss_mdns * Tue Apr 10 2007 Dmitry V. Levin 0.3.4-alt2 - Reduced macro abuse in specfile. * Mon Sep 05 2005 Dmitry V. Levin 0.3.4-alt1 - chroot.d/functions (copy_resolv_conf): added multilib support. - Updated FSF postal address. * Sat Jun 18 2005 Dmitry V. Levin 0.3.3-alt1 - chroot.d/functions (CopyLibs): enhanced new ldd(1) output handling. * Tue Mar 01 2005 Dmitry V. Levin 0.3.2-alt1 - chroot.d/functions (is_yes): new function. - chroot.d/functions: + added options: --no-force/--no-verbose; + changed force default value to be $FORCE-dependent; + changed verbose default value to be $VERBOSE-dependent. * Wed Mar 31 2004 Dmitry V. Levin 0.3.1-alt1 - chroot.d/functions (CopyLibs): + fix readlink usage for coreutils >= 5.2.1-alt3. - chroot.d/functions (copy_resolv_conf): + attempt to copy /var/nis/NIS_COLD_START file only if it exists. - update_chrooted: added --list option. * Sun Feb 15 2004 Dmitry V. Levin 0.3-alt1 - update_chrooted: added more options and document them. - chroot.d/functions: + parse common options; + optimized getopt handling code; + added functions: Info, Verbose; + added functions: copy_resolv_conf, copy_resolv_lib. - Added %_chrootdir/.provides.sh file. - Added update_chrooted(8) manpage. * Mon Nov 25 2002 Dmitry V. Levin 0.2.1-alt1 - update_chrooted: propagate --force option to scripts. - chroot.d/functions: + added comments (#0001443); + added Fatal() function; + Copy(): use cp(1) for simple cases, install(1) for others. * Wed Sep 25 2002 Dmitry V. Levin 0.2-alt4 - Provides: %_sysconfdir/chroot.d * Tue Apr 16 2002 Dmitry V. Levin 0.2-alt3 - update_chrooted: exit during install. * Tue Apr 16 2002 Dmitry V. Levin 0.2-alt2 - update_chrooted: relocated from %_sbindir/ to /sbin/ (compatibility symlink created). * Sat Apr 13 2002 Dmitry V. Levin 0.2-alt1 - chroot.d/functions (CopyLibs): when in Copy mode, call Copy (by default) in "-m 755" mode. - Updated package requires. * Thu Feb 22 2001 Dmitry V. Levin 0.1-ipl5 - chroot.d/functions (Copy): really skip missing source files. * Fri Feb 16 2001 Dmitry V. Levin 0.1-ipl4 - chroot.d/functions (Copy): allow empty exe list, be less verbose. * Wed Feb 14 2001 Dmitry V. Levin 0.1-ipl3 - chroot.d/functions (Copy): skip missing source files. * Wed Feb 07 2001 Dmitry V. Levin 0.1-ipl2 - chroot.d/functions (CopyLibs): skip missing libraries. * Mon Jan 29 2001 Dmitry V. Levin 0.1-ipl1 - Initial revision. chrooted-0.3.5/functions000075500000000000000000000134221066406614400152730ustar00rootroot00000000000000#!/bin/sh -e # # Copyright (C) 2000-2005 Dmitry V. Levin # # Functions used by most of scripts to update chrooted environments. # # This program 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. # # This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # # override PATH export PATH="/bin:/sbin:/usr/bin:/usr/sbin" PROG="${0##*/}" export LANG=C LANGUAGE=C LC_ALL=C chrooted_slib="$(getconf SLIB 2>/dev/null ||:)" [ -n "$chrooted_slib" ] || chrooted_slib=lib Fatal() { printf "%s: %s\n" "${0##*/}" "$*" >&2 exit 1 } Verbose() { [ -n "$verbose" ] || return 0 printf "%s: %s\n" "${0##*/}" "$*" >&2 } Info() { printf "%s: %s\n" "${0##*/}" "$*" >&2 } is_yes() { # Test syntax if [ $# = 0 ]; then Fatal "Usage: is_yes {value}" return 2 fi # Check value case "$1" in [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|[Yy]|1) # true returns zero return 0 ;; *) # false returns one return 1 ;; esac } # NAME # Copy - copy file # # SYNOPSIS # Copy [OPTIONS]... SOURCE DEST # # DESCRIPTION # Copy SOURCE to DEST. # Try to hardlink DEST to SOURCE if possible. # Avoid copying if SOURCE is same as DEST according to cmp(1), # and no "force" have been specified. # Pass -o, -g, -m and -v options to cp(1). # Copy() { local args= local verbose= local force= local cp=cp local TEMP TEMP=`getopt -n Copy -o qvfo:g:m: -l quiet,verbose,force,owner:,group:,mode: -- "$@"` || return eval set -- "$TEMP" while :; do case "$1" in -q|--quiet) verbose= ;; -v|--verbose) verbose=-v ;; -f|--force) force=-f ;; -o|--owner) shift args="$args -o $1" cp=install ;; -g|--group) shift args="$args -g $1" cp=install ;; -m|--mode) shift args="$args -m $1" cp=install ;; --) shift; break ;; esac shift done local src="$1" [ -n "$src" ] || { Info "Copy: SOURCE not specified"; return 1; } shift local dst="$1" [ -n "$dst" ] || { Info "Copy: DEST not specified"; return 1; } shift [ -r "$src" ] || { Verbose "Copy: SOURCE \"$src\" is not available"; return 1; } if [ -z "$force" ] && cmp -s "$src" "$dst"; then return 0 fi if ! ln -nf $verbose "$src" "$dst" 2>/dev/null; then $cp -p $verbose $args "$src" "$dst" fi } # NAME # CopyLibs - copy libraries and executables # # SYNOPSIS # Copy [OPTIONS]... FILES # # DESCRIPTION # Copy FILES to DESTDIR. # Traces library dependencies using ldd(1). # Uses Copy() for actual copying. # CopyLibs() { local args= local mode='-m 755' local verbose= local force= local destdir= local libs= local TEMP TEMP=`getopt -n CopyLibs -o qvfd:l:o:g:m: -l quiet,verbose,force,destdir:libs:owner:,group:,mode: -- "$@"` || return eval set -- "$TEMP" while :; do case "$1" in -q|--quiet) verbose= ;; -v|--verbose) verbose=-v ;; -f|--force) force=-f ;; -d|--destdir) # This is mandatory option. shift destdir="$1" ;; -l|--libs) # Copy these libraries without tracing dependencies. shift libs="$libs $1" ;; -o|--owner) shift args="$args -o $1" ;; -g|--group) shift args="$args -g $1" ;; -m|--mode) shift mode="-m $1" ;; --) shift; break ;; esac shift done [ -n "$destdir" -a -d "$destdir" ] || { Info "CopyLibs: invalid or missing DESTDIR specified"; return 1; } [ -n "$*" -o -n "$libs" ] || { Info "CopyLibs: mandatory arguments not specified"; return 1; } libs="$(for n in "$libs" `ldd "$@" 2>/dev/null |sed -ne 's/^[[:space:]]\+\([^[:space:]]\+ => \)\?\([^[:space:]]\+\) (0x\([0-9a-f]\+\))$/\2/p'`; do echo "$n"; done |sort -u)" for n in $libs; do local src src=$(readlink -ne "$n") && [ -n "$src" -a -e "$src" ] || continue # Skip missing files. local dst="$destdir/${n##*/}" Copy $verbose $force $mode $args "$src" "$dst" done } # copy resolver configuration copy_resolv_conf() { # Usual configs for f in localtime hosts services {host,nsswitch,resolv}.conf; do Copy $verbose $force -m644 "/etc/$f" "etc/$f" done # NIS/NIS+ [ -f /var/nis/NIS_COLD_START ] && Copy $verbose $force -m644 /var/nis/NIS_COLD_START "var/nis/NIS_COLD_START" ||: d=`nisdomainname` if [ -n "$d" -a "$d" != '(none)' ]; then Copy $verbose $force -m644 "/var/yp/binding/$d.2" "var/yp/binding/$d.2" ||: fi } # copy resolver libraries copy_resolv_lib() { CopyLibs $verbose $force \ -l/${chrooted_slib}/libnss_db.so.2 \ -l/${chrooted_slib}/libnss_dns.so.2 \ -l/${chrooted_slib}/libnss_files.so.2 \ -l/${chrooted_slib}/libnss_hesiod.so.2 \ -l/${chrooted_slib}/libnss_mdns4_minimal.so.2 \ -l/${chrooted_slib}/libnss_mdns4.so.2 \ -l/${chrooted_slib}/libnss_nisplus.so.2 \ -l/${chrooted_slib}/libnss_nis.so.2 \ -l/${chrooted_slib}/libresolv.so.2 \ -l/${chrooted_slib}/libnsl.so.1 \ -d ${chrooted_slib} } # parse common options force= verbose= if is_yes "$FORCE"; then force="-f" fi if is_yes "$VERBOSE"; then verbose="-v" fi TEMP=`getopt -n chroot.d -o f,v -l force,no-force,verbose,no-verbose -- "$@"` || exit 1 eval set -- "$TEMP" unset TEMP while :; do case "$1" in -f|--force) [ -n "$force" ] || force="-f" ;; -v|--verbose) [ -n "$verbose" ] || verbose="-v" ;; --no-force) force= ;; --no-verbose) verbose= ;; --) shift; break ;; esac shift done chrooted-0.3.5/update_chrooted000075500000000000000000000062141066406614400164350ustar00rootroot00000000000000#!/bin/sh # # Copyright (C) 2001-2005 Dmitry V. Levin # # The chrooted environment update program. # # This program 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. # # This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # [ -z "$DURING_INSTALL" ] || exit 0 unset a f t force verbose # override PATH export PATH="/bin:/sbin:/usr/bin:/usr/sbin" usage() { [ "$1" = 0 ] || exec >&2 cat <... Valid options are: -l, --list list registered types; -f, --force force update; -v, --verbose try to be more verbose; -V, --version print program version and exit; -h, --help show this text and exit. Report bugs to http://bugs.altlinux.ru/ EOF [ -n "$1" ] && exit "$1" || exit } print_version() { cat < This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Dmitry V. Levin EOF exit } t=`getopt -n update_chrooted -o l,f,v,V,h -l list,force,verbose,help,version -- "$@"` || exit eval set -- "$t" list= force="--no-force" verbose="--no-verbose" while :; do case "$1" in -l|--list) list=1 ;; -f|--force) force="-f" ;; -v|--verbose) verbose="-v" ;; -V|--version) print_version ;; -h|--help) usage 0 ;; --) shift; break ;; *) echo "update_chrooted: unrecognized option: $1" >&2; exit 1 ;; esac shift done if [ -n "$list" ]; then # No arguments, please. [ "$#" -eq 0 ] || usage type_list= for f in /etc/chroot.d/*.*; do # Check if the executable exists. [ -e "$f" ] || continue # Don't run *.rpm* and *~ scripts [ "${f%.rpm*}" == "$f" -a "${f%\~}" == "$f" ] || continue f="${f##*/}" type_list="$type_list ${f##*.}" done type_list="$(echo "$type_list" | tr -s ' ' '\n' | grep '^.' | LC_COLLATE=C sort -u | tr '\n' ' ')" if [ -n "$type_list" ]; then echo "List of registered types: $type_list" else echo "No registered types found" fi exit fi # At least one argument, please. [ "$#" -ge 1 ] || usage for type in "$@"; do [ -n "$type" ] || continue for f in /etc/chroot.d/*."$type"; do # Check if the executable exists. [ -x "$f" ] || continue # Don't run *.rpm* and *~ scripts [ "${f%.rpm*}" == "$f" -a "${f%\~}" == "$f" ] || continue "$f" $force $verbose done done : chrooted-0.3.5/update_chrooted.8.inc000064400000000000000000000016271066406614400173530ustar00rootroot00000000000000.\" Copyright (C) 2005 Dmitry V. Levin .\" .\" Additional documentation for the update_chrooted command. .\" .\" This file 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. .\" .\" This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. [NAME] \fBupdate_chrooted\fR \- updates chrooted environments