Merge remote-tracking branch 'origin/master' into cli-guideline
This commit is contained in:
commit
24db5b125f
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -18,7 +18,8 @@ perl/Makefile.config
|
|||
/doc/manual/nix.json
|
||||
/doc/manual/conf-file.json
|
||||
/doc/manual/builtins.json
|
||||
/doc/manual/src/command-ref/nix.md
|
||||
/doc/manual/src/SUMMARY.md
|
||||
/doc/manual/src/command-ref/new-cli
|
||||
/doc/manual/src/command-ref/conf-file.md
|
||||
/doc/manual/src/expressions/builtins.md
|
||||
|
||||
|
|
538
config/config.guess
vendored
538
config/config.guess
vendored
|
@ -1,8 +1,8 @@
|
|||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright 1992-2018 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2020 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2018-08-02'
|
||||
timestamp='2020-11-19'
|
||||
|
||||
# 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
|
||||
|
@ -27,12 +27,12 @@ timestamp='2018-08-02'
|
|||
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
|
||||
#
|
||||
# You can get the latest version of this script from:
|
||||
# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
|
||||
# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
|
||||
#
|
||||
# Please send patches to <config-patches@gnu.org>.
|
||||
|
||||
|
||||
me=`echo "$0" | sed -e 's,.*/,,'`
|
||||
me=$(echo "$0" | sed -e 's,.*/,,')
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]
|
||||
|
@ -50,7 +50,7 @@ version="\
|
|||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright 1992-2018 Free Software Foundation, Inc.
|
||||
Copyright 1992-2020 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
|
@ -96,13 +96,14 @@ fi
|
|||
|
||||
tmp=
|
||||
# shellcheck disable=SC2172
|
||||
trap 'test -z "$tmp" || rm -fr "$tmp"' 1 2 13 15
|
||||
trap 'exitcode=$?; test -z "$tmp" || rm -fr "$tmp"; exit $exitcode' 0
|
||||
trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
|
||||
|
||||
set_cc_for_build() {
|
||||
# prevent multiple calls if $tmp is already set
|
||||
test "$tmp" && return 0
|
||||
: "${TMPDIR=/tmp}"
|
||||
# shellcheck disable=SC2039
|
||||
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
|
||||
{ tmp=$( (umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null) && test -n "$tmp" && test -d "$tmp" ; } ||
|
||||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
|
||||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
|
||||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
|
||||
|
@ -130,16 +131,14 @@ if test -f /.attbin/uname ; then
|
|||
PATH=$PATH:/.attbin ; export PATH
|
||||
fi
|
||||
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=$( (uname -r) 2>/dev/null) || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=$( (uname -s) 2>/dev/null) || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown
|
||||
|
||||
case "$UNAME_SYSTEM" in
|
||||
Linux|GNU|GNU/*)
|
||||
# If the system lacks a compiler, then just pick glibc.
|
||||
# We could probably try harder.
|
||||
LIBC=gnu
|
||||
LIBC=unknown
|
||||
|
||||
set_cc_for_build
|
||||
cat <<-EOF > "$dummy.c"
|
||||
|
@ -148,17 +147,29 @@ Linux|GNU|GNU/*)
|
|||
LIBC=uclibc
|
||||
#elif defined(__dietlibc__)
|
||||
LIBC=dietlibc
|
||||
#else
|
||||
#elif defined(__GLIBC__)
|
||||
LIBC=gnu
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
/* First heuristic to detect musl libc. */
|
||||
#ifdef __DEFINED_va_list
|
||||
LIBC=musl
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
|
||||
eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')"
|
||||
|
||||
# If ldd exists, use it to detect musl libc.
|
||||
if command -v ldd >/dev/null && \
|
||||
ldd --version 2>&1 | grep -q ^musl
|
||||
then
|
||||
LIBC=musl
|
||||
# Second heuristic to detect musl libc.
|
||||
if [ "$LIBC" = unknown ] &&
|
||||
command -v ldd >/dev/null &&
|
||||
ldd --version 2>&1 | grep -q ^musl; then
|
||||
LIBC=musl
|
||||
fi
|
||||
|
||||
# If the system lacks a compiler, then just pick glibc.
|
||||
# We could probably try harder.
|
||||
if [ "$LIBC" = unknown ]; then
|
||||
LIBC=gnu
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
@ -178,19 +189,20 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
# Note: NetBSD doesn't particularly care about the vendor
|
||||
# portion of the name. We always set it to "unknown".
|
||||
sysctl="sysctl -n hw.machine_arch"
|
||||
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
|
||||
UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \
|
||||
"/sbin/$sysctl" 2>/dev/null || \
|
||||
"/usr/sbin/$sysctl" 2>/dev/null || \
|
||||
echo unknown)`
|
||||
echo unknown))
|
||||
case "$UNAME_MACHINE_ARCH" in
|
||||
aarch64eb) machine=aarch64_be-unknown ;;
|
||||
armeb) machine=armeb-unknown ;;
|
||||
arm*) machine=arm-unknown ;;
|
||||
sh3el) machine=shl-unknown ;;
|
||||
sh3eb) machine=sh-unknown ;;
|
||||
sh5el) machine=sh5le-unknown ;;
|
||||
earmv*)
|
||||
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
|
||||
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
|
||||
arch=$(echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,')
|
||||
endian=$(echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p')
|
||||
machine="${arch}${endian}"-unknown
|
||||
;;
|
||||
*) machine="$UNAME_MACHINE_ARCH"-unknown ;;
|
||||
|
@ -221,7 +233,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
case "$UNAME_MACHINE_ARCH" in
|
||||
earm*)
|
||||
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
|
||||
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
|
||||
abi=$(echo "$UNAME_MACHINE_ARCH" | sed -e "$expr")
|
||||
;;
|
||||
esac
|
||||
# The OS release
|
||||
|
@ -234,7 +246,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
release='-gnu'
|
||||
;;
|
||||
*)
|
||||
release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
|
||||
release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2)
|
||||
;;
|
||||
esac
|
||||
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
|
||||
|
@ -243,15 +255,15 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
echo "$machine-${os}${release}${abi-}"
|
||||
exit ;;
|
||||
*:Bitrig:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
|
||||
UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//')
|
||||
echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:OpenBSD:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
|
||||
UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//')
|
||||
echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:LibertyBSD:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
|
||||
UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//')
|
||||
echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:MidnightBSD:*:*)
|
||||
|
@ -263,6 +275,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
*:SolidBSD:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:OS108:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
macppc:MirBSD:*:*)
|
||||
echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
|
@ -272,26 +287,29 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
*:Sortix:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-sortix
|
||||
exit ;;
|
||||
*:Twizzler:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-twizzler
|
||||
exit ;;
|
||||
*:Redox:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-redox
|
||||
exit ;;
|
||||
mips:OSF1:*.*)
|
||||
echo mips-dec-osf1
|
||||
exit ;;
|
||||
echo mips-dec-osf1
|
||||
exit ;;
|
||||
alpha:OSF1:*:*)
|
||||
case $UNAME_RELEASE in
|
||||
*4.0)
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}')
|
||||
;;
|
||||
*5.*)
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
|
||||
UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}')
|
||||
;;
|
||||
esac
|
||||
# According to Compaq, /usr/sbin/psrinfo has been available on
|
||||
# OSF/1 and Tru64 systems produced since 1995. I hope that
|
||||
# covers most systems running today. This code pipes the CPU
|
||||
# types through head -n 1, so we only detect the type of CPU 0.
|
||||
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
|
||||
ALPHA_CPU_TYPE=$(/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1)
|
||||
case "$ALPHA_CPU_TYPE" in
|
||||
"EV4 (21064)")
|
||||
UNAME_MACHINE=alpha ;;
|
||||
|
@ -329,7 +347,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
|
||||
echo "$UNAME_MACHINE"-dec-osf"$(echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)"
|
||||
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
|
||||
exitcode=$?
|
||||
trap '' 0
|
||||
|
@ -363,7 +381,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
exit ;;
|
||||
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
if test "$( (/bin/universe) 2>/dev/null)" = att ; then
|
||||
echo pyramid-pyramid-sysv3
|
||||
else
|
||||
echo pyramid-pyramid-bsd
|
||||
|
@ -376,54 +394,59 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
echo sparc-icl-nx6
|
||||
exit ;;
|
||||
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
|
||||
case `/usr/bin/uname -p` in
|
||||
case $(/usr/bin/uname -p) in
|
||||
sparc) echo sparc-icl-nx7; exit ;;
|
||||
esac ;;
|
||||
s390x:SunOS:*:*)
|
||||
echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
|
||||
echo "$UNAME_MACHINE"-ibm-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')"
|
||||
exit ;;
|
||||
sun4H:SunOS:5.*:*)
|
||||
echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
|
||||
echo sparc-hal-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
|
||||
exit ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
|
||||
echo sparc-sun-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')"
|
||||
exit ;;
|
||||
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
|
||||
echo i386-pc-auroraux"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
|
||||
UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
|
||||
case `isainfo -b` in
|
||||
32)
|
||||
echo i386-pc-solaris2"$UNAME_REL"
|
||||
;;
|
||||
64)
|
||||
echo x86_64-pc-solaris2"$UNAME_REL"
|
||||
;;
|
||||
esac
|
||||
set_cc_for_build
|
||||
SUN_ARCH=i386
|
||||
# If there is a compiler, see if it is configured for 64-bit objects.
|
||||
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
|
||||
# This test works for both compilers.
|
||||
if test "$CC_FOR_BUILD" != no_compiler_found; then
|
||||
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
SUN_ARCH=x86_64
|
||||
fi
|
||||
fi
|
||||
echo "$SUN_ARCH"-pc-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
|
||||
exit ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
|
||||
# it's likely to be more like Solaris than SunOS4.
|
||||
echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
|
||||
echo sparc-sun-solaris3"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
|
||||
exit ;;
|
||||
sun4*:SunOS:*:*)
|
||||
case "`/usr/bin/arch -k`" in
|
||||
case "$(/usr/bin/arch -k)" in
|
||||
Series*|S4*)
|
||||
UNAME_RELEASE=`uname -v`
|
||||
UNAME_RELEASE=$(uname -v)
|
||||
;;
|
||||
esac
|
||||
# Japanese Language versions have a version number like `4.1.3-JL'.
|
||||
echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
|
||||
echo sparc-sun-sunos"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/')"
|
||||
exit ;;
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
sun*:*:4.2BSD:*)
|
||||
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null)
|
||||
test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
|
||||
case "`/bin/arch`" in
|
||||
case "$(/bin/arch)" in
|
||||
sun3)
|
||||
echo m68k-sun-sunos"$UNAME_RELEASE"
|
||||
;;
|
||||
|
@ -503,8 +526,8 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
|
||||
dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
|
||||
SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
|
||||
dummyarg=$(echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p') &&
|
||||
SYSTEM_NAME=$("$dummy" "$dummyarg") &&
|
||||
{ echo "$SYSTEM_NAME"; exit; }
|
||||
echo mips-mips-riscos"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
|
@ -531,11 +554,11 @@ EOF
|
|||
exit ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
|
||||
UNAME_PROCESSOR=$(/usr/bin/uname -p)
|
||||
if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
|
||||
then
|
||||
if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
|
||||
[ "$TARGET_BINARY_INTERFACE"x = x ]
|
||||
if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
|
||||
test "$TARGET_BINARY_INTERFACE"x = x
|
||||
then
|
||||
echo m88k-dg-dgux"$UNAME_RELEASE"
|
||||
else
|
||||
|
@ -559,17 +582,17 @@ EOF
|
|||
echo m68k-tektronix-bsd
|
||||
exit ;;
|
||||
*:IRIX*:*:*)
|
||||
echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
|
||||
echo mips-sgi-irix"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/g')"
|
||||
exit ;;
|
||||
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
|
||||
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
|
||||
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
|
||||
exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX '
|
||||
i*86:AIX:*:*)
|
||||
echo i386-ibm-aix
|
||||
exit ;;
|
||||
ia64:AIX:*:*)
|
||||
if [ -x /usr/bin/oslevel ] ; then
|
||||
IBM_REV=`/usr/bin/oslevel`
|
||||
if test -x /usr/bin/oslevel ; then
|
||||
IBM_REV=$(/usr/bin/oslevel)
|
||||
else
|
||||
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
|
||||
fi
|
||||
|
@ -589,7 +612,7 @@ EOF
|
|||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
|
||||
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy")
|
||||
then
|
||||
echo "$SYSTEM_NAME"
|
||||
else
|
||||
|
@ -602,15 +625,15 @@ EOF
|
|||
fi
|
||||
exit ;;
|
||||
*:AIX:*:[4567])
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
IBM_CPU_ID=$(/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }')
|
||||
if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
IBM_ARCH=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/lslpp ] ; then
|
||||
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
|
||||
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
|
||||
if test -x /usr/bin/lslpp ; then
|
||||
IBM_REV=$(/usr/bin/lslpp -Lqc bos.rte.libc |
|
||||
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/)
|
||||
else
|
||||
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
|
||||
fi
|
||||
|
@ -638,14 +661,14 @@ EOF
|
|||
echo m68k-hp-bsd4.4
|
||||
exit ;;
|
||||
9000/[34678]??:HP-UX:*:*)
|
||||
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
|
||||
HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//')
|
||||
case "$UNAME_MACHINE" in
|
||||
9000/31?) HP_ARCH=m68000 ;;
|
||||
9000/[34]??) HP_ARCH=m68k ;;
|
||||
9000/[678][0-9][0-9])
|
||||
if [ -x /usr/bin/getconf ]; then
|
||||
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
|
||||
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
|
||||
if test -x /usr/bin/getconf; then
|
||||
sc_cpu_version=$(/usr/bin/getconf SC_CPU_VERSION 2>/dev/null)
|
||||
sc_kernel_bits=$(/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null)
|
||||
case "$sc_cpu_version" in
|
||||
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
|
||||
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
|
||||
|
@ -657,7 +680,7 @@ EOF
|
|||
esac ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$HP_ARCH" = "" ]; then
|
||||
if test "$HP_ARCH" = ""; then
|
||||
set_cc_for_build
|
||||
sed 's/^ //' << EOF > "$dummy.c"
|
||||
|
||||
|
@ -692,11 +715,11 @@ EOF
|
|||
exit (0);
|
||||
}
|
||||
EOF
|
||||
(CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
|
||||
(CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=$("$dummy")
|
||||
test -z "$HP_ARCH" && HP_ARCH=hppa
|
||||
fi ;;
|
||||
esac
|
||||
if [ "$HP_ARCH" = hppa2.0w ]
|
||||
if test "$HP_ARCH" = hppa2.0w
|
||||
then
|
||||
set_cc_for_build
|
||||
|
||||
|
@ -720,7 +743,7 @@ EOF
|
|||
echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
|
||||
exit ;;
|
||||
ia64:HP-UX:*:*)
|
||||
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
|
||||
HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//')
|
||||
echo ia64-hp-hpux"$HPUX_REV"
|
||||
exit ;;
|
||||
3050*:HI-UX:*:*)
|
||||
|
@ -750,7 +773,7 @@ EOF
|
|||
exit (0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
|
||||
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") &&
|
||||
{ echo "$SYSTEM_NAME"; exit; }
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit ;;
|
||||
|
@ -770,7 +793,7 @@ EOF
|
|||
echo hppa1.0-hp-osf
|
||||
exit ;;
|
||||
i*86:OSF1:*:*)
|
||||
if [ -x /usr/sbin/sysversion ] ; then
|
||||
if test -x /usr/sbin/sysversion ; then
|
||||
echo "$UNAME_MACHINE"-unknown-osf1mk
|
||||
else
|
||||
echo "$UNAME_MACHINE"-unknown-osf1
|
||||
|
@ -819,14 +842,14 @@ EOF
|
|||
echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
|
||||
exit ;;
|
||||
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
|
||||
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
|
||||
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
|
||||
FUJITSU_PROC=$(uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
|
||||
FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///')
|
||||
FUJITSU_REL=$(echo "$UNAME_RELEASE" | sed -e 's/ /_/')
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
5000:UNIX_System_V:4.*:*)
|
||||
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
|
||||
FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///')
|
||||
FUJITSU_REL=$(echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/')
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
|
||||
|
@ -838,26 +861,26 @@ EOF
|
|||
*:BSD/OS:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
arm*:FreeBSD:*:*)
|
||||
UNAME_PROCESSOR=`uname -p`
|
||||
arm:FreeBSD:*:*)
|
||||
UNAME_PROCESSOR=$(uname -p)
|
||||
set_cc_for_build
|
||||
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_PCS_VFP
|
||||
then
|
||||
echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
|
||||
echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi
|
||||
else
|
||||
echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
|
||||
echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf
|
||||
fi
|
||||
exit ;;
|
||||
*:FreeBSD:*:*)
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
UNAME_PROCESSOR=$(/usr/bin/uname -p)
|
||||
case "$UNAME_PROCESSOR" in
|
||||
amd64)
|
||||
UNAME_PROCESSOR=x86_64 ;;
|
||||
i386)
|
||||
UNAME_PROCESSOR=i586 ;;
|
||||
esac
|
||||
echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
|
||||
echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')"
|
||||
exit ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo "$UNAME_MACHINE"-pc-cygwin
|
||||
|
@ -890,18 +913,18 @@ EOF
|
|||
echo "$UNAME_MACHINE"-pc-uwin
|
||||
exit ;;
|
||||
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
|
||||
echo x86_64-unknown-cygwin
|
||||
echo x86_64-pc-cygwin
|
||||
exit ;;
|
||||
prep*:SunOS:5.*:*)
|
||||
echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
|
||||
echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
|
||||
exit ;;
|
||||
*:GNU:*:*)
|
||||
# the GNU system
|
||||
echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
|
||||
echo "$(echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,')-unknown-$LIBC$(echo "$UNAME_RELEASE"|sed -e 's,/.*$,,')"
|
||||
exit ;;
|
||||
*:GNU/*:*:*)
|
||||
# other systems with GNU libc and userland
|
||||
echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
|
||||
echo "$UNAME_MACHINE-unknown-$(echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]")$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')-$LIBC"
|
||||
exit ;;
|
||||
*:Minix:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-minix
|
||||
|
@ -914,7 +937,7 @@ EOF
|
|||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||
exit ;;
|
||||
alpha:Linux:*:*)
|
||||
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
|
||||
case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in
|
||||
EV5) UNAME_MACHINE=alphaev5 ;;
|
||||
EV56) UNAME_MACHINE=alphaev56 ;;
|
||||
PCA56) UNAME_MACHINE=alphapca56 ;;
|
||||
|
@ -981,22 +1004,50 @@ EOF
|
|||
exit ;;
|
||||
mips:Linux:*:* | mips64:Linux:*:*)
|
||||
set_cc_for_build
|
||||
IS_GLIBC=0
|
||||
test x"${LIBC}" = xgnu && IS_GLIBC=1
|
||||
sed 's/^ //' << EOF > "$dummy.c"
|
||||
#undef CPU
|
||||
#undef ${UNAME_MACHINE}
|
||||
#undef ${UNAME_MACHINE}el
|
||||
#undef mips
|
||||
#undef mipsel
|
||||
#undef mips64
|
||||
#undef mips64el
|
||||
#if ${IS_GLIBC} && defined(_ABI64)
|
||||
LIBCABI=gnuabi64
|
||||
#else
|
||||
#if ${IS_GLIBC} && defined(_ABIN32)
|
||||
LIBCABI=gnuabin32
|
||||
#else
|
||||
LIBCABI=${LIBC}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
|
||||
CPU=mipsisa64r6
|
||||
#else
|
||||
#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
|
||||
CPU=mipsisa32r6
|
||||
#else
|
||||
#if defined(__mips64)
|
||||
CPU=mips64
|
||||
#else
|
||||
CPU=mips
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=${UNAME_MACHINE}el
|
||||
MIPS_ENDIAN=el
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=${UNAME_MACHINE}
|
||||
MIPS_ENDIAN=
|
||||
#else
|
||||
CPU=
|
||||
MIPS_ENDIAN=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
|
||||
test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
|
||||
eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI')"
|
||||
test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
|
||||
;;
|
||||
mips64el:Linux:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||
|
@ -1015,7 +1066,7 @@ EOF
|
|||
exit ;;
|
||||
parisc:Linux:*:* | hppa:Linux:*:*)
|
||||
# Look for CPU level
|
||||
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
|
||||
case $(grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2) in
|
||||
PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
|
||||
PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
|
||||
*) echo hppa-unknown-linux-"$LIBC" ;;
|
||||
|
@ -1055,7 +1106,17 @@ EOF
|
|||
echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
|
||||
exit ;;
|
||||
x86_64:Linux:*:*)
|
||||
echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
|
||||
set_cc_for_build
|
||||
LIBCABI=$LIBC
|
||||
if test "$CC_FOR_BUILD" != no_compiler_found; then
|
||||
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
|
||||
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_X32 >/dev/null
|
||||
then
|
||||
LIBCABI="$LIBC"x32
|
||||
fi
|
||||
fi
|
||||
echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI"
|
||||
exit ;;
|
||||
xtensa*:Linux:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||
|
@ -1095,7 +1156,7 @@ EOF
|
|||
echo "$UNAME_MACHINE"-pc-msdosdjgpp
|
||||
exit ;;
|
||||
i*86:*:4.*:*)
|
||||
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
|
||||
UNAME_REL=$(echo "$UNAME_RELEASE" | sed 's/\/MP$//')
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
|
||||
else
|
||||
|
@ -1104,19 +1165,19 @@ EOF
|
|||
exit ;;
|
||||
i*86:*:5:[678]*)
|
||||
# UnixWare 7.x, OpenUNIX and OpenServer 6.
|
||||
case `/bin/uname -X | grep "^Machine"` in
|
||||
case $(/bin/uname -X | grep "^Machine") in
|
||||
*486*) UNAME_MACHINE=i486 ;;
|
||||
*Pentium) UNAME_MACHINE=i586 ;;
|
||||
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
|
||||
esac
|
||||
echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
|
||||
echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}"
|
||||
exit ;;
|
||||
i*86:*:3.2:*)
|
||||
if test -f /usr/options/cb.name; then
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
UNAME_REL=$(sed -n 's/.*Version //p' </usr/options/cb.name)
|
||||
echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
|
||||
UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //'))
|
||||
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
|
@ -1166,7 +1227,7 @@ EOF
|
|||
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
&& OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
|
@ -1177,7 +1238,7 @@ EOF
|
|||
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
|
||||
OS_REL='.3'
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
&& OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
|
@ -1210,7 +1271,7 @@ EOF
|
|||
exit ;;
|
||||
*:SINIX-*:*:*)
|
||||
if uname -p 2>/dev/null >/dev/null ; then
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
UNAME_MACHINE=$( (uname -p) 2>/dev/null)
|
||||
echo "$UNAME_MACHINE"-sni-sysv4
|
||||
else
|
||||
echo ns32k-sni-sysv
|
||||
|
@ -1244,7 +1305,7 @@ EOF
|
|||
echo mips-sony-newsos6
|
||||
exit ;;
|
||||
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
if test -d /usr/nec; then
|
||||
echo mips-nec-sysv"$UNAME_RELEASE"
|
||||
else
|
||||
echo mips-unknown-sysv"$UNAME_RELEASE"
|
||||
|
@ -1292,44 +1353,48 @@ EOF
|
|||
*:Rhapsody:*:*)
|
||||
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
arm64:Darwin:*:*)
|
||||
echo aarch64-apple-darwin"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:Darwin:*:*)
|
||||
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
|
||||
set_cc_for_build
|
||||
if test "$UNAME_PROCESSOR" = unknown ; then
|
||||
UNAME_PROCESSOR=powerpc
|
||||
UNAME_PROCESSOR=$(uname -p)
|
||||
case $UNAME_PROCESSOR in
|
||||
unknown) UNAME_PROCESSOR=powerpc ;;
|
||||
esac
|
||||
if command -v xcode-select > /dev/null 2> /dev/null && \
|
||||
! xcode-select --print-path > /dev/null 2> /dev/null ; then
|
||||
# Avoid executing cc if there is no toolchain installed as
|
||||
# cc will be a stub that puts up a graphical alert
|
||||
# prompting the user to install developer tools.
|
||||
CC_FOR_BUILD=no_compiler_found
|
||||
else
|
||||
set_cc_for_build
|
||||
fi
|
||||
if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
|
||||
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
|
||||
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
case $UNAME_PROCESSOR in
|
||||
i386) UNAME_PROCESSOR=x86_64 ;;
|
||||
powerpc) UNAME_PROCESSOR=powerpc64 ;;
|
||||
esac
|
||||
fi
|
||||
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
|
||||
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
|
||||
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_PPC >/dev/null
|
||||
then
|
||||
UNAME_PROCESSOR=powerpc
|
||||
fi
|
||||
if test "$CC_FOR_BUILD" != no_compiler_found; then
|
||||
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
case $UNAME_PROCESSOR in
|
||||
i386) UNAME_PROCESSOR=x86_64 ;;
|
||||
powerpc) UNAME_PROCESSOR=powerpc64 ;;
|
||||
esac
|
||||
fi
|
||||
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
|
||||
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
|
||||
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_PPC >/dev/null
|
||||
then
|
||||
UNAME_PROCESSOR=powerpc
|
||||
fi
|
||||
elif test "$UNAME_PROCESSOR" = i386 ; then
|
||||
# Avoid executing cc on OS X 10.9, as it ships with a stub
|
||||
# that puts up a graphical alert prompting to install
|
||||
# developer tools. Any system running Mac OS X 10.7 or
|
||||
# later (Darwin 11 and later) is required to have a 64-bit
|
||||
# processor. This is not true of the ARM version of Darwin
|
||||
# that Apple uses in portable devices.
|
||||
UNAME_PROCESSOR=x86_64
|
||||
# uname -m returns i386 or x86_64
|
||||
UNAME_PROCESSOR=$UNAME_MACHINE
|
||||
fi
|
||||
echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:procnto*:*:* | *:QNX:[0123456789]*:*)
|
||||
UNAME_PROCESSOR=`uname -p`
|
||||
UNAME_PROCESSOR=$(uname -p)
|
||||
if test "$UNAME_PROCESSOR" = x86; then
|
||||
UNAME_PROCESSOR=i386
|
||||
UNAME_MACHINE=pc
|
||||
|
@ -1397,10 +1462,10 @@ EOF
|
|||
echo mips-sei-seiux"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
*:DragonFly:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
|
||||
echo "$UNAME_MACHINE"-unknown-dragonfly"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')"
|
||||
exit ;;
|
||||
*:*VMS:*:*)
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
UNAME_MACHINE=$( (uname -p) 2>/dev/null)
|
||||
case "$UNAME_MACHINE" in
|
||||
A*) echo alpha-dec-vms ; exit ;;
|
||||
I*) echo ia64-dec-vms ; exit ;;
|
||||
|
@ -1410,7 +1475,7 @@ EOF
|
|||
echo i386-pc-xenix
|
||||
exit ;;
|
||||
i*86:skyos:*:*)
|
||||
echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
|
||||
echo "$UNAME_MACHINE"-pc-skyos"$(echo "$UNAME_RELEASE" | sed -e 's/ .*$//')"
|
||||
exit ;;
|
||||
i*86:rdos:*:*)
|
||||
echo "$UNAME_MACHINE"-pc-rdos
|
||||
|
@ -1424,8 +1489,148 @@ EOF
|
|||
amd64:Isilon\ OneFS:*:*)
|
||||
echo x86_64-unknown-onefs
|
||||
exit ;;
|
||||
*:Unleashed:*:*)
|
||||
echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
|
||||
exit ;;
|
||||
esac
|
||||
|
||||
# No uname command or uname output not recognized.
|
||||
set_cc_for_build
|
||||
cat > "$dummy.c" <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
|
||||
#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
|
||||
#include <signal.h>
|
||||
#if defined(_SIZE_T_) || defined(SIGLOST)
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
#if defined (MIPSEB)
|
||||
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
|
||||
I don't know.... */
|
||||
printf ("mips-sony-bsd\n"); exit (0);
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (NeXT)
|
||||
#if !defined (__ARCHITECTURE__)
|
||||
#define __ARCHITECTURE__ "m68k"
|
||||
#endif
|
||||
int version;
|
||||
version=$( (hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null);
|
||||
if (version < 4)
|
||||
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
|
||||
else
|
||||
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
|
||||
exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (MULTIMAX) || defined (n16)
|
||||
#if defined (UMAXV)
|
||||
printf ("ns32k-encore-sysv\n"); exit (0);
|
||||
#else
|
||||
#if defined (CMU)
|
||||
printf ("ns32k-encore-mach\n"); exit (0);
|
||||
#else
|
||||
printf ("ns32k-encore-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__386BSD__)
|
||||
printf ("i386-pc-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (sequent)
|
||||
#if defined (i386)
|
||||
printf ("i386-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#if defined (ns32000)
|
||||
printf ("ns32k-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_)
|
||||
struct utsname un;
|
||||
|
||||
uname(&un);
|
||||
if (strncmp(un.version, "V2", 2) == 0) {
|
||||
printf ("i386-sequent-ptx2\n"); exit (0);
|
||||
}
|
||||
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
|
||||
printf ("i386-sequent-ptx1\n"); exit (0);
|
||||
}
|
||||
printf ("i386-sequent-ptx\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (vax)
|
||||
#if !defined (ultrix)
|
||||
#include <sys/param.h>
|
||||
#if defined (BSD)
|
||||
#if BSD == 43
|
||||
printf ("vax-dec-bsd4.3\n"); exit (0);
|
||||
#else
|
||||
#if BSD == 199006
|
||||
printf ("vax-dec-bsd4.3reno\n"); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#endif
|
||||
#else
|
||||
#if defined(_SIZE_T_) || defined(SIGLOST)
|
||||
struct utsname un;
|
||||
uname (&un);
|
||||
printf ("vax-dec-ultrix%s\n", un.release); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
|
||||
#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
|
||||
#if defined(_SIZE_T_) || defined(SIGLOST)
|
||||
struct utsname *un;
|
||||
uname (&un);
|
||||
printf ("mips-dec-ultrix%s\n", un.release); exit (0);
|
||||
#else
|
||||
printf ("mips-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (alliant) && defined (i860)
|
||||
printf ("i860-alliant-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
exit (1);
|
||||
}
|
||||
EOF
|
||||
|
||||
$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) &&
|
||||
{ echo "$SYSTEM_NAME"; exit; }
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
|
||||
|
||||
echo "$0: unable to guess system type" >&2
|
||||
|
||||
case "$UNAME_MACHINE:$UNAME_SYSTEM" in
|
||||
|
@ -1445,9 +1650,15 @@ This script (version $timestamp), has failed to recognize the
|
|||
operating system you are using. If your script is old, overwrite *all*
|
||||
copies of config.guess and config.sub with the latest versions from:
|
||||
|
||||
https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
|
||||
https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
|
||||
and
|
||||
https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
|
||||
https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
|
||||
EOF
|
||||
|
||||
year=$(echo $timestamp | sed 's,-.*,,')
|
||||
# shellcheck disable=SC2003
|
||||
if test "$(expr "$(date +%Y)" - "$year")" -lt 3 ; then
|
||||
cat >&2 <<EOF
|
||||
|
||||
If $0 has already been updated, send the following data and any
|
||||
information you think might be pertinent to config-patches@gnu.org to
|
||||
|
@ -1455,26 +1666,27 @@ provide the necessary information to handle your system.
|
|||
|
||||
config.guess timestamp = $timestamp
|
||||
|
||||
uname -m = `(uname -m) 2>/dev/null || echo unknown`
|
||||
uname -r = `(uname -r) 2>/dev/null || echo unknown`
|
||||
uname -s = `(uname -s) 2>/dev/null || echo unknown`
|
||||
uname -v = `(uname -v) 2>/dev/null || echo unknown`
|
||||
uname -m = $( (uname -m) 2>/dev/null || echo unknown)
|
||||
uname -r = $( (uname -r) 2>/dev/null || echo unknown)
|
||||
uname -s = $( (uname -s) 2>/dev/null || echo unknown)
|
||||
uname -v = $( (uname -v) 2>/dev/null || echo unknown)
|
||||
|
||||
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
|
||||
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
|
||||
/usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null)
|
||||
/bin/uname -X = $( (/bin/uname -X) 2>/dev/null)
|
||||
|
||||
hostinfo = `(hostinfo) 2>/dev/null`
|
||||
/bin/universe = `(/bin/universe) 2>/dev/null`
|
||||
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
|
||||
/bin/arch = `(/bin/arch) 2>/dev/null`
|
||||
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
|
||||
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
|
||||
hostinfo = $( (hostinfo) 2>/dev/null)
|
||||
/bin/universe = $( (/bin/universe) 2>/dev/null)
|
||||
/usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null)
|
||||
/bin/arch = $( (/bin/arch) 2>/dev/null)
|
||||
/usr/bin/oslevel = $( (/usr/bin/oslevel) 2>/dev/null)
|
||||
/usr/convex/getsysinfo = $( (/usr/convex/getsysinfo) 2>/dev/null)
|
||||
|
||||
UNAME_MACHINE = "$UNAME_MACHINE"
|
||||
UNAME_RELEASE = "$UNAME_RELEASE"
|
||||
UNAME_SYSTEM = "$UNAME_SYSTEM"
|
||||
UNAME_VERSION = "$UNAME_VERSION"
|
||||
EOF
|
||||
fi
|
||||
|
||||
exit 1
|
||||
|
||||
|
|
1756
config/config.sub
vendored
1756
config/config.sub
vendored
File diff suppressed because it is too large
Load diff
|
@ -255,6 +255,7 @@ if test -n "$enable_s3"; then
|
|||
declare -a aws_version_tokens=($(printf '#include <aws/core/VersionConfig.h>\nAWS_SDK_VERSION_STRING' | $CPP $CPPFLAGS - | grep -v '^#.*' | sed 's/"//g' | tr '.' ' '))
|
||||
AC_DEFINE_UNQUOTED([AWS_VERSION_MAJOR], ${aws_version_tokens@<:@0@:>@}, [Major version of aws-sdk-cpp.])
|
||||
AC_DEFINE_UNQUOTED([AWS_VERSION_MINOR], ${aws_version_tokens@<:@1@:>@}, [Minor version of aws-sdk-cpp.])
|
||||
AC_DEFINE_UNQUOTED([AWS_VERSION_PATCH], ${aws_version_tokens@<:@2@:>@}, [Patch version of aws-sdk-cpp.])
|
||||
fi
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,40 @@
|
|||
command:
|
||||
|
||||
with builtins;
|
||||
with import ./utils.nix;
|
||||
|
||||
let
|
||||
|
||||
showCommand =
|
||||
{ command, section, def }:
|
||||
"${section} Name\n\n"
|
||||
{ command, def, filename }:
|
||||
"# Name\n\n"
|
||||
+ "`${command}` - ${def.description}\n\n"
|
||||
+ "${section} Synopsis\n\n"
|
||||
+ "# Synopsis\n\n"
|
||||
+ showSynopsis { inherit command; args = def.args; }
|
||||
+ (if def ? doc
|
||||
then "${section} Description\n\n" + def.doc + "\n\n"
|
||||
else "")
|
||||
+ (let s = showFlags def.flags; in
|
||||
if s != ""
|
||||
then "${section} Flags\n\n${s}"
|
||||
+ (if def.commands or {} != {}
|
||||
then
|
||||
"where *subcommand* is one of the following:\n\n"
|
||||
# FIXME: group by category
|
||||
+ concatStrings (map (name:
|
||||
"* [`${command} ${name}`](./${appendName filename name}.md) - ${def.commands.${name}.description}\n")
|
||||
(attrNames def.commands))
|
||||
+ "\n"
|
||||
else "")
|
||||
+ (if def.examples or [] != []
|
||||
then
|
||||
"${section} Examples\n\n"
|
||||
"# Examples\n\n"
|
||||
+ concatStrings (map ({ description, command }: "${description}\n\n```console\n${command}\n```\n\n") def.examples)
|
||||
else "")
|
||||
+ (if def.commands or [] != []
|
||||
then concatStrings (
|
||||
map (name:
|
||||
"# Subcommand `${command} ${name}`\n\n"
|
||||
+ showCommand { command = command + " " + name; section = "##"; def = def.commands.${name}; })
|
||||
(attrNames def.commands))
|
||||
else "");
|
||||
+ (if def ? doc
|
||||
then def.doc + "\n\n"
|
||||
else "")
|
||||
+ (let s = showFlags def.flags; in
|
||||
if s != ""
|
||||
then "# Flags\n\n${s}"
|
||||
else "")
|
||||
;
|
||||
|
||||
appendName = filename: name: (if filename == "nix" then "nix3" else filename) + "-" + name;
|
||||
|
||||
showFlags = flags:
|
||||
concatStrings
|
||||
|
@ -48,8 +55,20 @@ let
|
|||
"`${command}` [*flags*...] ${concatStringsSep " "
|
||||
(map (arg: "*${arg.label}*" + (if arg ? arity then "" else "...")) args)}\n\n";
|
||||
|
||||
processCommand = { command, def, filename }:
|
||||
[ { name = filename + ".md"; value = showCommand { inherit command def filename; }; inherit command; } ]
|
||||
++ concatMap
|
||||
(name: processCommand {
|
||||
filename = appendName filename name;
|
||||
command = command + " " + name;
|
||||
def = def.commands.${name};
|
||||
})
|
||||
(attrNames def.commands or {});
|
||||
|
||||
in
|
||||
|
||||
command:
|
||||
|
||||
showCommand { command = "nix"; section = "#"; def = command; }
|
||||
let
|
||||
manpages = processCommand { filename = "nix"; command = "nix"; def = command; };
|
||||
summary = concatStrings (map (manpage: " - [${manpage.command}](command-ref/new-cli/${manpage.name})\n") manpages);
|
||||
in
|
||||
(listToAttrs manpages) // { "SUMMARY.md" = summary; }
|
||||
|
|
|
@ -4,7 +4,7 @@ MANUAL_SRCS := $(call rwildcard, $(d)/src, *.md)
|
|||
|
||||
# Generate man pages.
|
||||
man-pages := $(foreach n, \
|
||||
nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 nix.1 \
|
||||
nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 \
|
||||
nix-collect-garbage.1 \
|
||||
nix-prefetch-url.1 nix-channel.1 \
|
||||
nix-hash.1 nix-copy-closure.1 \
|
||||
|
@ -13,8 +13,6 @@ man-pages := $(foreach n, \
|
|||
|
||||
clean-files += $(d)/*.1 $(d)/*.5 $(d)/*.8
|
||||
|
||||
dist-files += $(man-pages)
|
||||
|
||||
# Provide a dummy environment for nix, so that it will not access files outside the macOS sandbox.
|
||||
dummy-env = env -i \
|
||||
HOME=/dummy \
|
||||
|
@ -22,7 +20,7 @@ dummy-env = env -i \
|
|||
NIX_SSL_CERT_FILE=/dummy/no-ca-bundle.crt \
|
||||
NIX_STATE_DIR=/dummy
|
||||
|
||||
nix-eval = $(dummy-env) $(bindir)/nix eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw --expr
|
||||
nix-eval = $(dummy-env) $(bindir)/nix eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw
|
||||
|
||||
$(d)/%.1: $(d)/src/command-ref/%.md
|
||||
@printf "Title: %s\n\n" "$$(basename $@ .1)" > $^.tmp
|
||||
|
@ -42,13 +40,17 @@ $(d)/nix.conf.5: $(d)/src/command-ref/conf-file.md
|
|||
$(trace-gen) lowdown -sT man $^.tmp -o $@
|
||||
@rm $^.tmp
|
||||
|
||||
$(d)/src/command-ref/nix.md: $(d)/nix.json $(d)/generate-manpage.nix $(bindir)/nix
|
||||
$(trace-gen) $(nix-eval) 'import doc/manual/generate-manpage.nix (builtins.fromJSON (builtins.readFile $<))' > $@.tmp
|
||||
$(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/command-ref/new-cli
|
||||
$(trace-gen) cat doc/manual/src/SUMMARY.md.in | while IFS= read line; do if [[ $$line = @manpages@ ]]; then cat doc/manual/src/command-ref/new-cli/SUMMARY.md; else echo "$$line"; fi; done > $@.tmp
|
||||
@mv $@.tmp $@
|
||||
|
||||
$(d)/src/command-ref/new-cli: $(d)/nix.json $(d)/generate-manpage.nix $(bindir)/nix
|
||||
@rm -rf $@
|
||||
$(trace-gen) $(nix-eval) --write-to $@ --expr 'import doc/manual/generate-manpage.nix (builtins.fromJSON (builtins.readFile $<))'
|
||||
|
||||
$(d)/src/command-ref/conf-file.md: $(d)/conf-file.json $(d)/generate-options.nix $(d)/src/command-ref/conf-file-prefix.md $(bindir)/nix
|
||||
@cat doc/manual/src/command-ref/conf-file-prefix.md > $@.tmp
|
||||
$(trace-gen) $(nix-eval) 'import doc/manual/generate-options.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
|
||||
$(trace-gen) $(nix-eval) --expr 'import doc/manual/generate-options.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
|
||||
@mv $@.tmp $@
|
||||
|
||||
$(d)/nix.json: $(bindir)/nix
|
||||
|
@ -61,18 +63,28 @@ $(d)/conf-file.json: $(bindir)/nix
|
|||
|
||||
$(d)/src/expressions/builtins.md: $(d)/builtins.json $(d)/generate-builtins.nix $(d)/src/expressions/builtins-prefix.md $(bindir)/nix
|
||||
@cat doc/manual/src/expressions/builtins-prefix.md > $@.tmp
|
||||
$(trace-gen) $(nix-eval) 'import doc/manual/generate-builtins.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
|
||||
$(trace-gen) $(nix-eval) --expr 'import doc/manual/generate-builtins.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
|
||||
@mv $@.tmp $@
|
||||
|
||||
$(d)/builtins.json: $(bindir)/nix
|
||||
$(trace-gen) $(dummy-env) NIX_PATH=nix/corepkgs=corepkgs $(bindir)/nix __dump-builtins > $@.tmp
|
||||
mv $@.tmp $@
|
||||
@mv $@.tmp $@
|
||||
|
||||
# Generate the HTML manual.
|
||||
install: $(docdir)/manual/index.html
|
||||
|
||||
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/custom.css $(d)/src/command-ref/nix.md $(d)/src/command-ref/conf-file.md $(d)/src/expressions/builtins.md
|
||||
$(trace-gen) mdbook build doc/manual -d $(docdir)/manual
|
||||
# Generate 'nix' manpages.
|
||||
install: $(d)/src/command-ref/new-cli
|
||||
$(trace-gen) for i in doc/manual/src/command-ref/new-cli/*.md; do \
|
||||
name=$$(basename $$i .md); \
|
||||
if [[ $$name = SUMMARY ]]; then continue; fi; \
|
||||
printf "Title: %s\n\n" "$$name" > $$i.tmp; \
|
||||
cat $$i >> $$i.tmp; \
|
||||
lowdown -sT man $$i.tmp -o $(mandir)/man1/$$name.1; \
|
||||
done
|
||||
|
||||
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/command-ref/new-cli $(d)/src/command-ref/conf-file.md $(d)/src/expressions/builtins.md
|
||||
$(trace-gen) RUST_LOG=warn mdbook build doc/manual -d $(docdir)/manual
|
||||
@cp doc/manual/highlight.pack.js $(docdir)/manual/highlight.js
|
||||
|
||||
endif
|
||||
|
|
|
@ -62,12 +62,12 @@
|
|||
- [nix-instantiate](command-ref/nix-instantiate.md)
|
||||
- [nix-prefetch-url](command-ref/nix-prefetch-url.md)
|
||||
- [Experimental Commands](command-ref/experimental-commands.md)
|
||||
- [nix](command-ref/nix.md)
|
||||
- [CLI guideline](command-ref/cli-guideline.md)
|
||||
- [Files](command-ref/files.md)
|
||||
- [nix.conf](command-ref/conf-file.md)
|
||||
- [Glossary](glossary.md)
|
||||
- [Hacking](hacking.md)
|
||||
- [Contributing](contributing/contributing.md)
|
||||
- [Hacking](contributing/hacking.md)
|
||||
- [CLI guideline](contributing/cli-guideline.md)
|
||||
- [Release Notes](release-notes/release-notes.md)
|
||||
- [Release 2.3 (2019-09-04)](release-notes/rl-2.3.md)
|
||||
- [Release 2.2 (2019-01-11)](release-notes/rl-2.2.md)
|
|
@ -466,6 +466,8 @@
|
|||
postInstall = ''
|
||||
mkdir -p $doc/nix-support
|
||||
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
|
|
6
local.mk
6
local.mk
|
@ -1,9 +1,3 @@
|
|||
ifeq ($(MAKECMDGOALS), dist)
|
||||
dist-files += $(shell cat .dist-files)
|
||||
endif
|
||||
|
||||
dist-files += configure config.h.in perl/configure
|
||||
|
||||
clean-files += Makefile.config
|
||||
|
||||
GLOBAL_CXXFLAGS += -Wno-deprecated-declarations
|
||||
|
|
17
mk/dist.mk
17
mk/dist.mk
|
@ -1,17 +0,0 @@
|
|||
ifdef PACKAGE_NAME
|
||||
|
||||
dist-name = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
|
||||
|
||||
dist: $(dist-name).tar.bz2 $(dist-name).tar.xz
|
||||
|
||||
$(dist-name).tar.bz2: $(dist-files)
|
||||
$(trace-gen) tar cfj $@ $(sort $(dist-files)) --transform 's,^,$(dist-name)/,'
|
||||
|
||||
$(dist-name).tar.xz: $(dist-files)
|
||||
$(trace-gen) tar cfJ $@ $(sort $(dist-files)) --transform 's,^,$(dist-name)/,'
|
||||
|
||||
clean-files += $(dist-name).tar.bz2 $(dist-name).tar.xz
|
||||
|
||||
print-top-help += echo " dist: Generate a source distribution";
|
||||
|
||||
endif
|
|
@ -10,7 +10,6 @@ bin-scripts :=
|
|||
noinst-scripts :=
|
||||
man-pages :=
|
||||
install-tests :=
|
||||
dist-files :=
|
||||
OS = $(shell uname -s)
|
||||
|
||||
|
||||
|
@ -112,9 +111,6 @@ $(foreach test, $(install-tests), $(eval $(call run-install-test,$(test))))
|
|||
$(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/man$(patsubst .%,%,$(suffix $(file))))))
|
||||
|
||||
|
||||
include mk/dist.mk
|
||||
|
||||
|
||||
.PHONY: default all man help
|
||||
|
||||
all: $(programs-list) $(libs-list) $(jars-list) $(man-pages)
|
||||
|
|
|
@ -159,5 +159,4 @@ define build-library
|
|||
libs-list += $$($(1)_PATH)
|
||||
endif
|
||||
clean-files += $$(_d)/*.a $$(_d)/*.$(SO_EXT) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS)
|
||||
dist-files += $$(_srcs)
|
||||
endef
|
||||
|
|
|
@ -79,7 +79,6 @@ define build-program
|
|||
|
||||
programs-list += $$($(1)_PATH)
|
||||
clean-files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS)
|
||||
dist-files += $$(_srcs)
|
||||
|
||||
# Phony target to run this program (typically as a dependency of 'check').
|
||||
.PHONY: $(1)_RUN
|
||||
|
|
|
@ -30,8 +30,6 @@ ifeq ($(OS), Darwin)
|
|||
install_name_tool -id $@ $@
|
||||
endif
|
||||
|
||||
dist-files += $(d)/vendor
|
||||
|
||||
clean: clean-rust
|
||||
|
||||
clean-rust:
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
|
||||
%{
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
|
||||
#endif
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ $(d)/lexer-tab.cc $(d)/lexer-tab.hh: $(d)/lexer.l
|
|||
|
||||
clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh
|
||||
|
||||
dist-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh
|
||||
|
||||
$(eval $(call install-file-in, $(d)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644))
|
||||
|
||||
$(foreach i, $(wildcard src/libexpr/flake/*.hh), \
|
||||
|
|
|
@ -86,8 +86,7 @@ void BinaryCacheStore::getFile(const std::string & path, Sink & sink)
|
|||
promise.set_exception(std::current_exception());
|
||||
}
|
||||
}});
|
||||
auto data = promise.get_future().get();
|
||||
sink((unsigned char *) data->data(), data->size());
|
||||
sink(*promise.get_future().get());
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> BinaryCacheStore::getFile(const std::string & path)
|
||||
|
|
|
@ -916,10 +916,8 @@ void DerivationGoal::buildDone()
|
|||
|
||||
LogSink(Activity & act) : act(act) { }
|
||||
|
||||
void operator() (const unsigned char * data, size_t len) override {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
auto c = data[i];
|
||||
|
||||
void operator() (std::string_view data) override {
|
||||
for (auto c : data) {
|
||||
if (c == '\n') {
|
||||
flushLine();
|
||||
} else {
|
||||
|
@ -3127,7 +3125,7 @@ void DerivationGoal::registerOutputs()
|
|||
StringSink sink;
|
||||
dumpPath(actualPath, sink);
|
||||
RewritingSink rsink2(oldHashPart, std::string(newInfo0.path.hashPart()), nextSink);
|
||||
rsink2((unsigned char *) sink.s->data(), sink.s->size());
|
||||
rsink2(*sink.s);
|
||||
rsink2.flush();
|
||||
});
|
||||
Path tmpPath = actualPath + ".tmp";
|
||||
|
|
|
@ -223,11 +223,6 @@ void Worker::run(const Goals & _topGoals)
|
|||
uint64_t downloadSize, narSize;
|
||||
store.queryMissing(topPaths, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
|
||||
if (!willBuild.empty() && 0 == settings.maxBuildJobs && getMachines().empty())
|
||||
throw Error(
|
||||
"%d derivations need to be built, but neither local builds ('--max-jobs') "
|
||||
"nor remote builds ('--builders') are enabled", willBuild.size());
|
||||
|
||||
debug("entered goal loop");
|
||||
|
||||
while (1) {
|
||||
|
|
|
@ -153,10 +153,10 @@ struct TunnelSink : Sink
|
|||
{
|
||||
Sink & to;
|
||||
TunnelSink(Sink & to) : to(to) { }
|
||||
virtual void operator () (const unsigned char * data, size_t len)
|
||||
void operator () (std::string_view data)
|
||||
{
|
||||
to << STDERR_WRITE;
|
||||
writeString(data, len, to);
|
||||
writeString(data, to);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -165,7 +165,7 @@ struct TunnelSource : BufferedSource
|
|||
Source & from;
|
||||
BufferedSink & to;
|
||||
TunnelSource(Source & from, BufferedSink & to) : from(from), to(to) { }
|
||||
size_t readUnbuffered(unsigned char * data, size_t len) override
|
||||
size_t readUnbuffered(char * data, size_t len) override
|
||||
{
|
||||
to << STDERR_READ << len;
|
||||
to.flush();
|
||||
|
@ -215,6 +215,8 @@ struct ClientSettings
|
|||
for (auto & s : ss)
|
||||
if (trusted.count(s))
|
||||
subs.push_back(s);
|
||||
else if (!hasSuffix(s, "/") && trusted.count(s + "/"))
|
||||
subs.push_back(s + "/");
|
||||
else
|
||||
warn("ignoring untrusted substituter '%s'", s);
|
||||
res = subs;
|
||||
|
|
|
@ -95,18 +95,18 @@ struct curlFileTransfer : public FileTransfer
|
|||
fmt(request.data ? "uploading '%s'" : "downloading '%s'", request.uri),
|
||||
{request.uri}, request.parentAct)
|
||||
, callback(std::move(callback))
|
||||
, finalSink([this](const unsigned char * data, size_t len) {
|
||||
, finalSink([this](std::string_view data) {
|
||||
if (this->request.dataCallback) {
|
||||
auto httpStatus = getHTTPStatus();
|
||||
|
||||
/* Only write data to the sink if this is a
|
||||
successful response. */
|
||||
if (successfulStatuses.count(httpStatus)) {
|
||||
writtenToSink += len;
|
||||
this->request.dataCallback((char *) data, len);
|
||||
writtenToSink += data.size();
|
||||
this->request.dataCallback(data);
|
||||
}
|
||||
} else
|
||||
this->result.data->append((char *) data, len);
|
||||
this->result.data->append(data);
|
||||
})
|
||||
{
|
||||
if (!request.expectedETag.empty())
|
||||
|
@ -171,8 +171,8 @@ struct curlFileTransfer : public FileTransfer
|
|||
}
|
||||
|
||||
if (errorSink)
|
||||
(*errorSink)((unsigned char *) contents, realSize);
|
||||
(*decompressionSink)((unsigned char *) contents, realSize);
|
||||
(*errorSink)({(char *) contents, realSize});
|
||||
(*decompressionSink)({(char *) contents, realSize});
|
||||
|
||||
return realSize;
|
||||
} catch (...) {
|
||||
|
@ -776,7 +776,7 @@ void FileTransfer::download(FileTransferRequest && request, Sink & sink)
|
|||
state->request.notify_one();
|
||||
});
|
||||
|
||||
request.dataCallback = [_state](char * buf, size_t len) {
|
||||
request.dataCallback = [_state](std::string_view data) {
|
||||
|
||||
auto state(_state->lock());
|
||||
|
||||
|
@ -794,7 +794,7 @@ void FileTransfer::download(FileTransferRequest && request, Sink & sink)
|
|||
|
||||
/* Append data to the buffer and wake up the calling
|
||||
thread. */
|
||||
state->data.append(buf, len);
|
||||
state->data.append(data);
|
||||
state->avail.notify_one();
|
||||
};
|
||||
|
||||
|
@ -840,7 +840,7 @@ void FileTransfer::download(FileTransferRequest && request, Sink & sink)
|
|||
if it's blocked on a full buffer. We don't hold the state
|
||||
lock while doing this to prevent blocking the download
|
||||
thread if sink() takes a long time. */
|
||||
sink((unsigned char *) chunk.data(), chunk.size());
|
||||
sink(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ struct FileTransferRequest
|
|||
bool decompress = true;
|
||||
std::shared_ptr<std::string> data;
|
||||
std::string mimeType;
|
||||
std::function<void(char *, size_t)> dataCallback;
|
||||
std::function<void(std::string_view data)> dataCallback;
|
||||
|
||||
FileTransferRequest(const std::string & uri)
|
||||
: uri(uri), parentAct(getCurActivity()) { }
|
||||
|
|
|
@ -583,7 +583,7 @@ public:
|
|||
|
||||
Setting<Strings> substituters{
|
||||
this,
|
||||
nixStore == "/nix/store" ? Strings{"https://cache.nixos.org/"} : Strings(),
|
||||
Strings{"https://cache.nixos.org/"},
|
||||
"substituters",
|
||||
R"(
|
||||
A list of URLs of substituters, separated by whitespace. The default
|
||||
|
@ -867,7 +867,7 @@ public:
|
|||
Example `~/.config/nix/nix.conf`:
|
||||
|
||||
```
|
||||
access-tokens = "github.com=23ac...b289 gitlab.mycompany.com=PAT:A123Bp_Cd..EfG gitlab.com=OAuth2:1jklw3jk"
|
||||
access-tokens = github.com=23ac...b289 gitlab.mycompany.com=PAT:A123Bp_Cd..EfG gitlab.com=OAuth2:1jklw3jk
|
||||
```
|
||||
|
||||
Example `~/code/flake.nix`:
|
||||
|
|
|
@ -1143,7 +1143,7 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, const string & name,
|
|||
dump.resize(oldSize + want);
|
||||
auto got = 0;
|
||||
try {
|
||||
got = source.read((uint8_t *) dump.data() + oldSize, want);
|
||||
got = source.read(dump.data() + oldSize, want);
|
||||
} catch (EndOfFile &) {
|
||||
inMemory = true;
|
||||
break;
|
||||
|
|
|
@ -87,7 +87,7 @@ struct NarAccessor : public FSAccessor
|
|||
parents.top()->start = pos;
|
||||
}
|
||||
|
||||
void receiveContents(unsigned char * data, size_t len) override
|
||||
void receiveContents(std::string_view data) override
|
||||
{ }
|
||||
|
||||
void createSymlink(const Path & path, const string & target) override
|
||||
|
@ -96,7 +96,7 @@ struct NarAccessor : public FSAccessor
|
|||
NarMember{FSAccessor::Type::tSymlink, false, 0, 0, target});
|
||||
}
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override
|
||||
size_t read(char * data, size_t len) override
|
||||
{
|
||||
auto n = source.read(data, len);
|
||||
pos += n;
|
||||
|
|
|
@ -55,27 +55,23 @@ struct RefScanSink : Sink
|
|||
|
||||
RefScanSink() { }
|
||||
|
||||
void operator () (const unsigned char * data, size_t len);
|
||||
void operator () (std::string_view data) override
|
||||
{
|
||||
/* It's possible that a reference spans the previous and current
|
||||
fragment, so search in the concatenation of the tail of the
|
||||
previous fragment and the start of the current fragment. */
|
||||
string s = tail + std::string(data, 0, refLength);
|
||||
search((const unsigned char *) s.data(), s.size(), hashes, seen);
|
||||
|
||||
search((const unsigned char *) data.data(), data.size(), hashes, seen);
|
||||
|
||||
size_t tailLen = data.size() <= refLength ? data.size() : refLength;
|
||||
tail = std::string(tail, tail.size() < refLength - tailLen ? 0 : tail.size() - (refLength - tailLen));
|
||||
tail.append({data.data() + data.size() - tailLen, tailLen});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void RefScanSink::operator () (const unsigned char * data, size_t len)
|
||||
{
|
||||
/* It's possible that a reference spans the previous and current
|
||||
fragment, so search in the concatenation of the tail of the
|
||||
previous fragment and the start of the current fragment. */
|
||||
string s = tail + string((const char *) data, len > refLength ? refLength : len);
|
||||
search((const unsigned char *) s.data(), s.size(), hashes, seen);
|
||||
|
||||
search(data, len, hashes, seen);
|
||||
|
||||
size_t tailLen = len <= refLength ? len : refLength;
|
||||
tail =
|
||||
string(tail, tail.size() < refLength - tailLen ? 0 : tail.size() - (refLength - tailLen)) +
|
||||
string((const char *) data + len - tailLen, tailLen);
|
||||
}
|
||||
|
||||
|
||||
std::pair<PathSet, HashResult> scanForReferences(const string & path,
|
||||
const PathSet & refs)
|
||||
{
|
||||
|
@ -129,10 +125,10 @@ RewritingSink::RewritingSink(const std::string & from, const std::string & to, S
|
|||
assert(from.size() == to.size());
|
||||
}
|
||||
|
||||
void RewritingSink::operator () (const unsigned char * data, size_t len)
|
||||
void RewritingSink::operator () (std::string_view data)
|
||||
{
|
||||
std::string s(prev);
|
||||
s.append((const char *) data, len);
|
||||
s.append(data);
|
||||
|
||||
size_t j = 0;
|
||||
while ((j = s.find(from, j)) != string::npos) {
|
||||
|
@ -146,14 +142,14 @@ void RewritingSink::operator () (const unsigned char * data, size_t len)
|
|||
|
||||
pos += consumed;
|
||||
|
||||
if (consumed) nextSink((unsigned char *) s.data(), consumed);
|
||||
if (consumed) nextSink(s.substr(0, consumed));
|
||||
}
|
||||
|
||||
void RewritingSink::flush()
|
||||
{
|
||||
if (prev.empty()) return;
|
||||
pos += prev.size();
|
||||
nextSink((unsigned char *) prev.data(), prev.size());
|
||||
nextSink(prev);
|
||||
prev.clear();
|
||||
}
|
||||
|
||||
|
@ -163,9 +159,9 @@ HashModuloSink::HashModuloSink(HashType ht, const std::string & modulus)
|
|||
{
|
||||
}
|
||||
|
||||
void HashModuloSink::operator () (const unsigned char * data, size_t len)
|
||||
void HashModuloSink::operator () (std::string_view data)
|
||||
{
|
||||
rewritingSink(data, len);
|
||||
rewritingSink(data);
|
||||
}
|
||||
|
||||
HashResult HashModuloSink::finish()
|
||||
|
@ -176,10 +172,8 @@ HashResult HashModuloSink::finish()
|
|||
NAR with self-references and a NAR with some of the
|
||||
self-references already zeroed out do not produce a hash
|
||||
collision. FIXME: proof. */
|
||||
for (auto & pos : rewritingSink.matches) {
|
||||
auto s = fmt("|%d", pos);
|
||||
hashSink((unsigned char *) s.data(), s.size());
|
||||
}
|
||||
for (auto & pos : rewritingSink.matches)
|
||||
hashSink(fmt("|%d", pos));
|
||||
|
||||
auto h = hashSink.finish();
|
||||
return {h.first, rewritingSink.pos};
|
||||
|
|
|
@ -19,7 +19,7 @@ struct RewritingSink : Sink
|
|||
|
||||
RewritingSink(const std::string & from, const std::string & to, Sink & nextSink);
|
||||
|
||||
void operator () (const unsigned char * data, size_t len) override;
|
||||
void operator () (std::string_view data) override;
|
||||
|
||||
void flush();
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ struct HashModuloSink : AbstractHashSink
|
|||
|
||||
HashModuloSink(HashType ht, const std::string & modulus);
|
||||
|
||||
void operator () (const unsigned char * data, size_t len) override;
|
||||
void operator () (std::string_view data) override;
|
||||
|
||||
HashResult finish() override;
|
||||
};
|
||||
|
|
|
@ -75,7 +75,7 @@ std::pair<ref<FSAccessor>, Path> RemoteFSAccessor::fetch(const Path & path_)
|
|||
throw SysError("seeking in '%s'", cacheFile);
|
||||
|
||||
std::string buf(length, 0);
|
||||
readFull(fd.get(), (unsigned char *) buf.data(), length);
|
||||
readFull(fd.get(), buf.data(), length);
|
||||
|
||||
return buf;
|
||||
});
|
||||
|
|
|
@ -856,8 +856,8 @@ std::exception_ptr RemoteStore::Connection::processStderr(Sink * sink, Source *
|
|||
else if (msg == STDERR_READ) {
|
||||
if (!source) throw Error("no source");
|
||||
size_t len = readNum<size_t>(from);
|
||||
auto buf = std::make_unique<unsigned char[]>(len);
|
||||
writeString(buf.get(), source->read(buf.get(), len), to);
|
||||
auto buf = std::make_unique<char[]>(len);
|
||||
writeString({(const char *) buf.get(), source->read(buf.get(), len)}, to);
|
||||
to.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,10 @@ class AwsLogger : public Aws::Utils::Logging::FormattedLogSystem
|
|||
{
|
||||
debug("AWS: %s", chomp(statement));
|
||||
}
|
||||
|
||||
#if !(AWS_VERSION_MAJOR <= 1 && AWS_VERSION_MINOR <= 7 && AWS_VERSION_PATCH <= 115)
|
||||
void Flush() override {}
|
||||
#endif
|
||||
};
|
||||
|
||||
static void initAWS()
|
||||
|
@ -398,7 +402,7 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore, virtual S3BinaryCache
|
|||
printTalkative("downloaded 's3://%s/%s' (%d bytes) in %d ms",
|
||||
bucketName, path, res.data->size(), res.durationMs);
|
||||
|
||||
sink((unsigned char *) res.data->data(), res.data->size());
|
||||
sink(*res.data);
|
||||
} else
|
||||
throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache '%s'", path, getUri());
|
||||
}
|
||||
|
|
|
@ -772,8 +772,8 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
|
|||
}
|
||||
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
LambdaSink progressSink([&](const unsigned char * data, size_t len) {
|
||||
total += len;
|
||||
LambdaSink progressSink([&](std::string_view data) {
|
||||
total += data.size();
|
||||
act.progress(total, info->narSize);
|
||||
});
|
||||
TeeSink tee { sink, progressSink };
|
||||
|
|
|
@ -50,14 +50,14 @@ static void dumpContents(const Path & path, size_t size,
|
|||
AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
|
||||
if (!fd) throw SysError("opening file '%1%'", path);
|
||||
|
||||
std::vector<unsigned char> buf(65536);
|
||||
std::vector<char> buf(65536);
|
||||
size_t left = size;
|
||||
|
||||
while (left > 0) {
|
||||
auto n = std::min(left, buf.size());
|
||||
readFull(fd.get(), buf.data(), n);
|
||||
left -= n;
|
||||
sink(buf.data(), n);
|
||||
sink({buf.data(), n});
|
||||
}
|
||||
|
||||
writePadding(size, sink);
|
||||
|
@ -155,14 +155,14 @@ static void parseContents(ParseSink & sink, Source & source, const Path & path)
|
|||
sink.preallocateContents(size);
|
||||
|
||||
uint64_t left = size;
|
||||
std::vector<unsigned char> buf(65536);
|
||||
std::vector<char> buf(65536);
|
||||
|
||||
while (left) {
|
||||
checkInterrupt();
|
||||
auto n = buf.size();
|
||||
if ((uint64_t)n > left) n = left;
|
||||
source(buf.data(), n);
|
||||
sink.receiveContents(buf.data(), n);
|
||||
sink.receiveContents({buf.data(), n});
|
||||
left -= n;
|
||||
}
|
||||
|
||||
|
@ -300,21 +300,21 @@ struct RestoreSink : ParseSink
|
|||
Path dstPath;
|
||||
AutoCloseFD fd;
|
||||
|
||||
void createDirectory(const Path & path)
|
||||
void createDirectory(const Path & path) override
|
||||
{
|
||||
Path p = dstPath + path;
|
||||
if (mkdir(p.c_str(), 0777) == -1)
|
||||
throw SysError("creating directory '%1%'", p);
|
||||
};
|
||||
|
||||
void createRegularFile(const Path & path)
|
||||
void createRegularFile(const Path & path) override
|
||||
{
|
||||
Path p = dstPath + path;
|
||||
fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666);
|
||||
if (!fd) throw SysError("creating file '%1%'", p);
|
||||
}
|
||||
|
||||
void isExecutable()
|
||||
void isExecutable() override
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat(fd.get(), &st) == -1)
|
||||
|
@ -323,7 +323,7 @@ struct RestoreSink : ParseSink
|
|||
throw SysError("fchmod");
|
||||
}
|
||||
|
||||
void preallocateContents(uint64_t len)
|
||||
void preallocateContents(uint64_t len) override
|
||||
{
|
||||
if (!archiveSettings.preallocateContents)
|
||||
return;
|
||||
|
@ -341,12 +341,12 @@ struct RestoreSink : ParseSink
|
|||
#endif
|
||||
}
|
||||
|
||||
void receiveContents(unsigned char * data, size_t len)
|
||||
void receiveContents(std::string_view data) override
|
||||
{
|
||||
writeFull(fd.get(), data, len);
|
||||
writeFull(fd.get(), data);
|
||||
}
|
||||
|
||||
void createSymlink(const Path & path, const string & target)
|
||||
void createSymlink(const Path & path, const string & target) override
|
||||
{
|
||||
Path p = dstPath + path;
|
||||
nix::createSymlink(target, p);
|
||||
|
|
|
@ -58,7 +58,7 @@ struct ParseSink
|
|||
virtual void createRegularFile(const Path & path) { };
|
||||
virtual void isExecutable() { };
|
||||
virtual void preallocateContents(uint64_t size) { };
|
||||
virtual void receiveContents(unsigned char * data, size_t len) { };
|
||||
virtual void receiveContents(std::string_view data) { };
|
||||
|
||||
virtual void createSymlink(const Path & path, const string & target) { };
|
||||
};
|
||||
|
@ -72,17 +72,17 @@ struct RetrieveRegularNARSink : ParseSink
|
|||
|
||||
RetrieveRegularNARSink(Sink & sink) : sink(sink) { }
|
||||
|
||||
void createDirectory(const Path & path)
|
||||
void createDirectory(const Path & path) override
|
||||
{
|
||||
regular = false;
|
||||
}
|
||||
|
||||
void receiveContents(unsigned char * data, size_t len)
|
||||
void receiveContents(std::string_view data) override
|
||||
{
|
||||
sink(data, len);
|
||||
sink(data);
|
||||
}
|
||||
|
||||
void createSymlink(const Path & path, const string & target)
|
||||
void createSymlink(const Path & path, const string & target) override
|
||||
{
|
||||
regular = false;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ void Args::parseCmdline(const Strings & _cmdline)
|
|||
throw UsageError("unrecognised flag '%1%'", arg);
|
||||
}
|
||||
else {
|
||||
pos = rewriteArgs(cmdline, pos);
|
||||
pendingArgs.push_back(*pos++);
|
||||
if (processArgs(pendingArgs, false))
|
||||
pendingArgs.clear();
|
||||
|
@ -390,10 +391,6 @@ MultiCommand::MultiCommand(const Commands & commands)
|
|||
.optional = true,
|
||||
.handler = {[=](std::string s) {
|
||||
assert(!command);
|
||||
if (auto alias = get(deprecatedAliases, s)) {
|
||||
warn("'%s' is a deprecated alias for '%s'", s, *alias);
|
||||
s = *alias;
|
||||
}
|
||||
if (auto prefix = needsCompletion(s)) {
|
||||
for (auto & [name, command] : commands)
|
||||
if (hasPrefix(name, *prefix))
|
||||
|
|
|
@ -115,6 +115,9 @@ protected:
|
|||
|
||||
virtual bool processArgs(const Strings & args, bool finish);
|
||||
|
||||
virtual Strings::iterator rewriteArgs(Strings & args, Strings::iterator pos)
|
||||
{ return pos; }
|
||||
|
||||
std::set<std::string> hiddenCategories;
|
||||
|
||||
public:
|
||||
|
@ -257,8 +260,6 @@ public:
|
|||
|
||||
std::map<Command::Category, std::string> categories;
|
||||
|
||||
std::map<std::string, std::string> deprecatedAliases;
|
||||
|
||||
// Selected command, if any.
|
||||
std::optional<std::pair<std::string, ref<Command>>> command;
|
||||
|
||||
|
|
|
@ -22,18 +22,17 @@ struct ChunkedCompressionSink : CompressionSink
|
|||
{
|
||||
uint8_t outbuf[32 * 1024];
|
||||
|
||||
void write(const unsigned char * data, size_t len) override
|
||||
void write(std::string_view data) override
|
||||
{
|
||||
const size_t CHUNK_SIZE = sizeof(outbuf) << 2;
|
||||
while (len) {
|
||||
size_t n = std::min(CHUNK_SIZE, len);
|
||||
writeInternal(data, n);
|
||||
data += n;
|
||||
len -= n;
|
||||
while (!data.empty()) {
|
||||
size_t n = std::min(CHUNK_SIZE, data.size());
|
||||
writeInternal(data);
|
||||
data.remove_prefix(n);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void writeInternal(const unsigned char * data, size_t len) = 0;
|
||||
virtual void writeInternal(std::string_view data) = 0;
|
||||
};
|
||||
|
||||
struct NoneSink : CompressionSink
|
||||
|
@ -41,7 +40,7 @@ struct NoneSink : CompressionSink
|
|||
Sink & nextSink;
|
||||
NoneSink(Sink & nextSink) : nextSink(nextSink) { }
|
||||
void finish() override { flush(); }
|
||||
void write(const unsigned char * data, size_t len) override { nextSink(data, len); }
|
||||
void write(std::string_view data) override { nextSink(data); }
|
||||
};
|
||||
|
||||
struct GzipDecompressionSink : CompressionSink
|
||||
|
@ -75,28 +74,28 @@ struct GzipDecompressionSink : CompressionSink
|
|||
void finish() override
|
||||
{
|
||||
CompressionSink::flush();
|
||||
write(nullptr, 0);
|
||||
write({});
|
||||
}
|
||||
|
||||
void write(const unsigned char * data, size_t len) override
|
||||
void write(std::string_view data) override
|
||||
{
|
||||
assert(len <= std::numeric_limits<decltype(strm.avail_in)>::max());
|
||||
assert(data.size() <= std::numeric_limits<decltype(strm.avail_in)>::max());
|
||||
|
||||
strm.next_in = (Bytef *) data;
|
||||
strm.avail_in = len;
|
||||
strm.next_in = (Bytef *) data.data();
|
||||
strm.avail_in = data.size();
|
||||
|
||||
while (!finished && (!data || strm.avail_in)) {
|
||||
while (!finished && (!data.data() || strm.avail_in)) {
|
||||
checkInterrupt();
|
||||
|
||||
int ret = inflate(&strm,Z_SYNC_FLUSH);
|
||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||
throw CompressionError("error while decompressing gzip file: %d (%d, %d)",
|
||||
zError(ret), len, strm.avail_in);
|
||||
zError(ret), data.size(), strm.avail_in);
|
||||
|
||||
finished = ret == Z_STREAM_END;
|
||||
|
||||
if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - strm.avail_out);
|
||||
nextSink({(char *) outbuf, sizeof(outbuf) - strm.avail_out});
|
||||
strm.next_out = (Bytef *) outbuf;
|
||||
strm.avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
@ -130,25 +129,25 @@ struct XzDecompressionSink : CompressionSink
|
|||
void finish() override
|
||||
{
|
||||
CompressionSink::flush();
|
||||
write(nullptr, 0);
|
||||
write({});
|
||||
}
|
||||
|
||||
void write(const unsigned char * data, size_t len) override
|
||||
void write(std::string_view data) override
|
||||
{
|
||||
strm.next_in = data;
|
||||
strm.avail_in = len;
|
||||
strm.next_in = (const unsigned char *) data.data();
|
||||
strm.avail_in = data.size();
|
||||
|
||||
while (!finished && (!data || strm.avail_in)) {
|
||||
while (!finished && (!data.data() || strm.avail_in)) {
|
||||
checkInterrupt();
|
||||
|
||||
lzma_ret ret = lzma_code(&strm, data ? LZMA_RUN : LZMA_FINISH);
|
||||
lzma_ret ret = lzma_code(&strm, data.data() ? LZMA_RUN : LZMA_FINISH);
|
||||
if (ret != LZMA_OK && ret != LZMA_STREAM_END)
|
||||
throw CompressionError("error %d while decompressing xz file", ret);
|
||||
|
||||
finished = ret == LZMA_STREAM_END;
|
||||
|
||||
if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - strm.avail_out);
|
||||
nextSink({(char *) outbuf, sizeof(outbuf) - strm.avail_out});
|
||||
strm.next_out = outbuf;
|
||||
strm.avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
@ -181,15 +180,15 @@ struct BzipDecompressionSink : ChunkedCompressionSink
|
|||
void finish() override
|
||||
{
|
||||
flush();
|
||||
write(nullptr, 0);
|
||||
write({});
|
||||
}
|
||||
|
||||
void writeInternal(const unsigned char * data, size_t len) override
|
||||
void writeInternal(std::string_view data) override
|
||||
{
|
||||
assert(len <= std::numeric_limits<decltype(strm.avail_in)>::max());
|
||||
assert(data.size() <= std::numeric_limits<decltype(strm.avail_in)>::max());
|
||||
|
||||
strm.next_in = (char *) data;
|
||||
strm.avail_in = len;
|
||||
strm.next_in = (char *) data.data();
|
||||
strm.avail_in = data.size();
|
||||
|
||||
while (strm.avail_in) {
|
||||
checkInterrupt();
|
||||
|
@ -201,7 +200,7 @@ struct BzipDecompressionSink : ChunkedCompressionSink
|
|||
finished = ret == BZ_STREAM_END;
|
||||
|
||||
if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - strm.avail_out);
|
||||
nextSink({(char *) outbuf, sizeof(outbuf) - strm.avail_out});
|
||||
strm.next_out = (char *) outbuf;
|
||||
strm.avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
@ -230,17 +229,17 @@ struct BrotliDecompressionSink : ChunkedCompressionSink
|
|||
void finish() override
|
||||
{
|
||||
flush();
|
||||
writeInternal(nullptr, 0);
|
||||
writeInternal({});
|
||||
}
|
||||
|
||||
void writeInternal(const unsigned char * data, size_t len) override
|
||||
void writeInternal(std::string_view data) override
|
||||
{
|
||||
const uint8_t * next_in = data;
|
||||
size_t avail_in = len;
|
||||
auto next_in = (const uint8_t *) data.data();
|
||||
size_t avail_in = data.size();
|
||||
uint8_t * next_out = outbuf;
|
||||
size_t avail_out = sizeof(outbuf);
|
||||
|
||||
while (!finished && (!data || avail_in)) {
|
||||
while (!finished && (!data.data() || avail_in)) {
|
||||
checkInterrupt();
|
||||
|
||||
if (!BrotliDecoderDecompressStream(state,
|
||||
|
@ -250,7 +249,7 @@ struct BrotliDecompressionSink : ChunkedCompressionSink
|
|||
throw CompressionError("error while decompressing brotli file");
|
||||
|
||||
if (avail_out < sizeof(outbuf) || avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - avail_out);
|
||||
nextSink({(char *) outbuf, sizeof(outbuf) - avail_out});
|
||||
next_out = outbuf;
|
||||
avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
@ -338,25 +337,25 @@ struct XzCompressionSink : CompressionSink
|
|||
void finish() override
|
||||
{
|
||||
CompressionSink::flush();
|
||||
write(nullptr, 0);
|
||||
write({});
|
||||
}
|
||||
|
||||
void write(const unsigned char * data, size_t len) override
|
||||
void write(std::string_view data) override
|
||||
{
|
||||
strm.next_in = data;
|
||||
strm.avail_in = len;
|
||||
strm.next_in = (const unsigned char *) data.data();
|
||||
strm.avail_in = data.size();
|
||||
|
||||
while (!finished && (!data || strm.avail_in)) {
|
||||
while (!finished && (!data.data() || strm.avail_in)) {
|
||||
checkInterrupt();
|
||||
|
||||
lzma_ret ret = lzma_code(&strm, data ? LZMA_RUN : LZMA_FINISH);
|
||||
lzma_ret ret = lzma_code(&strm, data.data() ? LZMA_RUN : LZMA_FINISH);
|
||||
if (ret != LZMA_OK && ret != LZMA_STREAM_END)
|
||||
throw CompressionError("error %d while compressing xz file", ret);
|
||||
|
||||
finished = ret == LZMA_STREAM_END;
|
||||
|
||||
if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - strm.avail_out);
|
||||
nextSink({(const char *) outbuf, sizeof(outbuf) - strm.avail_out});
|
||||
strm.next_out = outbuf;
|
||||
strm.avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
@ -389,27 +388,27 @@ struct BzipCompressionSink : ChunkedCompressionSink
|
|||
void finish() override
|
||||
{
|
||||
flush();
|
||||
writeInternal(nullptr, 0);
|
||||
writeInternal({});
|
||||
}
|
||||
|
||||
void writeInternal(const unsigned char * data, size_t len) override
|
||||
void writeInternal(std::string_view data) override
|
||||
{
|
||||
assert(len <= std::numeric_limits<decltype(strm.avail_in)>::max());
|
||||
assert(data.size() <= std::numeric_limits<decltype(strm.avail_in)>::max());
|
||||
|
||||
strm.next_in = (char *) data;
|
||||
strm.avail_in = len;
|
||||
strm.next_in = (char *) data.data();
|
||||
strm.avail_in = data.size();
|
||||
|
||||
while (!finished && (!data || strm.avail_in)) {
|
||||
while (!finished && (!data.data() || strm.avail_in)) {
|
||||
checkInterrupt();
|
||||
|
||||
int ret = BZ2_bzCompress(&strm, data ? BZ_RUN : BZ_FINISH);
|
||||
int ret = BZ2_bzCompress(&strm, data.data() ? BZ_RUN : BZ_FINISH);
|
||||
if (ret != BZ_RUN_OK && ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
|
||||
throw CompressionError("error %d while compressing bzip2 file", ret);
|
||||
|
||||
finished = ret == BZ_STREAM_END;
|
||||
|
||||
if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - strm.avail_out);
|
||||
nextSink({(const char *) outbuf, sizeof(outbuf) - strm.avail_out});
|
||||
strm.next_out = (char *) outbuf;
|
||||
strm.avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
@ -439,28 +438,28 @@ struct BrotliCompressionSink : ChunkedCompressionSink
|
|||
void finish() override
|
||||
{
|
||||
flush();
|
||||
writeInternal(nullptr, 0);
|
||||
writeInternal({});
|
||||
}
|
||||
|
||||
void writeInternal(const unsigned char * data, size_t len) override
|
||||
void writeInternal(std::string_view data) override
|
||||
{
|
||||
const uint8_t * next_in = data;
|
||||
size_t avail_in = len;
|
||||
auto next_in = (const uint8_t *) data.data();
|
||||
size_t avail_in = data.size();
|
||||
uint8_t * next_out = outbuf;
|
||||
size_t avail_out = sizeof(outbuf);
|
||||
|
||||
while (!finished && (!data || avail_in)) {
|
||||
while (!finished && (!data.data() || avail_in)) {
|
||||
checkInterrupt();
|
||||
|
||||
if (!BrotliEncoderCompressStream(state,
|
||||
data ? BROTLI_OPERATION_PROCESS : BROTLI_OPERATION_FINISH,
|
||||
data.data() ? BROTLI_OPERATION_PROCESS : BROTLI_OPERATION_FINISH,
|
||||
&avail_in, &next_in,
|
||||
&avail_out, &next_out,
|
||||
nullptr))
|
||||
throw CompressionError("error while compressing brotli compression");
|
||||
|
||||
if (avail_out < sizeof(outbuf) || avail_in == 0) {
|
||||
nextSink(outbuf, sizeof(outbuf) - avail_out);
|
||||
nextSink({(const char *) outbuf, sizeof(outbuf) - avail_out});
|
||||
next_out = outbuf;
|
||||
avail_out = sizeof(outbuf);
|
||||
}
|
||||
|
|
|
@ -291,12 +291,12 @@ static void start(HashType ht, Ctx & ctx)
|
|||
|
||||
|
||||
static void update(HashType ht, Ctx & ctx,
|
||||
const unsigned char * bytes, size_t len)
|
||||
std::string_view data)
|
||||
{
|
||||
if (ht == htMD5) MD5_Update(&ctx.md5, bytes, len);
|
||||
else if (ht == htSHA1) SHA1_Update(&ctx.sha1, bytes, len);
|
||||
else if (ht == htSHA256) SHA256_Update(&ctx.sha256, bytes, len);
|
||||
else if (ht == htSHA512) SHA512_Update(&ctx.sha512, bytes, len);
|
||||
if (ht == htMD5) MD5_Update(&ctx.md5, data.data(), data.size());
|
||||
else if (ht == htSHA1) SHA1_Update(&ctx.sha1, data.data(), data.size());
|
||||
else if (ht == htSHA256) SHA256_Update(&ctx.sha256, data.data(), data.size());
|
||||
else if (ht == htSHA512) SHA512_Update(&ctx.sha512, data.data(), data.size());
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@ Hash hashString(HashType ht, std::string_view s)
|
|||
Ctx ctx;
|
||||
Hash hash(ht);
|
||||
start(ht, ctx);
|
||||
update(ht, ctx, (const unsigned char *) s.data(), s.length());
|
||||
update(ht, ctx, s);
|
||||
finish(ht, ctx, hash.hash);
|
||||
return hash;
|
||||
}
|
||||
|
@ -341,10 +341,10 @@ HashSink::~HashSink()
|
|||
delete ctx;
|
||||
}
|
||||
|
||||
void HashSink::write(const unsigned char * data, size_t len)
|
||||
void HashSink::write(std::string_view data)
|
||||
{
|
||||
bytes += len;
|
||||
update(ht, *ctx, data, len);
|
||||
bytes += data.size();
|
||||
update(ht, *ctx, data);
|
||||
}
|
||||
|
||||
HashResult HashSink::finish()
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
HashSink(HashType ht);
|
||||
HashSink(const HashSink & h);
|
||||
~HashSink();
|
||||
void write(const unsigned char * data, size_t len) override;
|
||||
void write(std::string_view data) override;
|
||||
HashResult finish() override;
|
||||
HashResult currentHash();
|
||||
};
|
||||
|
|
|
@ -11,23 +11,23 @@
|
|||
namespace nix {
|
||||
|
||||
|
||||
void BufferedSink::operator () (const unsigned char * data, size_t len)
|
||||
void BufferedSink::operator () (std::string_view data)
|
||||
{
|
||||
if (!buffer) buffer = decltype(buffer)(new unsigned char[bufSize]);
|
||||
if (!buffer) buffer = decltype(buffer)(new char[bufSize]);
|
||||
|
||||
while (len) {
|
||||
while (!data.empty()) {
|
||||
/* Optimisation: bypass the buffer if the data exceeds the
|
||||
buffer size. */
|
||||
if (bufPos + len >= bufSize) {
|
||||
if (bufPos + data.size() >= bufSize) {
|
||||
flush();
|
||||
write(data, len);
|
||||
write(data);
|
||||
break;
|
||||
}
|
||||
/* Otherwise, copy the bytes to the buffer. Flush the buffer
|
||||
when it's full. */
|
||||
size_t n = bufPos + len > bufSize ? bufSize - bufPos : len;
|
||||
memcpy(buffer.get() + bufPos, data, n);
|
||||
data += n; bufPos += n; len -= n;
|
||||
size_t n = bufPos + data.size() > bufSize ? bufSize - bufPos : data.size();
|
||||
memcpy(buffer.get() + bufPos, data.data(), n);
|
||||
data.remove_prefix(n); bufPos += n;
|
||||
if (bufPos == bufSize) flush();
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ void BufferedSink::flush()
|
|||
if (bufPos == 0) return;
|
||||
size_t n = bufPos;
|
||||
bufPos = 0; // don't trigger the assert() in ~BufferedSink()
|
||||
write(buffer.get(), n);
|
||||
write({buffer.get(), n});
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,9 +59,9 @@ static void warnLargeDump()
|
|||
}
|
||||
|
||||
|
||||
void FdSink::write(const unsigned char * data, size_t len)
|
||||
void FdSink::write(std::string_view data)
|
||||
{
|
||||
written += len;
|
||||
written += data.size();
|
||||
static bool warned = false;
|
||||
if (warn && !warned) {
|
||||
if (written > threshold) {
|
||||
|
@ -70,7 +70,7 @@ void FdSink::write(const unsigned char * data, size_t len)
|
|||
}
|
||||
}
|
||||
try {
|
||||
writeFull(fd, data, len);
|
||||
writeFull(fd, data);
|
||||
} catch (SysError & e) {
|
||||
_good = false;
|
||||
throw;
|
||||
|
@ -84,7 +84,7 @@ bool FdSink::good()
|
|||
}
|
||||
|
||||
|
||||
void Source::operator () (unsigned char * data, size_t len)
|
||||
void Source::operator () (char * data, size_t len)
|
||||
{
|
||||
while (len) {
|
||||
size_t n = read(data, len);
|
||||
|
@ -96,12 +96,12 @@ void Source::operator () (unsigned char * data, size_t len)
|
|||
void Source::drainInto(Sink & sink)
|
||||
{
|
||||
std::string s;
|
||||
std::vector<unsigned char> buf(8192);
|
||||
std::vector<char> buf(8192);
|
||||
while (true) {
|
||||
size_t n;
|
||||
try {
|
||||
n = read(buf.data(), buf.size());
|
||||
sink(buf.data(), n);
|
||||
sink({buf.data(), n});
|
||||
} catch (EndOfFile &) {
|
||||
break;
|
||||
}
|
||||
|
@ -117,9 +117,9 @@ std::string Source::drain()
|
|||
}
|
||||
|
||||
|
||||
size_t BufferedSource::read(unsigned char * data, size_t len)
|
||||
size_t BufferedSource::read(char * data, size_t len)
|
||||
{
|
||||
if (!buffer) buffer = decltype(buffer)(new unsigned char[bufSize]);
|
||||
if (!buffer) buffer = decltype(buffer)(new char[bufSize]);
|
||||
|
||||
if (!bufPosIn) bufPosIn = readUnbuffered(buffer.get(), bufSize);
|
||||
|
||||
|
@ -138,12 +138,12 @@ bool BufferedSource::hasData()
|
|||
}
|
||||
|
||||
|
||||
size_t FdSource::readUnbuffered(unsigned char * data, size_t len)
|
||||
size_t FdSource::readUnbuffered(char * data, size_t len)
|
||||
{
|
||||
ssize_t n;
|
||||
do {
|
||||
checkInterrupt();
|
||||
n = ::read(fd, (char *) data, len);
|
||||
n = ::read(fd, data, len);
|
||||
} while (n == -1 && errno == EINTR);
|
||||
if (n == -1) { _good = false; throw SysError("reading from file"); }
|
||||
if (n == 0) { _good = false; throw EndOfFile("unexpected end-of-file"); }
|
||||
|
@ -158,10 +158,10 @@ bool FdSource::good()
|
|||
}
|
||||
|
||||
|
||||
size_t StringSource::read(unsigned char * data, size_t len)
|
||||
size_t StringSource::read(char * data, size_t len)
|
||||
{
|
||||
if (pos == s.size()) throw EndOfFile("end of string reached");
|
||||
size_t n = s.copy((char *) data, len, pos);
|
||||
size_t n = s.copy(data, len, pos);
|
||||
pos += n;
|
||||
return n;
|
||||
}
|
||||
|
@ -225,13 +225,13 @@ std::unique_ptr<Source> sinkToSource(
|
|||
std::string cur;
|
||||
size_t pos = 0;
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override
|
||||
size_t read(char * data, size_t len) override
|
||||
{
|
||||
if (!coro)
|
||||
coro = coro_t::pull_type(VirtualStackAllocator{}, [&](coro_t::push_type & yield) {
|
||||
LambdaSink sink([&](const unsigned char * data, size_t len) {
|
||||
if (len) yield(std::string((const char *) data, len));
|
||||
});
|
||||
LambdaSink sink([&](std::string_view data) {
|
||||
if (!data.empty()) yield(std::string(data));
|
||||
});
|
||||
fun(sink);
|
||||
});
|
||||
|
||||
|
@ -244,7 +244,7 @@ std::unique_ptr<Source> sinkToSource(
|
|||
}
|
||||
|
||||
auto n = std::min(cur.size() - pos, len);
|
||||
memcpy(data, (unsigned char *) cur.data() + pos, n);
|
||||
memcpy(data, cur.data() + pos, n);
|
||||
pos += n;
|
||||
|
||||
return n;
|
||||
|
@ -258,24 +258,24 @@ std::unique_ptr<Source> sinkToSource(
|
|||
void writePadding(size_t len, Sink & sink)
|
||||
{
|
||||
if (len % 8) {
|
||||
unsigned char zero[8];
|
||||
char zero[8];
|
||||
memset(zero, 0, sizeof(zero));
|
||||
sink(zero, 8 - (len % 8));
|
||||
sink({zero, 8 - (len % 8)});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeString(const unsigned char * buf, size_t len, Sink & sink)
|
||||
void writeString(std::string_view data, Sink & sink)
|
||||
{
|
||||
sink << len;
|
||||
sink(buf, len);
|
||||
writePadding(len, sink);
|
||||
sink << data.size();
|
||||
sink(data);
|
||||
writePadding(data.size(), sink);
|
||||
}
|
||||
|
||||
|
||||
Sink & operator << (Sink & sink, const string & s)
|
||||
{
|
||||
writeString((const unsigned char *) s.data(), s.size(), sink);
|
||||
writeString(s, sink);
|
||||
return sink;
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ Sink & operator << (Sink & sink, const Error & ex)
|
|||
void readPadding(size_t len, Source & source)
|
||||
{
|
||||
if (len % 8) {
|
||||
unsigned char zero[8];
|
||||
char zero[8];
|
||||
size_t n = 8 - (len % 8);
|
||||
source(zero, n);
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
|
@ -330,7 +330,7 @@ void readPadding(size_t len, Source & source)
|
|||
}
|
||||
|
||||
|
||||
size_t readString(unsigned char * buf, size_t max, Source & source)
|
||||
size_t readString(char * buf, size_t max, Source & source)
|
||||
{
|
||||
auto len = readNum<size_t>(source);
|
||||
if (len > max) throw SerialisationError("string is too long");
|
||||
|
@ -345,7 +345,7 @@ string readString(Source & source, size_t max)
|
|||
auto len = readNum<size_t>(source);
|
||||
if (len > max) throw SerialisationError("string is too long");
|
||||
std::string res(len, 0);
|
||||
source((unsigned char*) res.data(), len);
|
||||
source(res.data(), len);
|
||||
readPadding(len, source);
|
||||
return res;
|
||||
}
|
||||
|
@ -394,17 +394,17 @@ Error readError(Source & source)
|
|||
}
|
||||
|
||||
|
||||
void StringSink::operator () (const unsigned char * data, size_t len)
|
||||
void StringSink::operator () (std::string_view data)
|
||||
{
|
||||
static bool warned = false;
|
||||
if (!warned && s->size() > threshold) {
|
||||
warnLargeDump();
|
||||
warned = true;
|
||||
}
|
||||
s->append((const char *) data, len);
|
||||
s->append(data);
|
||||
}
|
||||
|
||||
size_t ChainSource::read(unsigned char * data, size_t len)
|
||||
size_t ChainSource::read(char * data, size_t len)
|
||||
{
|
||||
if (useSecond) {
|
||||
return source2.read(data, len);
|
||||
|
|
|
@ -14,19 +14,14 @@ namespace nix {
|
|||
struct Sink
|
||||
{
|
||||
virtual ~Sink() { }
|
||||
virtual void operator () (const unsigned char * data, size_t len) = 0;
|
||||
virtual void operator () (std::string_view data) = 0;
|
||||
virtual bool good() { return true; }
|
||||
|
||||
void operator () (const std::string & s)
|
||||
{
|
||||
(*this)((const unsigned char *) s.data(), s.size());
|
||||
}
|
||||
};
|
||||
|
||||
/* Just throws away data. */
|
||||
struct NullSink : Sink
|
||||
{
|
||||
void operator () (const unsigned char * data, size_t len) override
|
||||
void operator () (std::string_view data) override
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -35,21 +30,16 @@ struct NullSink : Sink
|
|||
struct BufferedSink : virtual Sink
|
||||
{
|
||||
size_t bufSize, bufPos;
|
||||
std::unique_ptr<unsigned char[]> buffer;
|
||||
std::unique_ptr<char[]> buffer;
|
||||
|
||||
BufferedSink(size_t bufSize = 32 * 1024)
|
||||
: bufSize(bufSize), bufPos(0), buffer(nullptr) { }
|
||||
|
||||
void operator () (const unsigned char * data, size_t len) override;
|
||||
|
||||
void operator () (const std::string & s)
|
||||
{
|
||||
Sink::operator()(s);
|
||||
}
|
||||
void operator () (std::string_view data) override;
|
||||
|
||||
void flush();
|
||||
|
||||
virtual void write(const unsigned char * data, size_t len) = 0;
|
||||
virtual void write(std::string_view data) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,12 +51,12 @@ struct Source
|
|||
/* Store exactly ‘len’ bytes in the buffer pointed to by ‘data’.
|
||||
It blocks until all the requested data is available, or throws
|
||||
an error if it is not going to be available. */
|
||||
void operator () (unsigned char * data, size_t len);
|
||||
void operator () (char * data, size_t len);
|
||||
|
||||
/* Store up to ‘len’ in the buffer pointed to by ‘data’, and
|
||||
return the number of bytes stored. It blocks until at least
|
||||
one byte is available. */
|
||||
virtual size_t read(unsigned char * data, size_t len) = 0;
|
||||
virtual size_t read(char * data, size_t len) = 0;
|
||||
|
||||
virtual bool good() { return true; }
|
||||
|
||||
|
@ -81,18 +71,18 @@ struct Source
|
|||
struct BufferedSource : Source
|
||||
{
|
||||
size_t bufSize, bufPosIn, bufPosOut;
|
||||
std::unique_ptr<unsigned char[]> buffer;
|
||||
std::unique_ptr<char[]> buffer;
|
||||
|
||||
BufferedSource(size_t bufSize = 32 * 1024)
|
||||
: bufSize(bufSize), bufPosIn(0), bufPosOut(0), buffer(nullptr) { }
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override;
|
||||
size_t read(char * data, size_t len) override;
|
||||
|
||||
bool hasData();
|
||||
|
||||
protected:
|
||||
/* Underlying read call, to be overridden. */
|
||||
virtual size_t readUnbuffered(unsigned char * data, size_t len) = 0;
|
||||
virtual size_t readUnbuffered(char * data, size_t len) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -119,7 +109,7 @@ struct FdSink : BufferedSink
|
|||
|
||||
~FdSink();
|
||||
|
||||
void write(const unsigned char * data, size_t len) override;
|
||||
void write(std::string_view data) override;
|
||||
|
||||
bool good() override;
|
||||
|
||||
|
@ -148,7 +138,7 @@ struct FdSource : BufferedSource
|
|||
|
||||
bool good() override;
|
||||
protected:
|
||||
size_t readUnbuffered(unsigned char * data, size_t len) override;
|
||||
size_t readUnbuffered(char * data, size_t len) override;
|
||||
private:
|
||||
bool _good = true;
|
||||
};
|
||||
|
@ -163,7 +153,7 @@ struct StringSink : Sink
|
|||
s->reserve(reservedSize);
|
||||
};
|
||||
StringSink(ref<std::string> s) : s(s) { };
|
||||
void operator () (const unsigned char * data, size_t len) override;
|
||||
void operator () (std::string_view data) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -173,7 +163,7 @@ struct StringSource : Source
|
|||
const string & s;
|
||||
size_t pos;
|
||||
StringSource(const string & _s) : s(_s), pos(0) { }
|
||||
size_t read(unsigned char * data, size_t len) override;
|
||||
size_t read(char * data, size_t len) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -182,10 +172,10 @@ struct TeeSink : Sink
|
|||
{
|
||||
Sink & sink1, & sink2;
|
||||
TeeSink(Sink & sink1, Sink & sink2) : sink1(sink1), sink2(sink2) { }
|
||||
virtual void operator () (const unsigned char * data, size_t len)
|
||||
virtual void operator () (std::string_view data)
|
||||
{
|
||||
sink1(data, len);
|
||||
sink2(data, len);
|
||||
sink1(data);
|
||||
sink2(data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -197,10 +187,10 @@ struct TeeSource : Source
|
|||
Sink & sink;
|
||||
TeeSource(Source & orig, Sink & sink)
|
||||
: orig(orig), sink(sink) { }
|
||||
size_t read(unsigned char * data, size_t len)
|
||||
size_t read(char * data, size_t len)
|
||||
{
|
||||
size_t n = orig.read(data, len);
|
||||
sink(data, n);
|
||||
sink({data, n});
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
@ -212,7 +202,7 @@ struct SizedSource : Source
|
|||
size_t remain;
|
||||
SizedSource(Source & orig, size_t size)
|
||||
: orig(orig), remain(size) { }
|
||||
size_t read(unsigned char * data, size_t len)
|
||||
size_t read(char * data, size_t len)
|
||||
{
|
||||
if (this->remain <= 0) {
|
||||
throw EndOfFile("sized: unexpected end-of-file");
|
||||
|
@ -226,7 +216,7 @@ struct SizedSource : Source
|
|||
/* Consume the original source until no remain data is left to consume. */
|
||||
size_t drainAll()
|
||||
{
|
||||
std::vector<unsigned char> buf(8192);
|
||||
std::vector<char> buf(8192);
|
||||
size_t sum = 0;
|
||||
while (this->remain > 0) {
|
||||
size_t n = read(buf.data(), buf.size());
|
||||
|
@ -241,24 +231,24 @@ struct LengthSink : Sink
|
|||
{
|
||||
uint64_t length = 0;
|
||||
|
||||
virtual void operator () (const unsigned char * _, size_t len)
|
||||
void operator () (std::string_view data) override
|
||||
{
|
||||
length += len;
|
||||
length += data.size();
|
||||
}
|
||||
};
|
||||
|
||||
/* Convert a function into a sink. */
|
||||
struct LambdaSink : Sink
|
||||
{
|
||||
typedef std::function<void(const unsigned char *, size_t)> lambda_t;
|
||||
typedef std::function<void(std::string_view data)> lambda_t;
|
||||
|
||||
lambda_t lambda;
|
||||
|
||||
LambdaSink(const lambda_t & lambda) : lambda(lambda) { }
|
||||
|
||||
virtual void operator () (const unsigned char * data, size_t len)
|
||||
void operator () (std::string_view data) override
|
||||
{
|
||||
lambda(data, len);
|
||||
lambda(data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -266,13 +256,13 @@ struct LambdaSink : Sink
|
|||
/* Convert a function into a source. */
|
||||
struct LambdaSource : Source
|
||||
{
|
||||
typedef std::function<size_t(unsigned char *, size_t)> lambda_t;
|
||||
typedef std::function<size_t(char *, size_t)> lambda_t;
|
||||
|
||||
lambda_t lambda;
|
||||
|
||||
LambdaSource(const lambda_t & lambda) : lambda(lambda) { }
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override
|
||||
size_t read(char * data, size_t len) override
|
||||
{
|
||||
return lambda(data, len);
|
||||
}
|
||||
|
@ -288,7 +278,7 @@ struct ChainSource : Source
|
|||
: source1(s1), source2(s2)
|
||||
{ }
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override;
|
||||
size_t read(char * data, size_t len) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -302,7 +292,7 @@ std::unique_ptr<Source> sinkToSource(
|
|||
|
||||
|
||||
void writePadding(size_t len, Sink & sink);
|
||||
void writeString(const unsigned char * buf, size_t len, Sink & sink);
|
||||
void writeString(std::string_view s, Sink & sink);
|
||||
|
||||
inline Sink & operator << (Sink & sink, uint64_t n)
|
||||
{
|
||||
|
@ -315,7 +305,7 @@ inline Sink & operator << (Sink & sink, uint64_t n)
|
|||
buf[5] = (n >> 40) & 0xff;
|
||||
buf[6] = (n >> 48) & 0xff;
|
||||
buf[7] = (unsigned char) (n >> 56) & 0xff;
|
||||
sink(buf, sizeof(buf));
|
||||
sink({(char *) buf, sizeof(buf)});
|
||||
return sink;
|
||||
}
|
||||
|
||||
|
@ -332,7 +322,7 @@ template<typename T>
|
|||
T readNum(Source & source)
|
||||
{
|
||||
unsigned char buf[8];
|
||||
source(buf, sizeof(buf));
|
||||
source((char *) buf, sizeof(buf));
|
||||
|
||||
uint64_t n =
|
||||
((uint64_t) buf[0]) |
|
||||
|
@ -364,7 +354,7 @@ inline uint64_t readLongLong(Source & source)
|
|||
|
||||
|
||||
void readPadding(size_t len, Source & source);
|
||||
size_t readString(unsigned char * buf, size_t max, Source & source);
|
||||
size_t readString(char * buf, size_t max, Source & source);
|
||||
string readString(Source & source, size_t max = std::numeric_limits<size_t>::max());
|
||||
template<class T> T readStrings(Source & source);
|
||||
|
||||
|
@ -396,9 +386,9 @@ struct StreamToSourceAdapter : Source
|
|||
: istream(istream)
|
||||
{ }
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override
|
||||
size_t read(char * data, size_t len) override
|
||||
{
|
||||
if (!istream->read((char *) data, len)) {
|
||||
if (!istream->read(data, len)) {
|
||||
if (istream->eof()) {
|
||||
if (istream->gcount() == 0)
|
||||
throw EndOfFile("end of file");
|
||||
|
@ -421,7 +411,7 @@ struct FramedSource : Source
|
|||
{
|
||||
Source & from;
|
||||
bool eof = false;
|
||||
std::vector<unsigned char> pending;
|
||||
std::vector<char> pending;
|
||||
size_t pos = 0;
|
||||
|
||||
FramedSource(Source & from) : from(from)
|
||||
|
@ -433,13 +423,13 @@ struct FramedSource : Source
|
|||
while (true) {
|
||||
auto n = readInt(from);
|
||||
if (!n) break;
|
||||
std::vector<unsigned char> data(n);
|
||||
std::vector<char> data(n);
|
||||
from(data.data(), n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t read(unsigned char * data, size_t len) override
|
||||
size_t read(char * data, size_t len) override
|
||||
{
|
||||
if (eof) throw EndOfFile("reached end of FramedSource");
|
||||
|
||||
|
@ -449,7 +439,7 @@ struct FramedSource : Source
|
|||
eof = true;
|
||||
return 0;
|
||||
}
|
||||
pending = std::vector<unsigned char>(len);
|
||||
pending = std::vector<char>(len);
|
||||
pos = 0;
|
||||
from(pending.data(), len);
|
||||
}
|
||||
|
@ -484,7 +474,7 @@ struct FramedSink : nix::BufferedSink
|
|||
}
|
||||
}
|
||||
|
||||
void write(const unsigned char * data, size_t len) override
|
||||
void write(std::string_view data) override
|
||||
{
|
||||
/* Don't send more data if the remote has
|
||||
encountered an error. */
|
||||
|
@ -493,8 +483,8 @@ struct FramedSink : nix::BufferedSink
|
|||
ex = nullptr;
|
||||
std::rethrow_exception(ex2);
|
||||
}
|
||||
to << len;
|
||||
to(data, len);
|
||||
to << data.size();
|
||||
to(data);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
*buffer = self->buffer.data();
|
||||
|
||||
try {
|
||||
return self->source->read(self->buffer.data(), 4096);
|
||||
return self->source->read((char *) self->buffer.data(), 4096);
|
||||
} catch (EndOfFile &) {
|
||||
return 0;
|
||||
} catch (std::exception & err) {
|
||||
|
|
|
@ -320,7 +320,7 @@ void readFile(const Path & path, Sink & sink)
|
|||
}
|
||||
|
||||
|
||||
void writeFile(const Path & path, const string & s, mode_t mode)
|
||||
void writeFile(const Path & path, std::string_view s, mode_t mode)
|
||||
{
|
||||
AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, mode);
|
||||
if (!fd)
|
||||
|
@ -340,13 +340,13 @@ void writeFile(const Path & path, Source & source, mode_t mode)
|
|||
if (!fd)
|
||||
throw SysError("opening file '%1%'", path);
|
||||
|
||||
std::vector<unsigned char> buf(64 * 1024);
|
||||
std::vector<char> buf(64 * 1024);
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
try {
|
||||
auto n = source.read(buf.data(), buf.size());
|
||||
writeFull(fd.get(), (unsigned char *) buf.data(), n);
|
||||
writeFull(fd.get(), {buf.data(), n});
|
||||
} catch (EndOfFile &) { break; }
|
||||
}
|
||||
} catch (Error & e) {
|
||||
|
@ -632,11 +632,11 @@ void replaceSymlink(const Path & target, const Path & link,
|
|||
}
|
||||
|
||||
|
||||
void readFull(int fd, unsigned char * buf, size_t count)
|
||||
void readFull(int fd, char * buf, size_t count)
|
||||
{
|
||||
while (count) {
|
||||
checkInterrupt();
|
||||
ssize_t res = read(fd, (char *) buf, count);
|
||||
ssize_t res = read(fd, buf, count);
|
||||
if (res == -1) {
|
||||
if (errno == EINTR) continue;
|
||||
throw SysError("reading from file");
|
||||
|
@ -648,27 +648,19 @@ void readFull(int fd, unsigned char * buf, size_t count)
|
|||
}
|
||||
|
||||
|
||||
void writeFull(int fd, const unsigned char * buf, size_t count, bool allowInterrupts)
|
||||
void writeFull(int fd, std::string_view s, bool allowInterrupts)
|
||||
{
|
||||
while (count) {
|
||||
while (!s.empty()) {
|
||||
if (allowInterrupts) checkInterrupt();
|
||||
ssize_t res = write(fd, (char *) buf, count);
|
||||
ssize_t res = write(fd, s.data(), s.size());
|
||||
if (res == -1 && errno != EINTR)
|
||||
throw SysError("writing to file");
|
||||
if (res > 0) {
|
||||
count -= res;
|
||||
buf += res;
|
||||
}
|
||||
if (res > 0)
|
||||
s.remove_prefix(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeFull(int fd, const string & s, bool allowInterrupts)
|
||||
{
|
||||
writeFull(fd, (const unsigned char *) s.data(), s.size(), allowInterrupts);
|
||||
}
|
||||
|
||||
|
||||
string drainFD(int fd, bool block, const size_t reserveSize)
|
||||
{
|
||||
StringSink sink(reserveSize);
|
||||
|
@ -705,7 +697,7 @@ void drainFD(int fd, Sink & sink, bool block)
|
|||
throw SysError("reading from file");
|
||||
}
|
||||
else if (rd == 0) break;
|
||||
else sink(buf.data(), rd);
|
||||
else sink({(char *) buf.data(), (size_t) rd});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1145,7 +1137,7 @@ void runProgram2(const RunOptions & options)
|
|||
in.readSide = -1;
|
||||
writerThread = std::thread([&]() {
|
||||
try {
|
||||
std::vector<unsigned char> buf(8 * 1024);
|
||||
std::vector<char> buf(8 * 1024);
|
||||
while (true) {
|
||||
size_t n;
|
||||
try {
|
||||
|
@ -1153,7 +1145,7 @@ void runProgram2(const RunOptions & options)
|
|||
} catch (EndOfFile &) {
|
||||
break;
|
||||
}
|
||||
writeFull(in.writeSide.get(), buf.data(), n);
|
||||
writeFull(in.writeSide.get(), {buf.data(), n});
|
||||
}
|
||||
promise.set_value();
|
||||
} catch (...) {
|
||||
|
|
|
@ -106,7 +106,7 @@ string readFile(const Path & path);
|
|||
void readFile(const Path & path, Sink & sink);
|
||||
|
||||
/* Write a string to a file. */
|
||||
void writeFile(const Path & path, const string & s, mode_t mode = 0666);
|
||||
void writeFile(const Path & path, std::string_view s, mode_t mode = 0666);
|
||||
|
||||
void writeFile(const Path & path, Source & source, mode_t mode = 0666);
|
||||
|
||||
|
@ -155,9 +155,8 @@ void replaceSymlink(const Path & target, const Path & link,
|
|||
|
||||
/* Wrappers arount read()/write() that read/write exactly the
|
||||
requested number of bytes. */
|
||||
void readFull(int fd, unsigned char * buf, size_t count);
|
||||
void writeFull(int fd, const unsigned char * buf, size_t count, bool allowInterrupts = true);
|
||||
void writeFull(int fd, const string & s, bool allowInterrupts = true);
|
||||
void readFull(int fd, char * buf, size_t count);
|
||||
void writeFull(int fd, std::string_view s, bool allowInterrupts = true);
|
||||
|
||||
MakeError(EndOfFile, Error);
|
||||
|
||||
|
|
28
src/nix/add-file.md
Normal file
28
src/nix/add-file.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
R""(
|
||||
|
||||
# Description
|
||||
|
||||
Copy the regular file *path* to the Nix store, and print the resulting
|
||||
store path on standard output.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The resulting store path is not registered as a garbage
|
||||
> collector root, so it could be deleted before you have a
|
||||
> chance to register it.
|
||||
|
||||
# Examples
|
||||
|
||||
Add a regular file to the store:
|
||||
|
||||
```console
|
||||
# echo foo > bar
|
||||
|
||||
# nix store add-file ./bar
|
||||
/nix/store/cbv2s4bsvzjri77s2gb8g8bpcb6dpa8w-bar
|
||||
|
||||
# cat /nix/store/cbv2s4bsvzjri77s2gb8g8bpcb6dpa8w-bar
|
||||
foo
|
||||
```
|
||||
|
||||
)""
|
29
src/nix/add-path.md
Normal file
29
src/nix/add-path.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
R""(
|
||||
|
||||
# Description
|
||||
|
||||
Copy *path* to the Nix store, and print the resulting store path on
|
||||
standard output.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The resulting store path is not registered as a garbage
|
||||
> collector root, so it could be deleted before you have a
|
||||
> chance to register it.
|
||||
|
||||
# Examples
|
||||
|
||||
Add a directory to the store:
|
||||
|
||||
```console
|
||||
# mkdir dir
|
||||
# echo foo > dir/bar
|
||||
|
||||
# nix store add-path ./dir
|
||||
/nix/store/6pmjx56pm94n66n4qw1nff0y1crm8nqg-dir
|
||||
|
||||
# cat /nix/store/6pmjx56pm94n66n4qw1nff0y1crm8nqg-dir/bar
|
||||
foo
|
||||
```
|
||||
|
||||
)""
|
|
@ -9,10 +9,11 @@ struct CmdAddToStore : MixDryRun, StoreCommand
|
|||
{
|
||||
Path path;
|
||||
std::optional<std::string> namePart;
|
||||
FileIngestionMethod ingestionMethod = FileIngestionMethod::Recursive;
|
||||
FileIngestionMethod ingestionMethod;
|
||||
|
||||
CmdAddToStore()
|
||||
{
|
||||
// FIXME: completion
|
||||
expectArg("path", &path);
|
||||
|
||||
addFlag({
|
||||
|
@ -22,36 +23,8 @@ struct CmdAddToStore : MixDryRun, StoreCommand
|
|||
.labels = {"name"},
|
||||
.handler = {&namePart},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "flat",
|
||||
.shortName = 0,
|
||||
.description = "add flat file to the Nix store",
|
||||
.handler = {&ingestionMethod, FileIngestionMethod::Flat},
|
||||
});
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "add a path to the Nix store";
|
||||
}
|
||||
|
||||
std::string doc() override
|
||||
{
|
||||
return R"(
|
||||
Copy the file or directory *path* to the Nix store, and
|
||||
print the resulting store path on standard output.
|
||||
)";
|
||||
}
|
||||
|
||||
Examples examples() override
|
||||
{
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
if (!namePart) namePart = baseNameOf(path);
|
||||
|
@ -87,4 +60,45 @@ struct CmdAddToStore : MixDryRun, StoreCommand
|
|||
}
|
||||
};
|
||||
|
||||
static auto rCmdAddToStore = registerCommand<CmdAddToStore>("add-to-store");
|
||||
struct CmdAddFile : CmdAddToStore
|
||||
{
|
||||
CmdAddFile()
|
||||
{
|
||||
ingestionMethod = FileIngestionMethod::Flat;
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "add a regular file to the Nix store";
|
||||
}
|
||||
|
||||
std::string doc() override
|
||||
{
|
||||
return
|
||||
#include "add-file.md"
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
struct CmdAddPath : CmdAddToStore
|
||||
{
|
||||
CmdAddPath()
|
||||
{
|
||||
ingestionMethod = FileIngestionMethod::Recursive;
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "add a path to the Nix store";
|
||||
}
|
||||
|
||||
std::string doc() override
|
||||
{
|
||||
return
|
||||
#include "add-path.md"
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdAddFile = registerCommand2<CmdAddFile>({"store", "add-file"});
|
||||
static auto rCmdAddPath = registerCommand2<CmdAddPath>({"store", "add-path"});
|
||||
|
|
|
@ -37,8 +37,6 @@ struct CmdCatStore : StoreCommand, MixCat
|
|||
return "print the contents of a file in the Nix store on stdout";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
cat(store->getFSAccessor());
|
||||
|
@ -64,13 +62,11 @@ struct CmdCatNar : StoreCommand, MixCat
|
|||
return "print the contents of a file inside a NAR file on stdout";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
cat(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdCatStore = registerCommand<CmdCatStore>("cat-store");
|
||||
static auto rCmdCatNar = registerCommand<CmdCatNar>("cat-nar");
|
||||
static auto rCmdCatStore = registerCommand2<CmdCatStore>({"store", "cat"});
|
||||
static auto rCmdCatNar = registerCommand2<CmdCatNar>({"nar", "cat"});
|
||||
|
|
|
@ -11,7 +11,21 @@ extern char * * environ __attribute__((weak));
|
|||
|
||||
namespace nix {
|
||||
|
||||
Commands * RegisterCommand::commands = nullptr;
|
||||
RegisterCommand::Commands * RegisterCommand::commands = nullptr;
|
||||
|
||||
nix::Commands RegisterCommand::getCommandsFor(const std::vector<std::string> & prefix)
|
||||
{
|
||||
nix::Commands res;
|
||||
for (auto & [name, command] : *RegisterCommand::commands)
|
||||
if (name.size() == prefix.size() + 1) {
|
||||
bool equal = true;
|
||||
for (size_t i = 0; i < prefix.size(); ++i)
|
||||
if (name[i] != prefix[i]) equal = false;
|
||||
if (equal)
|
||||
res.insert_or_assign(name[prefix.size()], command);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void NixMultiCommand::printHelp(const string & programName, std::ostream & out)
|
||||
{
|
||||
|
|
|
@ -176,20 +176,29 @@ struct StorePathCommand : public InstallablesCommand
|
|||
/* A helper class for registering commands globally. */
|
||||
struct RegisterCommand
|
||||
{
|
||||
typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
|
||||
static Commands * commands;
|
||||
|
||||
RegisterCommand(const std::string & name,
|
||||
RegisterCommand(std::vector<std::string> && name,
|
||||
std::function<ref<Command>()> command)
|
||||
{
|
||||
if (!commands) commands = new Commands;
|
||||
commands->emplace(name, command);
|
||||
}
|
||||
|
||||
static nix::Commands getCommandsFor(const std::vector<std::string> & prefix);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static RegisterCommand registerCommand(const std::string & name)
|
||||
{
|
||||
return RegisterCommand(name, [](){ return make_ref<T>(); });
|
||||
return RegisterCommand({name}, [](){ return make_ref<T>(); });
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
||||
{
|
||||
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
||||
}
|
||||
|
||||
Buildables build(ref<Store> store, Realise mode,
|
||||
|
|
|
@ -121,14 +121,12 @@ struct CmdDiffClosures : SourceExprCommand
|
|||
return "show what packages and versions were added and removed between two closures";
|
||||
}
|
||||
|
||||
Category category() override { return catSecondary; }
|
||||
|
||||
Examples examples() override
|
||||
{
|
||||
return {
|
||||
{
|
||||
"To show what got added and removed between two versions of the NixOS system profile:",
|
||||
"nix diff-closures /nix/var/nix/profiles/system-655-link /nix/var/nix/profiles/system-658-link",
|
||||
"nix store diff-closures /nix/var/nix/profiles/system-655-link /nix/var/nix/profiles/system-658-link",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -143,4 +141,4 @@ struct CmdDiffClosures : SourceExprCommand
|
|||
}
|
||||
};
|
||||
|
||||
static auto rCmdDiffClosures = registerCommand<CmdDiffClosures>("diff-closures");
|
||||
static auto rCmdDiffClosures = registerCommand2<CmdDiffClosures>({"store", "diff-closures"});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "command.hh"
|
||||
#include "store-api.hh"
|
||||
#include "archive.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
|
@ -7,7 +8,7 @@ struct CmdDumpPath : StorePathCommand
|
|||
{
|
||||
std::string description() override
|
||||
{
|
||||
return "dump a store path to stdout (in NAR format)";
|
||||
return "serialise a store path to stdout in NAR format";
|
||||
}
|
||||
|
||||
Examples examples() override
|
||||
|
@ -15,13 +16,11 @@ struct CmdDumpPath : StorePathCommand
|
|||
return {
|
||||
Example{
|
||||
"To get a NAR from the binary cache https://cache.nixos.org/:",
|
||||
"nix dump-path --store https://cache.nixos.org/ /nix/store/7crrmih8c52r8fbnqb933dxrsp44md93-glibc-2.25"
|
||||
"nix store dump-path --store https://cache.nixos.org/ /nix/store/7crrmih8c52r8fbnqb933dxrsp44md93-glibc-2.25"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store, const StorePath & storePath) override
|
||||
{
|
||||
FdSink sink(STDOUT_FILENO);
|
||||
|
@ -30,4 +29,42 @@ struct CmdDumpPath : StorePathCommand
|
|||
}
|
||||
};
|
||||
|
||||
static auto rDumpPath = registerCommand<CmdDumpPath>("dump-path");
|
||||
static auto rDumpPath = registerCommand2<CmdDumpPath>({"store", "dump-path"});
|
||||
|
||||
struct CmdDumpPath2 : Command
|
||||
{
|
||||
Path path;
|
||||
|
||||
CmdDumpPath2()
|
||||
{
|
||||
expectArgs({
|
||||
.label = "path",
|
||||
.handler = {&path},
|
||||
.completer = completePath
|
||||
});
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "serialise a path to stdout in NAR format";
|
||||
}
|
||||
|
||||
Examples examples() override
|
||||
{
|
||||
return {
|
||||
Example{
|
||||
"To serialise directory 'foo' as a NAR:",
|
||||
"nix nar dump-path ./foo"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
void run() override
|
||||
{
|
||||
FdSink sink(STDOUT_FILENO);
|
||||
dumpPath(path, sink);
|
||||
sink.flush();
|
||||
}
|
||||
};
|
||||
|
||||
static auto rDumpPath2 = registerCommand2<CmdDumpPath2>({"nar", "dump-path"});
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "shared.hh"
|
||||
#include "store-api.hh"
|
||||
#include "eval.hh"
|
||||
#include "eval-inline.hh"
|
||||
#include "json.hh"
|
||||
#include "value-to-json.hh"
|
||||
#include "progress-bar.hh"
|
||||
|
@ -13,6 +14,7 @@ struct CmdEval : MixJSON, InstallableCommand
|
|||
{
|
||||
bool raw = false;
|
||||
std::optional<std::string> apply;
|
||||
std::optional<Path> writeTo;
|
||||
|
||||
CmdEval()
|
||||
{
|
||||
|
@ -24,6 +26,13 @@ struct CmdEval : MixJSON, InstallableCommand
|
|||
.labels = {"expr"},
|
||||
.handler = {&apply},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "write-to",
|
||||
.description = "write a string or attrset of strings to 'path'",
|
||||
.labels = {"path"},
|
||||
.handler = {&writeTo},
|
||||
});
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
|
@ -66,7 +75,7 @@ struct CmdEval : MixJSON, InstallableCommand
|
|||
|
||||
auto state = getEvalState();
|
||||
|
||||
auto v = installable->toValue(*state).first;
|
||||
auto [v, pos] = installable->toValue(*state);
|
||||
PathSet context;
|
||||
|
||||
if (apply) {
|
||||
|
@ -77,13 +86,51 @@ struct CmdEval : MixJSON, InstallableCommand
|
|||
v = vRes;
|
||||
}
|
||||
|
||||
if (raw) {
|
||||
if (writeTo) {
|
||||
stopProgressBar();
|
||||
|
||||
if (pathExists(*writeTo))
|
||||
throw Error("path '%s' already exists", *writeTo);
|
||||
|
||||
std::function<void(Value & v, const Pos & pos, const Path & path)> recurse;
|
||||
|
||||
recurse = [&](Value & v, const Pos & pos, const Path & path)
|
||||
{
|
||||
state->forceValue(v);
|
||||
if (v.type == tString)
|
||||
// FIXME: disallow strings with contexts?
|
||||
writeFile(path, v.string.s);
|
||||
else if (v.type == tAttrs) {
|
||||
if (mkdir(path.c_str(), 0777) == -1)
|
||||
throw SysError("creating directory '%s'", path);
|
||||
for (auto & attr : *v.attrs)
|
||||
try {
|
||||
if (attr.name == "." || attr.name == "..")
|
||||
throw Error("invalid file name '%s'", attr.name);
|
||||
recurse(*attr.value, *attr.pos, path + "/" + std::string(attr.name));
|
||||
} catch (Error & e) {
|
||||
e.addTrace(*attr.pos, hintfmt("while evaluating the attribute '%s'", attr.name));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw TypeError("value at '%s' is not a string or an attribute set", pos);
|
||||
};
|
||||
|
||||
recurse(*v, pos, *writeTo);
|
||||
}
|
||||
|
||||
else if (raw) {
|
||||
stopProgressBar();
|
||||
std::cout << state->coerceToString(noPos, *v, context);
|
||||
} else if (json) {
|
||||
}
|
||||
|
||||
else if (json) {
|
||||
JSONPlaceholder jsonOut(std::cout);
|
||||
printValueAsJSON(*state, true, *v, jsonOut, context);
|
||||
} else {
|
||||
}
|
||||
|
||||
else {
|
||||
state->forceValueDeep(*v);
|
||||
logger->cout("%s", *v);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdHash : Command
|
||||
struct CmdHashBase : Command
|
||||
{
|
||||
FileIngestionMethod mode;
|
||||
Base base = SRI;
|
||||
|
@ -17,7 +17,7 @@ struct CmdHash : Command
|
|||
std::vector<std::string> paths;
|
||||
std::optional<std::string> modulus;
|
||||
|
||||
CmdHash(FileIngestionMethod mode) : mode(mode)
|
||||
CmdHashBase(FileIngestionMethod mode) : mode(mode)
|
||||
{
|
||||
mkFlag(0, "sri", "print hash in SRI format", &base, SRI);
|
||||
mkFlag(0, "base64", "print hash in base-64", &base, Base64);
|
||||
|
@ -51,8 +51,6 @@ struct CmdHash : Command
|
|||
return d;
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run() override
|
||||
{
|
||||
for (auto path : paths) {
|
||||
|
@ -79,9 +77,6 @@ struct CmdHash : Command
|
|||
}
|
||||
};
|
||||
|
||||
static RegisterCommand rCmdHashFile("hash-file", [](){ return make_ref<CmdHash>(FileIngestionMethod::Flat); });
|
||||
static RegisterCommand rCmdHashPath("hash-path", [](){ return make_ref<CmdHash>(FileIngestionMethod::Recursive); });
|
||||
|
||||
struct CmdToBase : Command
|
||||
{
|
||||
Base base;
|
||||
|
@ -103,8 +98,6 @@ struct CmdToBase : Command
|
|||
"SRI");
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run() override
|
||||
{
|
||||
for (auto s : args)
|
||||
|
@ -112,10 +105,41 @@ struct CmdToBase : Command
|
|||
}
|
||||
};
|
||||
|
||||
static RegisterCommand rCmdToBase16("to-base16", [](){ return make_ref<CmdToBase>(Base16); });
|
||||
static RegisterCommand rCmdToBase32("to-base32", [](){ return make_ref<CmdToBase>(Base32); });
|
||||
static RegisterCommand rCmdToBase64("to-base64", [](){ return make_ref<CmdToBase>(Base64); });
|
||||
static RegisterCommand rCmdToSRI("to-sri", [](){ return make_ref<CmdToBase>(SRI); });
|
||||
struct CmdHash : NixMultiCommand
|
||||
{
|
||||
CmdHash()
|
||||
: MultiCommand({
|
||||
{"file", []() { return make_ref<CmdHashBase>(FileIngestionMethod::Flat);; }},
|
||||
{"path", []() { return make_ref<CmdHashBase>(FileIngestionMethod::Recursive); }},
|
||||
{"to-base16", []() { return make_ref<CmdToBase>(Base16); }},
|
||||
{"to-base32", []() { return make_ref<CmdToBase>(Base32); }},
|
||||
{"to-base64", []() { return make_ref<CmdToBase>(Base64); }},
|
||||
{"to-sri", []() { return make_ref<CmdToBase>(SRI); }},
|
||||
})
|
||||
{ }
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "compute and convert cryptographic hashes";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run() override
|
||||
{
|
||||
if (!command)
|
||||
throw UsageError("'nix hash' requires a sub-command.");
|
||||
command->second->prepare();
|
||||
command->second->run();
|
||||
}
|
||||
|
||||
void printHelp(const string & programName, std::ostream & out) override
|
||||
{
|
||||
MultiCommand::printHelp(programName, out);
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdHash = registerCommand<CmdHash>("hash");
|
||||
|
||||
/* Legacy nix-hash command. */
|
||||
static int compatNixHash(int argc, char * * argv)
|
||||
|
@ -149,7 +173,7 @@ static int compatNixHash(int argc, char * * argv)
|
|||
});
|
||||
|
||||
if (op == opHash) {
|
||||
CmdHash cmd(flat ? FileIngestionMethod::Flat : FileIngestionMethod::Recursive);
|
||||
CmdHashBase cmd(flat ? FileIngestionMethod::Flat : FileIngestionMethod::Recursive);
|
||||
cmd.ht = ht;
|
||||
cmd.base = base32 ? Base32 : Base16;
|
||||
cmd.truncate = truncate;
|
||||
|
|
|
@ -97,7 +97,7 @@ struct CmdLsStore : StoreCommand, MixLs
|
|||
return {
|
||||
Example{
|
||||
"To list the contents of a store path in a binary cache:",
|
||||
"nix ls-store --store https://cache.nixos.org/ -lR /nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10"
|
||||
"nix store ls --store https://cache.nixos.org/ -lR /nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -107,8 +107,6 @@ struct CmdLsStore : StoreCommand, MixLs
|
|||
return "show information about a path in the Nix store";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
list(store->getFSAccessor());
|
||||
|
@ -134,7 +132,7 @@ struct CmdLsNar : Command, MixLs
|
|||
return {
|
||||
Example{
|
||||
"To list a specific file in a NAR:",
|
||||
"nix ls-nar -l hello.nar /bin/hello"
|
||||
"nix nar ls -l hello.nar /bin/hello"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -144,13 +142,11 @@ struct CmdLsNar : Command, MixLs
|
|||
return "show information about a path inside a NAR file";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run() override
|
||||
{
|
||||
list(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdLsStore = registerCommand<CmdLsStore>("ls-store");
|
||||
static auto rCmdLsNar = registerCommand<CmdLsNar>("ls-nar");
|
||||
static auto rCmdLsStore = registerCommand2<CmdLsStore>({"store", "ls"});
|
||||
static auto rCmdLsNar = registerCommand2<CmdLsNar>({"nar", "ls"});
|
||||
|
|
|
@ -59,7 +59,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
|||
bool useNet = true;
|
||||
bool refresh = false;
|
||||
|
||||
NixArgs() : MultiCommand(*RegisterCommand::commands), MixCommonArgs("nix")
|
||||
NixArgs() : MultiCommand(RegisterCommand::getCommandsFor({})), MixCommonArgs("nix")
|
||||
{
|
||||
categories.clear();
|
||||
categories[Command::catDefault] = "Main commands";
|
||||
|
@ -112,8 +112,45 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
|||
.description = "consider all previously downloaded files out-of-date",
|
||||
.handler = {[&]() { refresh = true; }},
|
||||
});
|
||||
}
|
||||
|
||||
deprecatedAliases.insert({"dev-shell", "develop"});
|
||||
std::map<std::string, std::vector<std::string>> aliases = {
|
||||
{"add-to-store", {"store", "add-path"}},
|
||||
{"cat-nar", {"nar", "cat"}},
|
||||
{"cat-store", {"store", "cat"}},
|
||||
{"copy-sigs", {"store", "copy-sigs"}},
|
||||
{"dev-shell", {"develop"}},
|
||||
{"diff-closures", {"store", "diff-closures"}},
|
||||
{"dump-path", {"store", "dump-path"}},
|
||||
{"hash-file", {"hash", "file"}},
|
||||
{"hash-path", {"hash", "path"}},
|
||||
{"ls-nar", {"nar", "ls"}},
|
||||
{"ls-store", {"store", "ls"}},
|
||||
{"make-content-addressable", {"store", "make-content-addressable"}},
|
||||
{"optimise-store", {"store", "optimise"}},
|
||||
{"ping-store", {"store", "ping"}},
|
||||
{"sign-paths", {"store", "sign-paths"}},
|
||||
{"to-base16", {"hash", "to-base16"}},
|
||||
{"to-base32", {"hash", "to-base32"}},
|
||||
{"to-base64", {"hash", "to-base64"}},
|
||||
{"verify", {"store", "verify"}},
|
||||
};
|
||||
|
||||
bool aliasUsed = false;
|
||||
|
||||
Strings::iterator rewriteArgs(Strings & args, Strings::iterator pos) override
|
||||
{
|
||||
if (aliasUsed || command || pos == args.end()) return pos;
|
||||
auto arg = *pos;
|
||||
auto i = aliases.find(arg);
|
||||
if (i == aliases.end()) return pos;
|
||||
warn("'%s' is a deprecated alias for '%s'",
|
||||
arg, concatStringsSep(" ", i->second));
|
||||
pos = args.erase(pos);
|
||||
for (auto j = i->second.rbegin(); j != i->second.rend(); ++j)
|
||||
pos = args.insert(pos, *j);
|
||||
aliasUsed = true;
|
||||
return pos;
|
||||
}
|
||||
|
||||
void printFlags(std::ostream & out) override
|
||||
|
@ -149,6 +186,50 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
|||
}
|
||||
};
|
||||
|
||||
static void showHelp(std::vector<std::string> subcommand)
|
||||
{
|
||||
showManPage(subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand)));
|
||||
}
|
||||
|
||||
struct CmdHelp : Command
|
||||
{
|
||||
std::vector<std::string> subcommand;
|
||||
|
||||
CmdHelp()
|
||||
{
|
||||
expectArgs({
|
||||
.label = "subcommand",
|
||||
.handler = {&subcommand},
|
||||
});
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "show help about 'nix' or a particular subcommand";
|
||||
}
|
||||
|
||||
Examples examples() override
|
||||
{
|
||||
return {
|
||||
Example{
|
||||
"To show help about 'nix' in general:",
|
||||
"nix help"
|
||||
},
|
||||
Example{
|
||||
"To show help about a particular subcommand:",
|
||||
"nix help run"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
void run() override
|
||||
{
|
||||
showHelp(subcommand);
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdHelp = registerCommand<CmdHelp>("help");
|
||||
|
||||
void mainWrapped(int argc, char * * argv)
|
||||
{
|
||||
/* The chroot helper needs to be run before any threads have been
|
||||
|
|
|
@ -23,17 +23,15 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
|
|||
return {
|
||||
Example{
|
||||
"To create a content-addressable representation of GNU Hello (but not its dependencies):",
|
||||
"nix make-content-addressable nixpkgs#hello"
|
||||
"nix store make-content-addressable nixpkgs#hello"
|
||||
},
|
||||
Example{
|
||||
"To compute a content-addressable representation of the current NixOS system closure:",
|
||||
"nix make-content-addressable -r /run/current-system"
|
||||
"nix store make-content-addressable -r /run/current-system"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store, StorePaths storePaths) override
|
||||
{
|
||||
auto paths = store->topoSortPaths(StorePathSet(storePaths.begin(), storePaths.end()));
|
||||
|
@ -73,7 +71,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
|
|||
*sink.s = rewriteStrings(*sink.s, rewrites);
|
||||
|
||||
HashModuloSink hashModuloSink(htSHA256, oldHashPart);
|
||||
hashModuloSink((unsigned char *) sink.s->data(), sink.s->size());
|
||||
hashModuloSink(*sink.s);
|
||||
|
||||
auto narHash = hashModuloSink.finish().first;
|
||||
|
||||
|
@ -94,7 +92,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
|
|||
|
||||
auto source = sinkToSource([&](Sink & nextSink) {
|
||||
RewritingSink rsink2(oldHashPart, std::string(info.path.hashPart()), nextSink);
|
||||
rsink2((unsigned char *) sink.s->data(), sink.s->size());
|
||||
rsink2(*sink.s);
|
||||
rsink2.flush();
|
||||
});
|
||||
|
||||
|
@ -108,4 +106,4 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
|
|||
}
|
||||
};
|
||||
|
||||
static auto rCmdMakeContentAddressable = registerCommand<CmdMakeContentAddressable>("make-content-addressable");
|
||||
static auto rCmdMakeContentAddressable = registerCommand2<CmdMakeContentAddressable>({"store", "make-content-addressable"});
|
||||
|
|
31
src/nix/nar.cc
Normal file
31
src/nix/nar.cc
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "command.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdNar : NixMultiCommand
|
||||
{
|
||||
CmdNar() : MultiCommand(RegisterCommand::getCommandsFor({"nar"}))
|
||||
{ }
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "query the contents of NAR files";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run() override
|
||||
{
|
||||
if (!command)
|
||||
throw UsageError("'nix nar' requires a sub-command.");
|
||||
command->second->prepare();
|
||||
command->second->run();
|
||||
}
|
||||
|
||||
void printHelp(const string & programName, std::ostream & out) override
|
||||
{
|
||||
MultiCommand::printHelp(programName, out);
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdNar = registerCommand<CmdNar>("nar");
|
|
@ -18,17 +18,15 @@ struct CmdOptimiseStore : StoreCommand
|
|||
return {
|
||||
Example{
|
||||
"To optimise the Nix store:",
|
||||
"nix optimise-store"
|
||||
"nix store optimise"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
store->optimiseStore();
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdOptimiseStore = registerCommand<CmdOptimiseStore>("optimise-store");
|
||||
static auto rCmdOptimiseStore = registerCommand2<CmdOptimiseStore>({"store", "optimise"});
|
||||
|
|
|
@ -16,17 +16,15 @@ struct CmdPingStore : StoreCommand
|
|||
return {
|
||||
Example{
|
||||
"To test whether connecting to a remote Nix store via SSH works:",
|
||||
"nix ping-store --store ssh://mac1"
|
||||
"nix store ping --store ssh://mac1"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
store->connect();
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdPingStore = registerCommand<CmdPingStore>("ping-store");
|
||||
static auto rCmdPingStore = registerCommand2<CmdPingStore>({"store", "ping"});
|
||||
|
|
|
@ -413,7 +413,7 @@ struct CmdProfileDiffClosures : virtual StoreCommand, MixDefaultProfile
|
|||
return {
|
||||
Example{
|
||||
"To show what changed between each generation of the NixOS system profile:",
|
||||
"nix profile diff-closure --profile /nix/var/nix/profiles/system"
|
||||
"nix profile diff-closures --profile /nix/var/nix/profiles/system"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// FIXME: integrate this with nix path-info?
|
||||
// FIXME: rename to 'nix store show-derivation' or 'nix debug show-derivation'?
|
||||
|
||||
#include "command.hh"
|
||||
#include "common-args.hh"
|
||||
|
|
|
@ -27,8 +27,6 @@ struct CmdCopySigs : StorePathsCommand
|
|||
return "copy path signatures from substituters (like binary caches)";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store, StorePaths storePaths) override
|
||||
{
|
||||
if (substituterUris.empty())
|
||||
|
@ -92,7 +90,7 @@ struct CmdCopySigs : StorePathsCommand
|
|||
}
|
||||
};
|
||||
|
||||
static auto rCmdCopySigs = registerCommand<CmdCopySigs>("copy-sigs");
|
||||
static auto rCmdCopySigs = registerCommand2<CmdCopySigs>({"store", "copy-sigs"});
|
||||
|
||||
struct CmdSignPaths : StorePathsCommand
|
||||
{
|
||||
|
@ -115,8 +113,6 @@ struct CmdSignPaths : StorePathsCommand
|
|||
return "sign the specified paths";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run(ref<Store> store, StorePaths storePaths) override
|
||||
{
|
||||
if (secretKeyFile.empty())
|
||||
|
@ -144,4 +140,4 @@ struct CmdSignPaths : StorePathsCommand
|
|||
}
|
||||
};
|
||||
|
||||
static auto rCmdSignPaths = registerCommand<CmdSignPaths>("sign-paths");
|
||||
static auto rCmdSignPaths = registerCommand2<CmdSignPaths>({"store", "sign-paths"});
|
||||
|
|
31
src/nix/store.cc
Normal file
31
src/nix/store.cc
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "command.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdStore : virtual NixMultiCommand
|
||||
{
|
||||
CmdStore() : MultiCommand(RegisterCommand::getCommandsFor({"store"}))
|
||||
{ }
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
return "manipulate a Nix store";
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
||||
void run() override
|
||||
{
|
||||
if (!command)
|
||||
throw UsageError("'nix store' requires a sub-command.");
|
||||
command->second->prepare();
|
||||
command->second->run();
|
||||
}
|
||||
|
||||
void printHelp(const string & programName, std::ostream & out) override
|
||||
{
|
||||
MultiCommand::printHelp(programName, out);
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdStore = registerCommand<CmdStore>("store");
|
|
@ -40,17 +40,15 @@ struct CmdVerify : StorePathsCommand
|
|||
return {
|
||||
Example{
|
||||
"To verify the entire Nix store:",
|
||||
"nix verify --all"
|
||||
"nix store verify --all"
|
||||
},
|
||||
Example{
|
||||
"To check whether each path in the closure of Firefox has at least 2 signatures:",
|
||||
"nix verify -r -n2 --no-contents $(type -p firefox)"
|
||||
"nix store verify -r -n2 --no-contents $(type -p firefox)"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Category category() override { return catSecondary; }
|
||||
|
||||
void run(ref<Store> store, StorePaths storePaths) override
|
||||
{
|
||||
std::vector<ref<Store>> substituters;
|
||||
|
@ -189,4 +187,4 @@ struct CmdVerify : StorePathsCommand
|
|||
}
|
||||
};
|
||||
|
||||
static auto rCmdVerify = registerCommand<CmdVerify>("verify");
|
||||
static auto rCmdVerify = registerCommand2<CmdVerify>({"store", "verify"});
|
||||
|
|
|
@ -188,7 +188,7 @@ unset _NIX_FORCE_HTTP
|
|||
|
||||
|
||||
# Test 'nix verify --all' on a binary cache.
|
||||
nix verify -vvvvv --all --store file://$cacheDir --no-trust
|
||||
nix store verify -vvvvv --all --store file://$cacheDir --no-trust
|
||||
|
||||
|
||||
# Test local NAR caching.
|
||||
|
@ -196,13 +196,13 @@ narCache=$TEST_ROOT/nar-cache
|
|||
rm -rf $narCache
|
||||
mkdir $narCache
|
||||
|
||||
[[ $(nix cat-store --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
|
||||
rm -rfv "$cacheDir/nar"
|
||||
|
||||
[[ $(nix cat-store --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
|
||||
(! nix cat-store --store file://$cacheDir $outPath/foobar)
|
||||
(! nix store cat --store file://$cacheDir $outPath/foobar)
|
||||
|
||||
|
||||
# Test NAR listing generation.
|
||||
|
|
|
@ -9,13 +9,13 @@ outPath=$(nix-build dependencies.nix --no-out-link)
|
|||
|
||||
nix copy --to $cacheURI $outPath
|
||||
|
||||
HASH=$(nix hash-path $outPath)
|
||||
HASH=$(nix hash path $outPath)
|
||||
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
nix copy --from $cacheURI $outPath --no-check-sigs
|
||||
|
||||
HASH2=$(nix hash-path $outPath)
|
||||
HASH2=$(nix hash path $outPath)
|
||||
|
||||
[[ $HASH = $HASH2 ]]
|
||||
|
|
|
@ -7,30 +7,32 @@ nix --experimental-features 'nix-command ca-derivations' show-derivation --deriv
|
|||
|
||||
buildAttr () {
|
||||
local derivationPath=$1
|
||||
shift
|
||||
local args=("--experimental-features" "ca-derivations" "./content-addressed.nix" "-A" "$derivationPath" "--no-out-link")
|
||||
local seedValue=$2
|
||||
shift; shift
|
||||
local args=("--experimental-features" "ca-derivations" "./content-addressed.nix" "-A" "$derivationPath" --arg seed "$seedValue" "--no-out-link")
|
||||
args+=("$@")
|
||||
nix-build "${args[@]}"
|
||||
}
|
||||
|
||||
testRemoteCache () {
|
||||
clearCache
|
||||
local outPath=$(buildAttr dependentNonCA)
|
||||
local outPath=$(buildAttr dependentNonCA 1)
|
||||
nix copy --to file://$cacheDir $outPath
|
||||
clearStore
|
||||
buildAttr dependentNonCA --option substituters file://$cacheDir --no-require-sigs |& (! grep "building dependent-non-ca")
|
||||
buildAttr dependentNonCA 1 --option substituters file://$cacheDir --no-require-sigs |& (! grep "building dependent-non-ca")
|
||||
}
|
||||
|
||||
testDeterministicCA () {
|
||||
[[ $(buildAttr rootCA) = $(buildAttr rootCA) ]]
|
||||
[[ $(buildAttr rootCA 1) = $(buildAttr rootCA 2) ]]
|
||||
}
|
||||
|
||||
testCutoffFor () {
|
||||
local out1 out2
|
||||
out1=$(buildAttr $1)
|
||||
out1=$(buildAttr $1 1)
|
||||
# The seed only changes the root derivation, and not it's output, so the
|
||||
# dependent derivations should only need to be built once.
|
||||
out2=$(buildAttr $1 -j0)
|
||||
buildAttr rootCA 2
|
||||
out2=$(buildAttr $1 2 -j0)
|
||||
test "$out1" == "$out2"
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ cmp $outPath fetchurl.sh
|
|||
# Now using a base-64 hash.
|
||||
clearStore
|
||||
|
||||
hash=$(nix hash-file --type sha512 --base64 ./fetchurl.sh)
|
||||
hash=$(nix hash file --type sha512 --base64 ./fetchurl.sh)
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr sha512 $hash --no-out-link)
|
||||
|
||||
|
@ -21,7 +21,7 @@ cmp $outPath fetchurl.sh
|
|||
# Now using an SRI hash.
|
||||
clearStore
|
||||
|
||||
hash=$(nix hash-file ./fetchurl.sh)
|
||||
hash=$(nix hash file ./fetchurl.sh)
|
||||
|
||||
[[ $hash =~ ^sha256- ]]
|
||||
|
||||
|
@ -34,14 +34,14 @@ clearStore
|
|||
|
||||
other_store=file://$TEST_ROOT/other_store?store=/fnord/store
|
||||
|
||||
hash=$(nix hash-file --type sha256 --base16 ./fetchurl.sh)
|
||||
hash=$(nix hash file --type sha256 --base16 ./fetchurl.sh)
|
||||
|
||||
storePath=$(nix --store $other_store add-to-store --flat ./fetchurl.sh)
|
||||
storePath=$(nix --store $other_store store add-file ./fetchurl.sh)
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr sha256 $hash --no-out-link --substituters $other_store)
|
||||
|
||||
# Test hashed mirrors with an SRI hash.
|
||||
nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr hash $(nix to-sri --type sha256 $hash) \
|
||||
nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr hash $(nix hash to-sri --type sha256 $hash) \
|
||||
--no-out-link --substituters $other_store
|
||||
|
||||
# Test unpacking a NAR.
|
||||
|
|
|
@ -2,9 +2,9 @@ source common.sh
|
|||
|
||||
clearStore
|
||||
|
||||
garbage1=$(nix add-to-store --name garbage1 ./nar-access.sh)
|
||||
garbage2=$(nix add-to-store --name garbage2 ./nar-access.sh)
|
||||
garbage3=$(nix add-to-store --name garbage3 ./nar-access.sh)
|
||||
garbage1=$(nix store add-path --name garbage1 ./nar-access.sh)
|
||||
garbage2=$(nix store add-path --name garbage2 ./nar-access.sh)
|
||||
garbage3=$(nix store add-path --name garbage3 ./nar-access.sh)
|
||||
|
||||
ls -l $garbage3
|
||||
POSIXLY_CORRECT=1 du $garbage3
|
||||
|
|
|
@ -2,7 +2,7 @@ source common.sh
|
|||
|
||||
try () {
|
||||
printf "%s" "$2" > $TEST_ROOT/vector
|
||||
hash=$(nix hash-file --base16 $EXTRA --type "$1" $TEST_ROOT/vector)
|
||||
hash=$(nix hash file --base16 $EXTRA --type "$1" $TEST_ROOT/vector)
|
||||
if test "$hash" != "$3"; then
|
||||
echo "hash $1, expected $3, got $hash"
|
||||
exit 1
|
||||
|
@ -69,17 +69,17 @@ try2 md5 "f78b733a68f5edbdf9413899339eaa4a"
|
|||
|
||||
# Conversion.
|
||||
try3() {
|
||||
h64=$(nix to-base64 --type "$1" "$2")
|
||||
h64=$(nix hash to-base64 --type "$1" "$2")
|
||||
[ "$h64" = "$4" ]
|
||||
sri=$(nix to-sri --type "$1" "$2")
|
||||
sri=$(nix hash to-sri --type "$1" "$2")
|
||||
[ "$sri" = "$1-$4" ]
|
||||
h32=$(nix-hash --type "$1" --to-base32 "$2")
|
||||
[ "$h32" = "$3" ]
|
||||
h16=$(nix-hash --type "$1" --to-base16 "$h32")
|
||||
[ "$h16" = "$2" ]
|
||||
h16=$(nix to-base16 --type "$1" "$h64")
|
||||
h16=$(nix hash to-base16 --type "$1" "$h64")
|
||||
[ "$h16" = "$2" ]
|
||||
h16=$(nix to-base16 "$sri")
|
||||
h16=$(nix hash to-base16 "$sri")
|
||||
[ "$h16" = "$2" ]
|
||||
}
|
||||
try3 sha1 "800d59cfcd3c05e900cb4e214be48f6b886a08df" "vw46m23bizj4n8afrc0fj19wrp7mj3c0" "gA1Zz808BekAy04hS+SPa4hqCN8="
|
||||
|
|
|
@ -22,9 +22,9 @@ outPath=$(nix-build dependencies.nix --no-out-link --sandbox-paths /nix/store)
|
|||
|
||||
nix path-info -r $outPath | grep input-2
|
||||
|
||||
nix ls-store -R -l $outPath | grep foobar
|
||||
nix store ls -R -l $outPath | grep foobar
|
||||
|
||||
nix cat-store $outPath/foobar | grep FOOBAR
|
||||
nix store cat $outPath/foobar | grep FOOBAR
|
||||
|
||||
# Test --check without hash rewriting.
|
||||
nix-build dependencies.nix --no-out-link --check --sandbox-paths /nix/store
|
||||
|
|
|
@ -9,45 +9,45 @@ cd "$TEST_ROOT"
|
|||
narFile="$TEST_ROOT/path.nar"
|
||||
nix-store --dump $storePath > $narFile
|
||||
|
||||
# Check that find and ls-nar match.
|
||||
# Check that find and nar ls match.
|
||||
( cd $storePath; find . | sort ) > files.find
|
||||
nix ls-nar -R -d $narFile "" | sort > files.ls-nar
|
||||
nix nar ls -R -d $narFile "" | sort > files.ls-nar
|
||||
diff -u files.find files.ls-nar
|
||||
|
||||
# Check that file contents of data match.
|
||||
nix cat-nar $narFile /foo/data > data.cat-nar
|
||||
nix nar cat $narFile /foo/data > data.cat-nar
|
||||
diff -u data.cat-nar $storePath/foo/data
|
||||
|
||||
# Check that file contents of baz match.
|
||||
nix cat-nar $narFile /foo/baz > baz.cat-nar
|
||||
nix nar cat $narFile /foo/baz > baz.cat-nar
|
||||
diff -u baz.cat-nar $storePath/foo/baz
|
||||
|
||||
nix cat-store $storePath/foo/baz > baz.cat-nar
|
||||
nix store cat $storePath/foo/baz > baz.cat-nar
|
||||
diff -u baz.cat-nar $storePath/foo/baz
|
||||
|
||||
# Test --json.
|
||||
diff -u \
|
||||
<(nix ls-nar --json $narFile / | jq -S) \
|
||||
<(nix nar ls --json $narFile / | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"foo":{},"foo-x":{},"qux":{},"zyx":{}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-nar --json -R $narFile /foo | jq -S) \
|
||||
<(nix nar ls --json -R $narFile /foo | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"bar":{"type":"regular","size":0,"narOffset":368},"baz":{"type":"regular","size":0,"narOffset":552},"data":{"type":"regular","size":58,"narOffset":736}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-nar --json -R $narFile /foo/bar | jq -S) \
|
||||
<(nix nar ls --json -R $narFile /foo/bar | jq -S) \
|
||||
<(echo '{"type":"regular","size":0,"narOffset":368}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-store --json $storePath | jq -S) \
|
||||
<(nix store ls --json $storePath | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"foo":{},"foo-x":{},"qux":{},"zyx":{}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-store --json -R $storePath/foo | jq -S) \
|
||||
<(nix store ls --json -R $storePath/foo | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"bar":{"type":"regular","size":0},"baz":{"type":"regular","size":0},"data":{"type":"regular","size":58}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-store --json -R $storePath/foo/bar| jq -S) \
|
||||
<(nix store ls --json -R $storePath/foo/bar| jq -S) \
|
||||
<(echo '{"type":"regular","size":0}' | jq -S)
|
||||
|
||||
# Test missing files.
|
||||
nix ls-store --json -R $storePath/xyzzy 2>&1 | grep 'does not exist in NAR'
|
||||
nix ls-store $storePath/xyzzy 2>&1 | grep 'does not exist'
|
||||
nix store ls --json -R $storePath/xyzzy 2>&1 | grep 'does not exist in NAR'
|
||||
nix store ls $storePath/xyzzy 2>&1 | grep 'does not exist'
|
||||
|
||||
# Test failure to dump.
|
||||
if nix-store --dump $storePath >/dev/full ; then
|
||||
|
|
|
@ -15,4 +15,12 @@ nix eval --expr 'assert 1 + 2 == 3; true'
|
|||
|
||||
[[ $(nix eval --impure --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; })).x") == 123 ]]
|
||||
(! nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; })).x")
|
||||
nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; sha256 = \"$(nix hash-file pure-eval.nix --type sha256)\"; })).x"
|
||||
nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; sha256 = \"$(nix hash file pure-eval.nix --type sha256)\"; })).x"
|
||||
|
||||
rm -rf $TEST_ROOT/eval-out
|
||||
nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ x = "foo" + "bar"; y = { z = "bla"; }; }'
|
||||
[[ $(cat $TEST_ROOT/eval-out/x) = foobar ]]
|
||||
[[ $(cat $TEST_ROOT/eval-out/y/z) = bla ]]
|
||||
|
||||
rm -rf $TEST_ROOT/eval-out
|
||||
(! nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ "." = "bla"; }')
|
||||
|
|
|
@ -7,7 +7,7 @@ clearStore
|
|||
|
||||
rm -f $TEST_ROOT/result
|
||||
|
||||
export unreachable=$(nix add-to-store ./recursive.sh)
|
||||
export unreachable=$(nix store add-path ./recursive.sh)
|
||||
|
||||
NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command recursive-nix' build -o $TEST_ROOT/result -L --impure --expr '
|
||||
with import ./config.nix;
|
||||
|
@ -38,7 +38,7 @@ NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command r
|
|||
|
||||
# Add something to the store.
|
||||
echo foobar > foobar
|
||||
foobar=$(nix $opts add-to-store ./foobar)
|
||||
foobar=$(nix $opts store add-path ./foobar)
|
||||
|
||||
nix $opts path-info $foobar
|
||||
nix $opts build $foobar
|
||||
|
|
|
@ -17,40 +17,40 @@ info=$(nix path-info --json $outPath)
|
|||
[[ $info =~ 'cache1.example.org' ]]
|
||||
[[ $info =~ 'cache2.example.org' ]]
|
||||
|
||||
# Test "nix verify".
|
||||
nix verify -r $outPath
|
||||
# Test "nix store verify".
|
||||
nix store verify -r $outPath
|
||||
|
||||
expect 2 nix verify -r $outPath --sigs-needed 1
|
||||
expect 2 nix store verify -r $outPath --sigs-needed 1
|
||||
|
||||
nix verify -r $outPath --sigs-needed 1 --trusted-public-keys $pk1
|
||||
nix store verify -r $outPath --sigs-needed 1 --trusted-public-keys $pk1
|
||||
|
||||
expect 2 nix verify -r $outPath --sigs-needed 2 --trusted-public-keys $pk1
|
||||
expect 2 nix store verify -r $outPath --sigs-needed 2 --trusted-public-keys $pk1
|
||||
|
||||
nix verify -r $outPath --sigs-needed 2 --trusted-public-keys "$pk1 $pk2"
|
||||
nix store verify -r $outPath --sigs-needed 2 --trusted-public-keys "$pk1 $pk2"
|
||||
|
||||
nix verify --all --sigs-needed 2 --trusted-public-keys "$pk1 $pk2"
|
||||
nix store verify --all --sigs-needed 2 --trusted-public-keys "$pk1 $pk2"
|
||||
|
||||
# Build something unsigned.
|
||||
outPath2=$(nix-build simple.nix --no-out-link)
|
||||
|
||||
nix verify -r $outPath
|
||||
nix store verify -r $outPath
|
||||
|
||||
# Verify that the path did not get signed but does have the ultimate bit.
|
||||
info=$(nix path-info --json $outPath2)
|
||||
[[ $info =~ '"ultimate":true' ]]
|
||||
(! [[ $info =~ 'signatures' ]])
|
||||
|
||||
# Test "nix verify".
|
||||
nix verify -r $outPath2
|
||||
# Test "nix store verify".
|
||||
nix store verify -r $outPath2
|
||||
|
||||
expect 2 nix verify -r $outPath2 --sigs-needed 1
|
||||
expect 2 nix store verify -r $outPath2 --sigs-needed 1
|
||||
|
||||
expect 2 nix verify -r $outPath2 --sigs-needed 1 --trusted-public-keys $pk1
|
||||
expect 2 nix store verify -r $outPath2 --sigs-needed 1 --trusted-public-keys $pk1
|
||||
|
||||
# Test "nix sign-paths".
|
||||
nix sign-paths --key-file $TEST_ROOT/sk1 $outPath2
|
||||
# Test "nix store sign-paths".
|
||||
nix store sign-paths --key-file $TEST_ROOT/sk1 $outPath2
|
||||
|
||||
nix verify -r $outPath2 --sigs-needed 1 --trusted-public-keys $pk1
|
||||
nix store verify -r $outPath2 --sigs-needed 1 --trusted-public-keys $pk1
|
||||
|
||||
# Build something content-addressed.
|
||||
outPathCA=$(IMPURE_VAR1=foo IMPURE_VAR2=bar nix-build ./fixed.nix -A good.0 --no-out-link)
|
||||
|
@ -59,12 +59,12 @@ outPathCA=$(IMPURE_VAR1=foo IMPURE_VAR2=bar nix-build ./fixed.nix -A good.0 --no
|
|||
|
||||
# Content-addressed paths don't need signatures, so they verify
|
||||
# regardless of --sigs-needed.
|
||||
nix verify $outPathCA
|
||||
nix verify $outPathCA --sigs-needed 1000
|
||||
nix store verify $outPathCA
|
||||
nix store verify $outPathCA --sigs-needed 1000
|
||||
|
||||
# Check that signing a content-addressed path doesn't overflow validSigs
|
||||
nix sign-paths --key-file $TEST_ROOT/sk1 $outPathCA
|
||||
nix verify -r $outPathCA --sigs-needed 1000 --trusted-public-keys $pk1
|
||||
nix store sign-paths --key-file $TEST_ROOT/sk1 $outPathCA
|
||||
nix store verify -r $outPathCA --sigs-needed 1000 --trusted-public-keys $pk1
|
||||
|
||||
# Copy to a binary cache.
|
||||
nix copy --to file://$cacheDir $outPath2
|
||||
|
@ -76,7 +76,7 @@ info=$(nix path-info --store file://$cacheDir --json $outPath2)
|
|||
(! [[ $info =~ 'cache2.example.org' ]])
|
||||
|
||||
# Verify that adding a signature to a path in a binary cache works.
|
||||
nix sign-paths --store file://$cacheDir --key-file $TEST_ROOT/sk2 $outPath2
|
||||
nix store sign-paths --store file://$cacheDir --key-file $TEST_ROOT/sk2 $outPath2
|
||||
info=$(nix path-info --store file://$cacheDir --json $outPath2)
|
||||
[[ $info =~ 'cache1.example.org' ]]
|
||||
[[ $info =~ 'cache2.example.org' ]]
|
||||
|
@ -89,17 +89,17 @@ rm -rf $TEST_ROOT/store0
|
|||
# But succeed if we supply the public keys.
|
||||
nix copy --to $TEST_ROOT/store0 $outPath --trusted-public-keys $pk1
|
||||
|
||||
expect 2 nix verify --store $TEST_ROOT/store0 -r $outPath
|
||||
expect 2 nix store verify --store $TEST_ROOT/store0 -r $outPath
|
||||
|
||||
nix verify --store $TEST_ROOT/store0 -r $outPath --trusted-public-keys $pk1
|
||||
nix verify --store $TEST_ROOT/store0 -r $outPath --sigs-needed 2 --trusted-public-keys "$pk1 $pk2"
|
||||
nix store verify --store $TEST_ROOT/store0 -r $outPath --trusted-public-keys $pk1
|
||||
nix store verify --store $TEST_ROOT/store0 -r $outPath --sigs-needed 2 --trusted-public-keys "$pk1 $pk2"
|
||||
|
||||
# It should also succeed if we disable signature checking.
|
||||
(! nix copy --to $TEST_ROOT/store0 $outPath2)
|
||||
nix copy --to $TEST_ROOT/store0?require-sigs=false $outPath2
|
||||
|
||||
# But signatures should still get copied.
|
||||
nix verify --store $TEST_ROOT/store0 -r $outPath2 --trusted-public-keys $pk1
|
||||
nix store verify --store $TEST_ROOT/store0 -r $outPath2 --trusted-public-keys $pk1
|
||||
|
||||
# Content-addressed stuff can be copied without signatures.
|
||||
nix copy --to $TEST_ROOT/store0 $outPathCA
|
||||
|
|
|
@ -11,6 +11,6 @@ store+=$remote_store
|
|||
store+=$remote_store
|
||||
store+=$remote_store
|
||||
|
||||
out=$(nix add-to-store --store "$store" $TEST_ROOT/hello.sh)
|
||||
out=$(nix store add-path --store "$store" $TEST_ROOT/hello.sh)
|
||||
|
||||
[ foo = $(< $out) ]
|
||||
|
|
|
@ -10,7 +10,7 @@ mkdir -p $tarroot
|
|||
cp dependencies.nix $tarroot/default.nix
|
||||
cp config.nix dependencies.builder*.sh $tarroot/
|
||||
|
||||
hash=$(nix hash-path $tarroot)
|
||||
hash=$(nix hash path $tarroot)
|
||||
|
||||
test_tarball() {
|
||||
local ext="$1"
|
||||
|
|
Loading…
Reference in a new issue