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












1
2
3
4
5
6
7
8
9



10 FOR I = 1 TO 999
20 A = I / 3 \ B = I / 5
30 IF INT(A) = A GOTO 60
40 IF INT(B) = B GOTO 60
50 GOTO 70
60 T = T + I
70 NEXT I
80 PRINT "TOTAL: "; T
90 END

Changes to tools/bosi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112


113
114
115


116
117
118
119

120
121
122
123
124
125
126


127
128

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

220
221











222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267

268
269
270



271
272
273
274
275
276
277
278




279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296





297
298
299
300
301
302
303
304
305
306




307
308
309
310

311
312
313
314
315
316



317
318
319
320
321
322

323
324
325
326
327
328
329
330
331
332


333
334
335
336
337
338
339
340
341
342
343
344
345
346
#!/bin/bash
# bosi - The Binary OS Image creation/update script
#
# Copyright © 2016-2017 by Warren Young
# 
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS LISTED ABOVE BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# 
# Except as contained in this notice, the names of the authors above shall
# not be used in advertising or otherwise to promote the sale, use or
# other dealings in this Software without prior written authorization from
# those authors.


# Display the usage message
function usage() {
    cat <<USAGE
usage: $0 <verb> [tag]

    The available verbs are init, build, prepare, shrink, image, and finish.

    You may include a tag parameter with the 'image' and 'finish' verbs
    to override the default tag ('ils') used in image and zip file
    outputs.

    See RELEASE-PROCESS.md for more info.

USAGE
    exit 1
}

verb="$1"
tag="$2"
test -n "$verb" || usage


test -z "$tag" && tag=ils

nu=pidp8i
nh=/home/$nu
repo=pidp8i
dldir="$HOME/tangentsoft.com/dl"
os=stretch-lite
img=$dldir/pidp8i-$(date +%Y.%m.%d)-$tag-$os.img

greadlink=$(type -p greadlink || type -p readlink)
this=$($greadlink -f $0)
topdir="$($greadlink -f "$(dirname "$this")"/..)"


# Give user a few seconds to read the final messages before rebooting or
# powering off.
function do_wait() {
    n=8
    cat <<MSG
    
$1 in $n seconds...


MSG
    sleep $n
}


# Initial steps
function do_init() {


    if [ "$USER" != "root" ]
    then
        echo "The init step has to be run as root.  The explanation is"
        echo "given in the section for 'init' in RELEASE-PROCESS.md."
        echo
        exit 1
    fi

    set -x

    apt-get update && apt-get -y upgrade || true

    apt-get install python-pip || true
    pip install pexpect

    test -f /usr/include/curses.h || apt-get -y install libncurses-dev

    if [ -z "$(type -p fossil)" ]
    then
        fb=/usr/local/bin/fossil
        src=https://tangentsoft.com/pidp8i/uv/fossil-2.8-raspbian-9.6-stretch
        wget -O $fb $src
        chmod +x $fb
        apt-get -y install libssl-dev    # user might rebuild Fossil later
    fi

    if [ ! -e "$nh" ]
    then
        # First pass on a clean SD card: rename 'pi' user and group to
        # 'pidp8i' and rename its home directory to match.
        pkill -u pi
        usermod  -l $nu -d $nh -m pi 
        groupmod -n $nu pi


    fi

    reboot


}


# Clone repo and build the software under [new] pidp8i account

function do_build() {
    if [ "$USER" != "$nu" ]
    then
        echo "The build step has to be run as $nu."
        echo
        exit 1
    fi



    set -x


    if [ ! -d museum ]
    then
        mkdir -p museum $repo
        fossil clone https://tangentsoft.com/$repo museum/$repo.fossil
    fi

    cd $repo

    if [ -r ChangeLog.md ]
    then
        fossil revert           # just in case
        fossil update release
    else
        fossil open ~/museum/$repo.fossil release
        fossil set autosync pullonly
        ./configure
    fi

    tools/mmake
    bin/teco-pi-demo -b             # test and benchmark simulator
    sudo make install || true       # don't care about return code
    do_wait "Rebooting"
    sudo reboot
}


# This script prepares the OS's configuration to a clean first boot state.
function do_prepare() {
    if [ "$USER" != "$nu" ]
    then
        echo "The prepare step has to be run as $nu."
        echo
        exit 1
    fi

    set -x

    history -c ; rm -f ~/.bash_history


    pidp8i stop || true                         # avoid sim hogging CPU
    sudo systemctl enable ssh || true           # disabled by default
    sudo shred -u /etc/ssh/*key* || true        # allow multiple passes
    sudo dphys-swapfile uninstall || true
    sudo dd if=/dev/zero of=/junk bs=1M || true # it *will* error-out!
    sudo rm -f /junk

    encpass=$(openssl passwd -1 edsonDeCastro1968)
    sudo usermod -p $encpass pidp8i
    sudo passwd -e pidp8i

    cl=/boot/cmdline.txt
    if ! grep -Fq ' init=' $cl
    then
        sudo sed -i -e 's#$# init=/usr/lib/raspi-config/init_resize.sh#' $cl
    fi

    do_wait "Powering off"
    sudo poweroff
}


# Shrink the filesystem on the OS SD card we're about to image to just a
# bit bigger than required to hold its present contents.
#
# The extra 100 megs in the arithmetic below accounts for the /boot
# partition, since the `resizepart` command takes a partition end value,
# not a size value.
#
# We don't calculate the actual end of the /boot partition and use that
# value because we want a bit of slack space to buy time for an end user
# who neglects to expand the card image into the free space available on
# their SD card after first boot.
function do_shrink() {
    test "$USER" = "root" || exec sudo $this shrink

    set -x

    umount /dev/sda2 || true    # might auto-mount, might not
    e2fsck -f /dev/sda2         # resize2fs demands it

    # Pack it down tight
    blocks=$(
        resize2fs -M /dev/sda2 2>&1 |
        grep 'blocks long' | 
        grep -wo '[0-9]\+'
    )
    if [ "$blocks" -gt 0 ]
    then
        # And now give it a bit of breathing room
        parted /dev/sda resizepart 2 $(($blocks * 4096 + 10**8))b

        resize2fs /dev/sda2
        poweroff











    else
        echo "Failed to extract new filesystem size from resize2fs!"
        echo
        exit 1
    fi
}


# This script images the OS SD card in a USB reader on a Mac OS X box.
function do_image() {
    dev=UNKNOWN
    ps=UNKNOWN
    hb=no
    rp=UNKNOWN

    while read line
    do
        case $line in
            /dev/*)
                dev=$(echo $line | cut -f1 -d' ')
                ;;

            0:*)
                case $line in
                    *FDisk_partition_scheme*) ps=fdisk ;;
                    *) dev= ;;      # can't be the OS SD card
                esac
                ;;

            1:*)
                case $line in
                    *Windows_FAT_32\ boot*) hb=yes ;;
                    *) dev= ;;      # can't be the OS SD card
                esac
                ;;

            2:*)
                case $line in
                    *Linux*) rp=Linux ; break ;; # found it!
                    *) dev= ;;      # can't be the OS SD card
                esac
                ;;
        esac
    done < <(diskutil list)

    if [ -z "$dev" ]

    then
        cat <<MSG
Failed to find OS SD card!  I learned the following, though:




    SD /dev node:     $dev
    Partition scheme: $ps
    Has /boot:        $hb
    /root partition:  $rp

MSG
        exit 1




    fi

    echo
    echo "-------------------------------------------------------"
    diskutil info "$dev"
    echo "-------------------------------------------------------"
    echo
    read -p "Is that the OS SD card? [y/N]: " answer
    case $answer in
        [Yy]*) ;;
        *) exit 1
    esac

    rdev=${dev/disk/rdisk}              # speeds zeroing and re-imaging

    mf=/tmp/MANIFEST.txt
    readme=/tmp/README.md
    cp "$topdir/doc/OS-images.md" $readme






    set -x

    diskutil unmountDisk $dev           # it auto-mounted
    sudo time dd if=$rdev bs=1m of=$img
    sum=($(shasum -a 256 "$img"))
    bytes=($(wc -c $img))

    cat > $mf <<MF
SHA-256 hash and size of ${sum[1]}:





Hash:  ${sum[0]}
Size:  ${bytes[0]}
MF


    imgdir="$(dirname "$img")"
    sed -i '' -e "s_$imgdir/__" "$mf"   # nix local paths in manifest
    unix2dos $mf                        # might be opened on Windows
    time zip -9j $img.zip $img $mf $readme
    rm -f $mf $readme




    # Now re-image the card, starting with a zeroed card to ensure a
    # clean test.  Ignore the end-of-device error from the zero step.
    sudo time dd if=/dev/zero of=$rdev bs=1m || true
    sudo time dd if=$img of=$rdev bs=1m
    diskutil unmountDisk $dev || true   # Paragon ExtFS might be installed

}


# Clean up after the above
function do_finish() {
    set -x

    trash $img
    cd $dldir/..
    make synch


}


# Main routine
set -e
case "$verb" in
    in*) do_init ;;
    bu*) do_build ;;
    pr*) do_prepare ;;
    sh*) do_shrink ;;
    im*) do_image ;;
    fi*) do_finish ;;
    *)   usage ;;
esac
|

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

|
<
>
>
|





|

>


<


<
<
<
<
<
<
<
<
<
<
<
<
<
<


>
>
|
|
|
|
|
|
|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
|
|
>
>
|

<
>
>



<
>
|
<
<
<
<
<
<
>
>

<
>

|
|
|
|
|

|

|
|
|
|
|
|
<
|
|

|
<
|
<
|



|
|
<
<
<
<
<
<
<
<
<
|
>

<
<
|
|
|
|
<
<
<
|
<
<
<
<
<
<
<
<
|



|











|

<
<
|
|
<
<
|
|
|
|
|
|
|
<
|
>
|
<
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|



|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|
<
<
>
>
>

<
<
<
<
<
<
<
>
>
>
>
|
|
<
<
<
<
<
<
<
<
<
<

<

<
<
<
>
>
>
>
>
|
<

<
<
<
<

<
<
>
>
>
>

<
<
<
>

<
<
<
<
<
>
>
>

<
<
<
<
<
>
|
<
<
<
<
<
<
<
<
<
>
>






|
|
|
|
|
|
|

1
2
3












































4
5

6
7
8
9
10
11
12
13
14
15
16
17
18

19
20














21
22
23
24
25
26
27
28
29
30
31
32














33








34
35
36
37
38
39

40
41
42
43
44

45
46






47
48
49

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

66
67
68
69

70

71
72
73
74
75
76









77
78
79


80
81
82
83



84








85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102


103
104


105
106
107
108
109
110
111

112
113
114

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135




































136
137


138
139
140
141







142
143
144
145
146
147










148

149



150
151
152
153
154
155

156




157


158
159
160
161
162



163
164





165
166
167
168





169
170









171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash -x
# bosi - The Binary OS Image creation/update script













































verb="$1"
object="$2"


tag=$(echo $verb | cut -f2 -d- -s)
test -z "$tag" && tag=all

nu=pidp8i
nh=/home/$nu
repo=pidp8i
dldir="$HOME/tangentsoft.com/dl"
os=jessie-lite
img=$dldir/pidp8i-$(date +%Y.%m.%d)-$tag-$os.img
rdisk=/dev/rdisk10
greadlink=$(type -p greadlink || type -p readlink)
this=$($greadlink -f $0)

















# Initial steps
function do_init() {
	if ! getent passwd $nu > /dev/null
	then
		if [ "$USER" != "root" ]
		then
			echo "The init step has to be run as root."
			echo "See RELEASE-PROCESS.md."
			echo
			exit 1
		fi















		usermod \








			-d $nh \
			-l $nu \
			-p $(openssl passwd -1 edsonDeCastro1968) \
			-m pi 
	fi


	sudo apt-get update && sudo apt-get -y upgrade || true
	do_fossil
}



# Fossil clone, build and install
function do_fossil() {






	test "$USER" = "root" && exec sudo -i -u $nu $nh/bosi fossil $object
	cd $HOME


	test -n "$(type -p fossil)" || sudo apt-get -y install fossil

	if [ ! -d museum ]
	then
		mkdir -p museum $repo
		fossil clone https://tangentsoft.com/$repo museum/$repo.fossil
	fi

	cd $repo

	if [ -r ChangeLog.md ]
	then
		fossil revert			# just in case
		fossil update $object
	else
		fossil open ~/museum/$repo.fossil $object

		./configure
	fi

	make -j4

	sudo make install || true

	sudo reboot
}


# This script resets the OS's configuration to a clean first boot state.
function do_reset() {









	history -c ; rm -f ~/.bash_history
	test "$USER" = "root" || exec sudo $this reset



	shred -u /etc/ssh/*key*
	dphys-swapfile uninstall
	dd if=/dev/zero of=/junk bs=1M || true		# it *will* error-out!
	rm /junk



	passwd -e pidp8i








	( sleep 1 ; poweroff ) & exit
}


# Shrink the filesystem on the SD card we're about to image to just a
# bit bigger than required to hold its present contents.
#
# The extra 100 megs in the arithmetic below accounts for the /boot
# partition, since the `resizepart` command takes a partition end value,
# not a size value.
#
# We don't calculate the actual end of the /boot partition and use that
# value because we want a bit of slack space to buy time for an end user
# who neglects to expand the card image into the free space available on
# their SD card after first boot.
function do_shrink() {
	test "$USER" = "root" || exec sudo $this shrink $object



	umount /dev/sda2 || true	# might auto-mount, might not
	e2fsck -f /dev/sda2			# resize2fs demands it


	blocks=$(
		resize2fs -M /dev/sda2 2>&1 |
		grep 'blocks long' | 
		grep -wo '[0-9]\+'
	)
	if [ "$blocks" -gt 0 ]
	then

		parted /dev/sda resizepart 2 $(($blocks * 4096 + 10**8))b
		blocks=$(
			resize2fs /dev/sda2 2>&1 |

			grep 'blocks long' | 
			grep -wo '[0-9]\+'
		)

		cat <<NEXT
Move the USB SD card reader to the desktop machine and resume the
process with

    bosi image $blocks

NEXT
	else
		echo "Failed to extract new filesystem size from resize2fs!"
		echo
		exit 1
	fi
}


# This script images the SD card in a USB reader on a Mac OS X box.
function do_image() {




































	if [ -n "$object" ]
	then


		sudo diskutil unmountDisk $rdisk		# it auto-mounted
		sudo dd if=$rdisk bs=4k count=$object of=$img
		zip -9j $img.zip $img








		sudo dd if=$img of=$rdisk bs=1m
		sudo diskutil unmountDisk $rdisk || true	# Paragon ExtFS might be installed
	else
		usage
	fi
}
















# Clean up after the above
function do_finish() {
	rmtrash $img
	cd $dldir/..
	make synch
}









# Display the usage message
function usage() {
	cat <<USAGE
usage: $0 <verb[-tag]> [object]




    The available verbs are init, fossil, shrink, image, and finish.






    You may append a tag to the image and finish verbs (e.g. image-nls)
    to override the default tag ('all') used in image and zip file
    outputs.






    The object depends on the verb.  See RELEASE-PROCESS.md.










USAGE
	exit 1
}


# Main routine
set -e
case "$verb" in
	in*) do_init ;;
	fo*) do_fossil ;;
	re*) do_reset ;;
	sh*) do_shrink ;;
	im*) do_image ;;
	fi*) do_finish ;;
	*)   usage ;;
esac