github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/tools/mk_macports (about)

     1  #!/usr/bin/env bash
     2  
     3  # Install files into MacPorts DESTDIR
     4  
     5  # Usage:
     6  #   mk_macports MANIFEST MANIFEST1 ...
     7  
     8  # Where "manifest.txt" contains:
     9  #   exec /usr/bin/stack_makefqdn  misc/stack_makefqdn.py
    10  #   exec /usr/bin/bar             bar/bar.sh
    11  #   read /usr/man/man1/bar.1      bar/bar.1.man
    12  #   0444 /etc/foo.conf            bar/foo.conf
    13  # (NOTE: "exec" means 0755; "read" means 0744)
    14  
    15  set -e
    16  
    17  # Fail if DESTDIR is not set.
    18  DESTDIR="${DESTDIR?"Envvar DESTDIR must be set to destination dir."}"
    19  
    20  # Copy the files into place:
    21  cat """$@""" | while read -a arr ; do
    22    PERM="${arr[0]}"
    23    case $PERM in
    24      \#*)  continue ;;   # Skip comments.
    25      exec) PERM=0755 ;;
    26      read) PERM=0744 ;;
    27      *) ;;
    28    esac
    29    DST="$DESTDIR/${arr[1]}"
    30    SRC="${arr[2]}"
    31    install -m "$PERM" "$SRC" "$DST"
    32  done