PiDP-8/I Software

Changes On Branch release
Log In

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch release Excluding Merge-Ins

This is equivalent to a diff from 07a540166c to 2e08e8ff1a

2019-04-25
10:29
Added -y to an apt-get command in tools/bosi check-in: 04cce6c025 user: tangent tags: trunk
09:46
Merged trunk changes for v20190425 into release branch Leaf check-in: 2e08e8ff1a user: tangent tags: release, v20190425
09:40
Small fix to tools/mkrel. check-in: 07a540166c user: tangent tags: trunk
09:40
Released v20190425 check-in: 1999bfb59b user: tangent tags: trunk
2017-12-23
03:55
Merged doc fix in check-in: 3e64e6c138 user: tangent tags: release, v20171222

Changes to examples/pep001.bas.

     1         -1 REM Copyright (c) 2016 by Warren Young
     2         -2 REM Released under the terms of ../SIMH-LICENSE.md
     3         -3 REM ------------------------------------------------------------------
     4      1   10 FOR I = 1 TO 999
     5      2   20 A = I / 3 \ B = I / 5
     6      3   30 IF INT(A) = A GOTO 60
     7      4   40 IF INT(B) = B GOTO 60
     8      5   50 GOTO 70
     9      6   60 T = T + I
    10      7   70 NEXT I
    11      8   80 PRINT "TOTAL: "; T
    12      9   90 END

Changes to tools/bosi.

     1         -#!/bin/bash
            1  +#!/bin/bash -x
     2      2   # bosi - The Binary OS Image creation/update script
     3         -#
     4         -# Copyright © 2016-2017 by Warren Young
     5         -# 
     6         -# Permission is hereby granted, free of charge, to any person obtaining a
     7         -# copy of this software and associated documentation files (the
     8         -# "Software"), to deal in the Software without restriction, including
     9         -# without limitation the rights to use, copy, modify, merge, publish,
    10         -# distribute, sublicense, and/or sell copies of the Software, and to
    11         -# permit persons to whom the Software is furnished to do so, subject to
    12         -# the following conditions:
    13         -# 
    14         -# The above copyright notice and this permission notice shall be included
    15         -# in all copies or substantial portions of the Software.
    16         -# 
    17         -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    18         -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    19         -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    20         -# IN NO EVENT SHALL THE AUTHORS LISTED ABOVE BE LIABLE FOR ANY CLAIM,
    21         -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
    22         -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
    23         -# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    24         -# 
    25         -# Except as contained in this notice, the names of the authors above shall
    26         -# not be used in advertising or otherwise to promote the sale, use or
    27         -# other dealings in this Software without prior written authorization from
    28         -# those authors.
    29         -
    30         -
    31         -# Display the usage message
    32         -function usage() {
    33         -    cat <<USAGE
    34         -usage: $0 <verb> [tag]
    35         -
    36         -    The available verbs are init, build, prepare, shrink, image, and finish.
    37         -
    38         -    You may include a tag parameter with the 'image' and 'finish' verbs
    39         -    to override the default tag ('ils') used in image and zip file
    40         -    outputs.
    41         -
    42         -    See RELEASE-PROCESS.md for more info.
    43         -
    44         -USAGE
    45         -    exit 1
    46         -}
    47      3   
    48      4   verb="$1"
    49         -tag="$2"
    50         -test -n "$verb" || usage
    51         -test -z "$tag" && tag=ils
            5  +object="$2"
            6  +
            7  +tag=$(echo $verb | cut -f2 -d- -s)
            8  +test -z "$tag" && tag=all
    52      9   
    53     10   nu=pidp8i
    54     11   nh=/home/$nu
    55     12   repo=pidp8i
    56     13   dldir="$HOME/tangentsoft.com/dl"
    57         -os=stretch-lite
           14  +os=jessie-lite
    58     15   img=$dldir/pidp8i-$(date +%Y.%m.%d)-$tag-$os.img
           16  +rdisk=/dev/rdisk10
    59     17   greadlink=$(type -p greadlink || type -p readlink)
    60     18   this=$($greadlink -f $0)
    61         -topdir="$($greadlink -f "$(dirname "$this")"/..)"
    62         -
    63         -
    64         -# Give user a few seconds to read the final messages before rebooting or
    65         -# powering off.
    66         -function do_wait() {
    67         -    n=8
    68         -    cat <<MSG
    69         -    
    70         -$1 in $n seconds...
    71         -
    72         -
    73         -MSG
    74         -    sleep $n
    75         -}
    76     19   
    77     20   
    78     21   # Initial steps
    79     22   function do_init() {
    80         -    if [ "$USER" != "root" ]
    81         -    then
    82         -        echo "The init step has to be run as root.  The explanation is"
    83         -        echo "given in the section for 'init' in RELEASE-PROCESS.md."
    84         -        echo
    85         -        exit 1
    86         -    fi
    87         -
    88         -    set -x
    89         -
    90         -    apt-get update && apt-get -y upgrade || true
    91         -
    92         -    apt-get install python-pip || true
    93         -    pip install pexpect
    94         -
    95         -    test -f /usr/include/curses.h || apt-get -y install libncurses-dev
    96         -
    97         -    if [ -z "$(type -p fossil)" ]
    98         -    then
    99         -        fb=/usr/local/bin/fossil
   100         -        src=https://tangentsoft.com/pidp8i/uv/fossil-2.8-raspbian-9.6-stretch
   101         -        wget -O $fb $src
   102         -        chmod +x $fb
   103         -        apt-get -y install libssl-dev    # user might rebuild Fossil later
   104         -    fi
   105         -
   106         -    if [ ! -e "$nh" ]
   107         -    then
   108         -        # First pass on a clean SD card: rename 'pi' user and group to
   109         -        # 'pidp8i' and rename its home directory to match.
   110         -        pkill -u pi
   111         -        usermod  -l $nu -d $nh -m pi 
   112         -        groupmod -n $nu pi
   113         -    fi
   114         -
   115         -    reboot
           23  +	if ! getent passwd $nu > /dev/null
           24  +	then
           25  +		if [ "$USER" != "root" ]
           26  +		then
           27  +			echo "The init step has to be run as root."
           28  +			echo "See RELEASE-PROCESS.md."
           29  +			echo
           30  +			exit 1
           31  +		fi
           32  +
           33  +		usermod \
           34  +			-d $nh \
           35  +			-l $nu \
           36  +			-p $(openssl passwd -1 edsonDeCastro1968) \
           37  +			-m pi 
           38  +	fi
           39  +
           40  +	sudo apt-get update && sudo apt-get -y upgrade || true
           41  +	do_fossil
           42  +}
           43  +
           44  +
           45  +# Fossil clone, build and install
           46  +function do_fossil() {
           47  +	test "$USER" = "root" && exec sudo -i -u $nu $nh/bosi fossil $object
           48  +	cd $HOME
           49  +
           50  +	test -n "$(type -p fossil)" || sudo apt-get -y install fossil
           51  +
           52  +	if [ ! -d museum ]
           53  +	then
           54  +		mkdir -p museum $repo
           55  +		fossil clone https://tangentsoft.com/$repo museum/$repo.fossil
           56  +	fi
           57  +
           58  +	cd $repo
           59  +
           60  +	if [ -r ChangeLog.md ]
           61  +	then
           62  +		fossil revert			# just in case
           63  +		fossil update $object
           64  +	else
           65  +		fossil open ~/museum/$repo.fossil $object
           66  +		./configure
           67  +	fi
           68  +
           69  +	make -j4
           70  +	sudo make install || true
           71  +	sudo reboot
   116     72   }
   117     73   
   118     74   
   119         -# Clone repo and build the software under [new] pidp8i account
   120         -function do_build() {
   121         -    if [ "$USER" != "$nu" ]
   122         -    then
   123         -        echo "The build step has to be run as $nu."
   124         -        echo
   125         -        exit 1
   126         -    fi
           75  +# This script resets the OS's configuration to a clean first boot state.
           76  +function do_reset() {
           77  +	history -c ; rm -f ~/.bash_history
           78  +	test "$USER" = "root" || exec sudo $this reset
   127     79   
   128         -    set -x
   129         -
   130         -    if [ ! -d museum ]
   131         -    then
   132         -        mkdir -p museum $repo
   133         -        fossil clone https://tangentsoft.com/$repo museum/$repo.fossil
   134         -    fi
   135         -
   136         -    cd $repo
   137         -
   138         -    if [ -r ChangeLog.md ]
   139         -    then
   140         -        fossil revert           # just in case
   141         -        fossil update release
   142         -    else
   143         -        fossil open ~/museum/$repo.fossil release
   144         -        fossil set autosync pullonly
   145         -        ./configure
   146         -    fi
   147         -
   148         -    tools/mmake
   149         -    bin/teco-pi-demo -b             # test and benchmark simulator
   150         -    sudo make install || true       # don't care about return code
   151         -    do_wait "Rebooting"
   152         -    sudo reboot
           80  +	shred -u /etc/ssh/*key*
           81  +	dphys-swapfile uninstall
           82  +	dd if=/dev/zero of=/junk bs=1M || true		# it *will* error-out!
           83  +	rm /junk
           84  +	passwd -e pidp8i
           85  +	( sleep 1 ; poweroff ) & exit
   153     86   }
   154     87   
   155     88   
   156         -# This script prepares the OS's configuration to a clean first boot state.
   157         -function do_prepare() {
   158         -    if [ "$USER" != "$nu" ]
   159         -    then
   160         -        echo "The prepare step has to be run as $nu."
   161         -        echo
   162         -        exit 1
   163         -    fi
   164         -
   165         -    set -x
   166         -
   167         -    history -c ; rm -f ~/.bash_history
   168         -
   169         -    pidp8i stop || true                         # avoid sim hogging CPU
   170         -    sudo systemctl enable ssh || true           # disabled by default
   171         -    sudo shred -u /etc/ssh/*key* || true        # allow multiple passes
   172         -    sudo dphys-swapfile uninstall || true
   173         -    sudo dd if=/dev/zero of=/junk bs=1M || true # it *will* error-out!
   174         -    sudo rm -f /junk
   175         -
   176         -    encpass=$(openssl passwd -1 edsonDeCastro1968)
   177         -    sudo usermod -p $encpass pidp8i
   178         -    sudo passwd -e pidp8i
   179         -
   180         -    cl=/boot/cmdline.txt
   181         -    if ! grep -Fq ' init=' $cl
   182         -    then
   183         -        sudo sed -i -e 's#$# init=/usr/lib/raspi-config/init_resize.sh#' $cl
   184         -    fi
   185         -
   186         -    do_wait "Powering off"
   187         -    sudo poweroff
   188         -}
   189         -
   190         -
   191         -# Shrink the filesystem on the OS SD card we're about to image to just a
           89  +# Shrink the filesystem on the SD card we're about to image to just a
   192     90   # bit bigger than required to hold its present contents.
   193     91   #
   194     92   # The extra 100 megs in the arithmetic below accounts for the /boot
   195     93   # partition, since the `resizepart` command takes a partition end value,
   196     94   # not a size value.
   197     95   #
   198     96   # We don't calculate the actual end of the /boot partition and use that
   199     97   # value because we want a bit of slack space to buy time for an end user
   200     98   # who neglects to expand the card image into the free space available on
   201     99   # their SD card after first boot.
   202    100   function do_shrink() {
   203         -    test "$USER" = "root" || exec sudo $this shrink
   204         -
   205         -    set -x
   206         -
   207         -    umount /dev/sda2 || true    # might auto-mount, might not
   208         -    e2fsck -f /dev/sda2         # resize2fs demands it
   209         -
   210         -    # Pack it down tight
   211         -    blocks=$(
   212         -        resize2fs -M /dev/sda2 2>&1 |
   213         -        grep 'blocks long' | 
   214         -        grep -wo '[0-9]\+'
   215         -    )
   216         -    if [ "$blocks" -gt 0 ]
   217         -    then
   218         -        # And now give it a bit of breathing room
   219         -        parted /dev/sda resizepart 2 $(($blocks * 4096 + 10**8))b
   220         -        resize2fs /dev/sda2
   221         -        poweroff
   222         -    else
   223         -        echo "Failed to extract new filesystem size from resize2fs!"
   224         -        echo
   225         -        exit 1
   226         -    fi
          101  +	test "$USER" = "root" || exec sudo $this shrink $object
          102  +
          103  +	umount /dev/sda2 || true	# might auto-mount, might not
          104  +	e2fsck -f /dev/sda2			# resize2fs demands it
          105  +	blocks=$(
          106  +		resize2fs -M /dev/sda2 2>&1 |
          107  +		grep 'blocks long' | 
          108  +		grep -wo '[0-9]\+'
          109  +	)
          110  +	if [ "$blocks" -gt 0 ]
          111  +	then
          112  +		parted /dev/sda resizepart 2 $(($blocks * 4096 + 10**8))b
          113  +		blocks=$(
          114  +			resize2fs /dev/sda2 2>&1 |
          115  +			grep 'blocks long' | 
          116  +			grep -wo '[0-9]\+'
          117  +		)
          118  +
          119  +		cat <<NEXT
          120  +Move the USB SD card reader to the desktop machine and resume the
          121  +process with
          122  +
          123  +    bosi image $blocks
          124  +
          125  +NEXT
          126  +	else
          127  +		echo "Failed to extract new filesystem size from resize2fs!"
          128  +		echo
          129  +		exit 1
          130  +	fi
   227    131   }
   228    132   
   229    133   
   230         -# This script images the OS SD card in a USB reader on a Mac OS X box.
          134  +# This script images the SD card in a USB reader on a Mac OS X box.
   231    135   function do_image() {
   232         -    dev=UNKNOWN
   233         -    ps=UNKNOWN
   234         -    hb=no
   235         -    rp=UNKNOWN
   236         -
   237         -    while read line
   238         -    do
   239         -        case $line in
   240         -            /dev/*)
   241         -                dev=$(echo $line | cut -f1 -d' ')
   242         -                ;;
          136  +	if [ -n "$object" ]
          137  +	then
          138  +		sudo diskutil unmountDisk $rdisk		# it auto-mounted
          139  +		sudo dd if=$rdisk bs=4k count=$object of=$img
          140  +		zip -9j $img.zip $img
   243    141   
   244         -            0:*)
   245         -                case $line in
   246         -                    *FDisk_partition_scheme*) ps=fdisk ;;
   247         -                    *) dev= ;;      # can't be the OS SD card
   248         -                esac
   249         -                ;;
   250         -
   251         -            1:*)
   252         -                case $line in
   253         -                    *Windows_FAT_32\ boot*) hb=yes ;;
   254         -                    *) dev= ;;      # can't be the OS SD card
   255         -                esac
   256         -                ;;
   257         -
   258         -            2:*)
   259         -                case $line in
   260         -                    *Linux*) rp=Linux ; break ;; # found it!
   261         -                    *) dev= ;;      # can't be the OS SD card
   262         -                esac
   263         -                ;;
   264         -        esac
   265         -    done < <(diskutil list)
   266         -
   267         -    if [ -z "$dev" ]
   268         -    then
   269         -        cat <<MSG
   270         -Failed to find OS SD card!  I learned the following, though:
   271         -
   272         -    SD /dev node:     $dev
   273         -    Partition scheme: $ps
   274         -    Has /boot:        $hb
   275         -    /root partition:  $rp
   276         -
   277         -MSG
   278         -        exit 1
   279         -    fi
   280         -
   281         -    echo
   282         -    echo "-------------------------------------------------------"
   283         -    diskutil info "$dev"
   284         -    echo "-------------------------------------------------------"
   285         -    echo
   286         -    read -p "Is that the OS SD card? [y/N]: " answer
   287         -    case $answer in
   288         -        [Yy]*) ;;
   289         -        *) exit 1
   290         -    esac
   291         -
   292         -    rdev=${dev/disk/rdisk}              # speeds zeroing and re-imaging
   293         -
   294         -    mf=/tmp/MANIFEST.txt
   295         -    readme=/tmp/README.md
   296         -    cp "$topdir/doc/OS-images.md" $readme
   297         -
   298         -    set -x
   299         -
   300         -    diskutil unmountDisk $dev           # it auto-mounted
   301         -    sudo time dd if=$rdev bs=1m of=$img
   302         -    sum=($(shasum -a 256 "$img"))
   303         -    bytes=($(wc -c $img))
   304         -
   305         -    cat > $mf <<MF
   306         -SHA-256 hash and size of ${sum[1]}:
   307         -
   308         -Hash:  ${sum[0]}
   309         -Size:  ${bytes[0]}
   310         -MF
   311         -
   312         -    imgdir="$(dirname "$img")"
   313         -    sed -i '' -e "s_$imgdir/__" "$mf"   # nix local paths in manifest
   314         -    unix2dos $mf                        # might be opened on Windows
   315         -    time zip -9j $img.zip $img $mf $readme
   316         -    rm -f $mf $readme
   317         -
   318         -    # Now re-image the card, starting with a zeroed card to ensure a
   319         -    # clean test.  Ignore the end-of-device error from the zero step.
   320         -    sudo time dd if=/dev/zero of=$rdev bs=1m || true
   321         -    sudo time dd if=$img of=$rdev bs=1m
   322         -    diskutil unmountDisk $dev || true   # Paragon ExtFS might be installed
          142  +		sudo dd if=$img of=$rdisk bs=1m
          143  +		sudo diskutil unmountDisk $rdisk || true	# Paragon ExtFS might be installed
          144  +	else
          145  +		usage
          146  +	fi
   323    147   }
   324    148   
   325    149   
   326    150   # Clean up after the above
   327    151   function do_finish() {
   328         -    set -x
          152  +	rmtrash $img
          153  +	cd $dldir/..
          154  +	make synch
          155  +}
          156  +
          157  +
          158  +# Display the usage message
          159  +function usage() {
          160  +	cat <<USAGE
          161  +usage: $0 <verb[-tag]> [object]
          162  +
          163  +    The available verbs are init, fossil, shrink, image, and finish.
          164  +
          165  +    You may append a tag to the image and finish verbs (e.g. image-nls)
          166  +    to override the default tag ('all') used in image and zip file
          167  +    outputs.
          168  +
          169  +    The object depends on the verb.  See RELEASE-PROCESS.md.
   329    170   
   330         -    trash $img
   331         -    cd $dldir/..
   332         -    make synch
          171  +USAGE
          172  +	exit 1
   333    173   }
   334    174   
   335    175   
   336    176   # Main routine
   337    177   set -e
   338    178   case "$verb" in
   339         -    in*) do_init ;;
   340         -    bu*) do_build ;;
   341         -    pr*) do_prepare ;;
   342         -    sh*) do_shrink ;;
   343         -    im*) do_image ;;
   344         -    fi*) do_finish ;;
   345         -    *)   usage ;;
          179  +	in*) do_init ;;
          180  +	fo*) do_fossil ;;
          181  +	re*) do_reset ;;
          182  +	sh*) do_shrink ;;
          183  +	im*) do_image ;;
          184  +	fi*) do_finish ;;
          185  +	*)   usage ;;
   346    186   esac