diff --git a/.gitignore b/.gitignore index 509dbb2d6..f68096577 100644 --- a/.gitignore +++ b/.gitignore @@ -5,44 +5,25 @@ lcl # Flat make libs, binaries, etc /bin/.paths -/bin/ar -/bin/cc /bin/crossexec -/bin/ditto +/bin/execrate /bin/filter -/bin/hurl /bin/iffe /bin/ksh /bin/mamake -/bin/mktest -/bin/ok/ /bin/proto +/bin/mktest /bin/pty -/bin/ratz /bin/regress -/bin/release /bin/rt /bin/shcomp /bin/suid_exec /fun/ /include/ /lib/file/ -/lib/lib/ -/lib/libast.a -/lib/libcmd.a -/lib/libdll.a -/lib/libshell.a -/lib/libsum.a -/lib/make/ -/lib/package/gen/ -/lib/probe/ +/lib/*.a /man/ -# This one keeps changing its license header, causing git to show an -# uncommitted file. It's always re-copied anyway, and not for direct -# invocation, so exclude. The source file is: src/cmd/INIT/execrate.sh -bin/execrate - # Miscellaneous artefacts *.bak *.sav diff --git a/bin/package b/bin/package index 538fe7453..cf300f908 100755 --- a/bin/package +++ b/bin/package @@ -25,7 +25,8 @@ ######################################################################## # Escape from a non-POSIX shell -min_posix='path=Bad && case $PATH in (Bad) exit 1;; esac && '\ +# ('test X -ef Y' is technically non-POSIX, but practically universal) +min_posix='test / -ef / && path=Bad && case $PATH in (Bad) exit 1;; esac && '\ 'PWD=Bad && cd -P -- / && case $PWD in (/) ;; (*) exit 1;; esac && '\ '! { ! case x in ( x ) : ${0##*/} || : $( : ) ;; esac; } && '\ 'trap "exit 0" 0 && exit 1' @@ -140,6 +141,12 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in { [+debug|environment?Show environment and actions but do not execute.] + [+flat?With the \bmake\b action, create a flat view by linking all + files from \b$INSTALLROOT\b, minus build system internals, onto + their corresponding path under \b$PACKAGEROOT\b. + Only one architecture can have a flat view. + If \bflat\b is specified with the \bclean\b action, then + only clean up this flat view and do not delete \b$INSTALLROOT\b.] [+force?Force the action to override saved state.] [+never?Run make -N and show other actions.] [+only?Only operate on the specified packages.] @@ -150,7 +157,9 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in } [+?The actions are:] { - [+clean | clobber?Delete the \barch/\b\aHOSTTYPE\a hierarchy; this + [+clean | clobber?Clean up the flat view, if any. + Then, unless \bflat\b was given, + delete the \barch/\b\aHOSTTYPE\a hierarchy; this deletes all generated files and directories for \aHOSTTYPE\a. The hierarchy can be rebuilt by \b'$command$' make\b.] [+export\b [ \avariable\a ...]]?List \aname\a=\avalue\a for @@ -295,6 +304,7 @@ esac action= bit= exec= +flat=0 force=0 global= hi= @@ -331,6 +341,8 @@ do case $# in debug|environment) exec=echo make=echo show=echo ;; + flat) flat=1 + ;; force) force=1 ;; never) exec=echo noexec=-N @@ -392,6 +404,11 @@ DESCRIPTION The qualifiers are: debug|environment Show environment and actions but do not execute. + flat With the make action, create a flat view by linking all files from + $INSTALLROOT, minus build system internals, onto their corresponding + path under $PACKAGEROOT. Only one architecture can have a flat view. + If flat is specified with the clean action, then only clean up this + flat view and do not delete $INSTALLROOT. force Force the action to override saved state. never Run make -N and show other actions. only Only operate on the specified packages. @@ -403,8 +420,9 @@ DESCRIPTION The actions are: clean | clobber - Delete the arch/HOSTTYPE hierarchy; this deletes all generated files - and directories for HOSTTYPE. The hierarchy can be rebuilt by package + Clean up the flat view, if any. Then, unless flat was given, delete + the arch/HOSTTYPE hierarchy; this deletes all generated files and + directories for HOSTTYPE. The hierarchy can be rebuilt by package make. export [ variable ...] List name=value for variable, one per line. If the only attribute is @@ -2743,9 +2761,23 @@ error_status=0 case $action in clean|clobber) - cd $PACKAGEROOT - $exec rm -rf arch/$HOSTTYPE - exit + cd "$PACKAGEROOT" || exit + note "cleaning up flat view" + $exec find "arch/$HOSTTYPE" -name src -prune -o -type f -exec "$SHELL" -c ' + for h + do p=${h#"arch/$HOSTTYPE/"} + if test "$p" -ef "$h" + then rm -f "$p" + fi + done + ' "$0" {} + + case $flat in + 0) note "deleting arch/$HOSTTYPE" + $exec rm -rf arch/$HOSTTYPE + ;; + esac + note "removing empty directories" + $exec find . -depth -type d -exec rmdir {} + 2>/dev/null ;; export) case $INSTALLROOT in @@ -3293,6 +3325,23 @@ cat $j $k '') target="install" ;; esac eval capture mamake \$makeflags \$noexec \$target $assign + + case $flat in + 1) note "creating flat view" + cd "$PACKAGEROOT" || exit + # exclude build system internals + $exec find "arch/$HOSTTYPE" -name package -prune -o -name probe -prune -o -name FEATURE -prune \ + -o -name ok -prune -o -name src -prune -o -name '*.dSYM' -prune -o -path "*/lib/lib" -prune \ + -o -type f ! -name '*.old' -exec "$SHELL" -c ' + for h + do p=${h#"arch/$HOSTTYPE/"} + d=${p%/*} + test -d "$d" || mkdir -p "$d" || exit + ln -f "$h" "$p" 2>/dev/null || ln -sf "$h" "$p" || exit + done + ' "$0" {} + + ;; + esac ;; results)set '' $target diff --git a/src/cmd/INIT/Mamfile b/src/cmd/INIT/Mamfile index 33a1afe83..066858af6 100644 --- a/src/cmd/INIT/Mamfile +++ b/src/cmd/INIT/Mamfile @@ -590,11 +590,6 @@ make install prev filter exec - test '' = 'filter' || ${STDCMP} 2>/dev/null -s filter ${INSTALLROOT}/bin/filter || { ${STDMV} ${INSTALLROOT}/bin/filter ${INSTALLROOT}/bin/filter.old 2>/dev/null || true; ${STDCP} filter ${INSTALLROOT}/bin/filter ;} done ${INSTALLROOT}/bin/filter generated - make ${PACKAGEROOT}/lib/package - exec - if test ! -d ${PACKAGEROOT}/lib/package - exec - then mkdir -p ${PACKAGEROOT}/lib/package - exec - fi - done ${PACKAGEROOT}/lib/package generated make ${INSTALLROOT}/bin/mamake prev mamake exec - test '' = 'mamake' || ${STDCMP} 2>/dev/null -s mamake ${INSTALLROOT}/bin/mamake || { ${STDMV} ${INSTALLROOT}/bin/mamake ${INSTALLROOT}/bin/mamake.old 2>/dev/null || true; ${STDCP} mamake ${INSTALLROOT}/bin/mamake ;} diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index 538fe7453..cf300f908 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -25,7 +25,8 @@ ######################################################################## # Escape from a non-POSIX shell -min_posix='path=Bad && case $PATH in (Bad) exit 1;; esac && '\ +# ('test X -ef Y' is technically non-POSIX, but practically universal) +min_posix='test / -ef / && path=Bad && case $PATH in (Bad) exit 1;; esac && '\ 'PWD=Bad && cd -P -- / && case $PWD in (/) ;; (*) exit 1;; esac && '\ '! { ! case x in ( x ) : ${0##*/} || : $( : ) ;; esac; } && '\ 'trap "exit 0" 0 && exit 1' @@ -140,6 +141,12 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in { [+debug|environment?Show environment and actions but do not execute.] + [+flat?With the \bmake\b action, create a flat view by linking all + files from \b$INSTALLROOT\b, minus build system internals, onto + their corresponding path under \b$PACKAGEROOT\b. + Only one architecture can have a flat view. + If \bflat\b is specified with the \bclean\b action, then + only clean up this flat view and do not delete \b$INSTALLROOT\b.] [+force?Force the action to override saved state.] [+never?Run make -N and show other actions.] [+only?Only operate on the specified packages.] @@ -150,7 +157,9 @@ case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in } [+?The actions are:] { - [+clean | clobber?Delete the \barch/\b\aHOSTTYPE\a hierarchy; this + [+clean | clobber?Clean up the flat view, if any. + Then, unless \bflat\b was given, + delete the \barch/\b\aHOSTTYPE\a hierarchy; this deletes all generated files and directories for \aHOSTTYPE\a. The hierarchy can be rebuilt by \b'$command$' make\b.] [+export\b [ \avariable\a ...]]?List \aname\a=\avalue\a for @@ -295,6 +304,7 @@ esac action= bit= exec= +flat=0 force=0 global= hi= @@ -331,6 +341,8 @@ do case $# in debug|environment) exec=echo make=echo show=echo ;; + flat) flat=1 + ;; force) force=1 ;; never) exec=echo noexec=-N @@ -392,6 +404,11 @@ DESCRIPTION The qualifiers are: debug|environment Show environment and actions but do not execute. + flat With the make action, create a flat view by linking all files from + $INSTALLROOT, minus build system internals, onto their corresponding + path under $PACKAGEROOT. Only one architecture can have a flat view. + If flat is specified with the clean action, then only clean up this + flat view and do not delete $INSTALLROOT. force Force the action to override saved state. never Run make -N and show other actions. only Only operate on the specified packages. @@ -403,8 +420,9 @@ DESCRIPTION The actions are: clean | clobber - Delete the arch/HOSTTYPE hierarchy; this deletes all generated files - and directories for HOSTTYPE. The hierarchy can be rebuilt by package + Clean up the flat view, if any. Then, unless flat was given, delete + the arch/HOSTTYPE hierarchy; this deletes all generated files and + directories for HOSTTYPE. The hierarchy can be rebuilt by package make. export [ variable ...] List name=value for variable, one per line. If the only attribute is @@ -2743,9 +2761,23 @@ error_status=0 case $action in clean|clobber) - cd $PACKAGEROOT - $exec rm -rf arch/$HOSTTYPE - exit + cd "$PACKAGEROOT" || exit + note "cleaning up flat view" + $exec find "arch/$HOSTTYPE" -name src -prune -o -type f -exec "$SHELL" -c ' + for h + do p=${h#"arch/$HOSTTYPE/"} + if test "$p" -ef "$h" + then rm -f "$p" + fi + done + ' "$0" {} + + case $flat in + 0) note "deleting arch/$HOSTTYPE" + $exec rm -rf arch/$HOSTTYPE + ;; + esac + note "removing empty directories" + $exec find . -depth -type d -exec rmdir {} + 2>/dev/null ;; export) case $INSTALLROOT in @@ -3293,6 +3325,23 @@ cat $j $k '') target="install" ;; esac eval capture mamake \$makeflags \$noexec \$target $assign + + case $flat in + 1) note "creating flat view" + cd "$PACKAGEROOT" || exit + # exclude build system internals + $exec find "arch/$HOSTTYPE" -name package -prune -o -name probe -prune -o -name FEATURE -prune \ + -o -name ok -prune -o -name src -prune -o -name '*.dSYM' -prune -o -path "*/lib/lib" -prune \ + -o -type f ! -name '*.old' -exec "$SHELL" -c ' + for h + do p=${h#"arch/$HOSTTYPE/"} + d=${p%/*} + test -d "$d" || mkdir -p "$d" || exit + ln -f "$h" "$p" 2>/dev/null || ln -sf "$h" "$p" || exit + done + ' "$0" {} + + ;; + esac ;; results)set '' $target