Commit 823e0dd4 authored by Alessandro Rubini's avatar Alessandro Rubini

flash-wrs: use TMPDIR from environment, defaulting to /tmp

It is a common convention to use $TMPDIR for temporaries, instead
of an hardwired /tmp pathname.  And now I need is because my /tmp is
too small on the system where I flash.

The local variable TMPDIR is thus renamed to WRSTMPDIR.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent aaf00621
...@@ -130,7 +130,9 @@ rootfsjffs2="" ...@@ -130,7 +130,9 @@ rootfsjffs2=""
# full path to the file system directory # full path to the file system directory
TMPFS="" TMPFS=""
TMPDIR=$(mktemp -d /tmp/flash-wrs-XXXXXX) if [ "x$TMPDIR" = "x" ]; then TMPDIR="/tmp"; fi
WRSTMPDIR=$(mktemp -d $TMPDIR/flash-wrs-XXXXXX)
while [ $# -ge 1 ]; do while [ $# -ge 1 ]; do
case $1 in case $1 in
...@@ -143,11 +145,11 @@ while [ $# -ge 1 ]; do ...@@ -143,11 +145,11 @@ while [ $# -ge 1 ]; do
*.tar.gz) *.tar.gz)
checkExit "tar-file" $1 checkExit "tar-file" $1
tar --directory $TMPDIR -xzf $1 tar --directory $WRSTMPDIR -xzf $1
at91bs=$TMPDIR/at91bootstrap.bin; at91bs=$WRSTMPDIR/at91bootstrap.bin;
barebox=$TMPDIR/barebox.bin barebox=$WRSTMPDIR/barebox.bin
kernel=$TMPDIR/zImage kernel=$WRSTMPDIR/zImage
rootfsgz=$TMPDIR/wrs-image.tar.gz rootfsgz=$WRSTMPDIR/wrs-image.tar.gz
shift;; shift;;
-h|--help) showhelp; shift;; -h|--help) showhelp; shift;;
...@@ -209,7 +211,7 @@ fi ...@@ -209,7 +211,7 @@ fi
# Even if not all files are always needed, check all of them immediately # Even if not all files are always needed, check all of them immediately
me=$(basename $0) me=$(basename $0)
echo "${me}: Working in $TMPDIR" echo "${me}: Working in $WRSTMPDIR"
checkExit barebox $barebox checkExit barebox $barebox
checkExit at91bootstrap $at91bs checkExit at91bootstrap $at91bs
checkExit kernel $kernel checkExit kernel $kernel
...@@ -262,7 +264,7 @@ echo -n " please release the flash button and press Enter to start flashing: " ...@@ -262,7 +264,7 @@ echo -n " please release the flash button and press Enter to start flashing: "
read unused read unused
# Create a temporary barebox binary with modified MAC addresses # Create a temporary barebox binary with modified MAC addresses
Tbarebox=$TMPDIR/bb.new Tbarebox=$WRSTMPDIR/bb.new
modifyMAC ${barebox} ${Tbarebox} modifyMAC ${barebox} ${Tbarebox}
...@@ -274,18 +276,18 @@ fi ...@@ -274,18 +276,18 @@ fi
## Prepare for the NAND flashing procedure ## Prepare for the NAND flashing procedure
if $nf; then if $nf; then
TMPFS=$TMPDIR/wrsfs-tgz; mkdir $TMPFS TMPFS=$WRSTMPDIR/wrsfs-tgz; mkdir $TMPFS
rootfsjffs2=$TMPDIR/wrs-image.jffs2 rootfsjffs2=$WRSTMPDIR/wrs-image.jffs2
# The TMPCPIO is used for the NAND flashing procedure. It # The TMPCPIO is used for the NAND flashing procedure. It
# contains the magic string "paperino" (0x61706570 0x69726f6e) # contains the magic string "paperino" (0x61706570 0x69726f6e)
# in the first 8bytes and in the following byte the whole # in the first 8bytes and in the following byte the whole
# file system. Barebox use this magic string to identify # file system. Barebox use this magic string to identify
# the flashing procedure. # the flashing procedure.
TMPCPIO=$TMPDIR/wrsflash.cpio.gz TMPCPIO=$WRSTMPDIR/wrsflash.cpio.gz
# make flashing cpio from the unzipped file system # make flashing cpio from the unzipped file system
TMPSCRIPT=$TMPDIR/wrsrootfs-script TMPSCRIPT=$WRSTMPDIR/wrsrootfs-script
cat > $TMPSCRIPT << EOF cat > $TMPSCRIPT << EOF
tar --directory $TMPFS -xzf $rootfsgz tar --directory $TMPFS -xzf $rootfsgz
# Remove the unnecessary HDL files, by default we keep 18 ports HDL for both FPGA type # Remove the unnecessary HDL files, by default we keep 18 ports HDL for both FPGA type
...@@ -327,10 +329,10 @@ fi ...@@ -327,10 +329,10 @@ fi
## Loading in DDR ## Loading in DDR
if $ddr; then if $ddr; then
TMPFS=$(mktemp -d /tmp/wrsfs-tgz.XXXXXX) TMPFS=$(mktemp -d $TMPDIR/wrsfs-tgz.XXXXXX)
rootfsjffs2=/tmp/wrs-image.jffs2.img rootfsjffs2=$TMPDIR/wrs-image.jffs2.img
# make cpio and jffs2 image # make cpio and jffs2 image
TMPSCRIPT=$(mktemp /tmp/wrsrootfs-script.XXXXXX) TMPSCRIPT=$(mktemp $TMPDIR/wrsrootfs-script.XXXXXX)
cat > $TMPSCRIPT << EOF cat > $TMPSCRIPT << EOF
tar --directory $TMPFS -xzf $rootfsgz tar --directory $TMPFS -xzf $rootfsgz
mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $rootfsjffs2 mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $rootfsjffs2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment