view scripts/ @ 1087:b73a61542297 draft

I've finally gotten 'cpio' into a shape where it could be useable. This version can archive and extract directories, sockets, FIFOs, devices, symlinks, and regular files. Supported options are -iot, -H FMT (which is a dummy right now). It only writes newc, and could read newc or newcrc. This does NOT implement -d, which essentially is equivalent to mkdir -p $(dirname $FILE) for every file that needs it. Hard links are not supported, though it would be easy to add them given a hash table or something like that. I also have not implemented the "<n> blocks" output on stderr. If desired, I can add it pretty simply. There is one assumption this makes: that the mode of a file, as mode_t, is bitwise equivalent to the mode as defined for the cpio format. This is true of Linux, but is not mandated by POSIX. If it is compiled for a system where that is false, the archives will not be portable.
author Isaac Dunham <>
date Mon, 14 Oct 2013 11:15:22 -0500
parents a612857eb52d
children 565980862743
line wrap: on
line source


# This has to be a separate file from scripts/ so it can be called
# before menuconfig.  (It's called again from scripts/ just to be sure.)

mkdir -p generated

source configure

  # Probe for container support on target

  echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
  ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null - 2>/dev/null << EOF
    #include <linux/sched.h>

    int main(int argc, char *argv[]) { return unshare(x); }
  [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
  rm a.out 2>/dev/null
  echo -e "\tdefault $DEFAULT\n" || return 1

  # I could query the directory here, but I want to control the order
  # and capitalization in the menu
  for j in toys/*/README
    DIR="$(dirname "$j")"

    [ $(ls "$DIR" | wc -l) -lt 2 ] && continue

    echo "menu \"$(head -n 1 $j)\""

    # extract config stanzas from each source file, in alphabetical order
    for i in $(ls -1 $DIR/*.c)
      # Grab the config block for
      echo "# $i"
      sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1

    echo endmenu

  ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null - 2>/dev/null << EOF
    #include <fcntl.h>
    #ifndef O_NOFOLLOW
    #error posix 2008 was a while ago now
  if [ $? -ne 0 ]
    rm -f a.out
    ${CROSS_COMPILE}${CC} $CFLAGS -xc - 2>/dev/null << EOF
      #include <stdio.h>
      #include <sys/types.h>
      #include <asm/fcntl.h>

      int main(int argc, char *argv[])
        printf("0x%x\n", O_NOFOLLOW);
    X=$(./a.out) 2>/dev/null
    rm -f a.out
    echo "#define O_NOFOLLOW ${X:-0}"

probeconfig > generated/Config.probed || rm generated/Config.probed
genconfig > generated/ || rm generated/
headerprobes > generated/portability.h || rm generated/portability.h