13 Commits
1.2.9 ... 1.3.1

5 changed files with 484 additions and 91 deletions

View File

@@ -358,6 +358,7 @@ if [[ -d /srv/A2SERVER/A2FILES && ! -d /srv/A2SERVER/.a2files ]]; then
mkdir /srv/A2SERVER/A2FILES
sudo sed -i 's/casefold:toupper //' /usr/local/etc/netatalk/AppleVolumes.default 2> /dev/null
sudo sed -i 's/^VOLCASEFOLD:.*/VOLCASEFOLD:/' /srv/A2SERVER/.a2files/.appledesktop/.volinfo 2> /dev/null
sudo sed -i 's|/media/A2SHARED/A2FILES|/srv/A2SERVER/A2FILES|' /srv/A2SERVER/.a2files/.appledesktop/.volinfo 2> /dev/null
fi
# 1.3.0: remove GSFILES if empty
@@ -380,7 +381,7 @@ fi
# set up A2FILES case-insensitive share (for ProDOS 8 files, and GS/OS system)
sudo sed -i \
's/^#share2/\/srv\/A2SERVER\/A2FILES\ A2FILES options:prodos\ ea:ad/' \
/usr/local/etc/netatalk/AppleVolumes.default
/usr/local/etc/netatalk/AppleVolumes.default
[[ -d /srv/A2SERVER/A2FILES ]] || mkdir -p /srv/A2SERVER/A2FILES
[[ -d /srv/A2SERVER/.a2files ]] || mkdir -p /srv/A2SERVER/.a2files
@@ -458,6 +459,8 @@ fi
# to make Netatalk start up when the server boots:
sudo update-rc.d netatalk defaults &> /dev/null
# prepare shared volumes for use
afpsync -v < /dev/null
# --- Setting up users

View File

@@ -9,12 +9,12 @@
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
*) scriptURL="${A2SERVER_SCRIPT_URL:-http://ivanx.com/a2server}/" ;;
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
*) scriptURL="${A2SERVER_SCRIPT_URL:-http://ivanx.com/a2server}/" ;;
esac
case "$A2SERVER_BINARY_URL" in
*/) binaryURL="$A2SERVER_BINARY_URL" ;;
*) binaryURL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files}/" ;;
*/) binaryURL="$A2SERVER_BINARY_URL" ;;
*) binaryURL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files}/" ;;
esac
useExternalURL=1
[[ $A2SERVER_NO_EXTERNAL ]] && useExternalURL=
@@ -36,28 +36,139 @@ adtproDir=$commDir/ADTPro
gsosURL="http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Apple_II/Apple_IIGS_System_6.0.1/"
gsosBackupURL="http://archive.org/download/download.info.apple.com.2012.11/download.info.apple.com.2012.11.zip/download.info.apple.com%2FApple_Support_Area%2FApple_Software_Updates%2FEnglish-North_American%2FApple_II%2FApple_IIGS_System_6.0.1%2F"
updateP8YearTables () {
# Geoff Body and Andrew Roughan helped Joseph Carter with this one
# Update ProDOS 8 year table (and spalsh date because may as well)
# Effectively, we're turning p8 into the 6.0.3 version here.
wd=$PWD
cd /usr/local/etc/netatalk/a2boot
echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="p8" bs=38 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="p8" bs=3958 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="ProDOS16 Image" bs=3110 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="ProDOS16 Image" bs=7030 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=79 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=7071 seek=1 conv=notrunc 2> /dev/null
cd "$wd"
# --- bashByter library routines
decToChar () {
# converts single-byte decimal value to equivalent character
# arg: decimal number from 0-255
# out: one character
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
[[ $1 ]] || return 11
[[ $2 ]] && return 8
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
# args are valid
echo -n -e "\x$(printf %02X "$1")"
}
charToDec () {
# converts single character to corresponding decimal value
# stdin OR arg: one character
# [arg overrides stdin; stdin is required for NUL (0) or LF (0x0A)]
# out: decimal value from 0-255
#exit: 8=extraneous arg, 9=invalid stdin,
# 11=missing stdin/arg, 21=invalid arg
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
# arg/stdin is potentially valid (additional check below)
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
# above line verifies that arg/stdin is valid
[[ ${#charX} -ne 2 ]] && { echo -n 0; return 0; }
echo -n "${charX:0:1}" | od -t u1 | \
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
}
# --- end bashByter
cpAD () {
# copy a file with its AppleDouble component in ./.AppleDouble
# arg1 = source path, # arg2 = destination directory (not filename)
cp -p "$1" "$2"
afpsync=
if [[ $1 == "-s" ]]; then
afpsync=1
shift
fi
arg1="$1"
[[ "$arg1" == *"/"* ]] || arg1="./$arg1"
cp -p "$arg1" "$2"
mkdir -p "$2"/.AppleDouble
cp -p "${1%/*}"/.AppleDouble/"${1##*/}" "$2"/.AppleDouble
[[ $3 == "-s" ]] && afpsync -v > /dev/null
cp -p "${arg1%/*}"/.AppleDouble/"${arg1##*/}" "$2"/.AppleDouble
[[ $afpsync ]] && afpsync -v > /dev/null
}
checkP8YearTables () {
updateP8YearTables -c $1
return $?
}
updateP8YearTables () {
# JC: Geoff Body and Andrew Roughan helped Joseph Carter with this one
# Update ProDOS 8 year table (and spalsh date because may as well)
# Effectively, we're turning p8 into the 6.0.2 or 6.0.3 version here.
#
# ID: updates the year tables for the Thunderclock driver in ProDOS 8;
# calculated from the day of week and date, as year is unavailable.
# accepts optional arguments for custom patches
# arg1 = year table, comma separated
# arg2 = date string for ProDOS splash screen in format "dd-Mmm-yy"
# OR for presets, arg1=602 or arg1=603, arg2 is empty
check=
if [[ $1 == "-c" ]]; then
check=1
shift
fi
patch1=""
patch2=""
if [[ $1 == "602" ]]; then
patch1=$(echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d")
patch2=$(echo -n -e "\xb2\xb2\xad\xca\xf5\xee\xad\xb1\xb5")
elif [[ $1 == "603" ]]; then
patch1=$(echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d")
patch2=$(echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5")
elif [[ $1 ]]; then # year table supplied as seven comma-separated values
for year in $(tr "," " " <<< $1); do
patch1=${patch1}$(echo -n -e "\x$(printf %02X $year)")
done
if [[ $2 ]]; then # splash screen date supplied, convert to high-ascii bytes
for c in $(sed "s/./& /g" <<< $2); do
patch2=${patch2}$(decToChar $(( $(charToDec $c) + 128 )))
done
fi
fi
wd=$PWD
cd /usr/local/etc/netatalk/a2boot
files=("p8" "ProDOS16 Image" "Apple :2f:2fe Boot Blocks" "$gsosDir/System/P8")
offset1=(3958 7030 7071 3958) # splash screen date
offset2=(38 3110 79 38) # year table
i=0
if [[ $check ]]; then
# check if patched -- we're not actually doing this any more; we're always patching
patched=0 # 0 is true in this case since it's the return value
while (( $i < ${#files[@]} )); do
[[ ! -f "${files[$i]}" ]] && { (( i++ )); continue; }
if [[ ! $patch1 || $patch1 != $(sudo dd if="${files[$i]}" skip=${offset1[$i]} bs=1 count=7 2> /dev/null) ]]; then
patched=1 # 1 is false
break
fi
if [[ ! $patch2 || $patch2 != $(sudo dd if="${files[$i]}" skip=${offset2[$i]} bs=1 count=9 2> /dev/null) ]]; then
patched=1 # 1 is false
break
fi
(( i++ ))
done
else
# perform patch
while (( $i < ${#files[@]} )); do
[[ ! -f "${files[$i]}" ]] && { (( i++ )); continue; }
[[ $patch1 ]] && echo -n -e ${patch1} | sudo dd of="${files[$i]}" seek=${offset1[$i]} bs=1 conv=notrunc 2> /dev/null
[[ $patch2 ]] && echo -n -e ${patch2} | sudo dd of="${files[$i]}" seek=${offset2[$i]} bs=1 conv=notrunc 2> /dev/null
(( i++ ))
done
patched=0 # 0 is true
fi
return $patched
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="p8" bs=38 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="p8" bs=3958 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="ProDOS16 Image" bs=3110 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="ProDOS16 Image" bs=7030 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=79 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=7071 seek=1 conv=notrunc 2> /dev/null
cd "$wd"
}
# bail out on automated netboot setup unless -b is also specified
@@ -369,14 +480,23 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
fi
fi
if [[ ! $autoAnswerYes && gsosInstall -lt 2 ]]; then
echo
echo -n "Do you want to update the ProDOS 8 year tables? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
updateP8YearTables
fi
# if [[ ! $autoAnswerYes && (! $gsosInstall || $gsosInstall -lt 2) ]] && ! checkP8YearTables 603; then
# echo
# echo -n "Do you want to update the ProDOS 8 Thunderclock year tables? "
# read
# fi
# if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
# updateP8YearTables 603
# elif [[ $gsosInstall -ge 2 ]]; then
# updateP8YearTables 60${gsosInstall}
# fi
# patch ProDOS 8 Thunderclock driver year table based on today's date
echo
echo "A2SERVER: Updating ProDOS 8 Thunderclock driver year tables..."
mkdir -p /tmp/netboot
wget -qO /tmp/netboot/clock.patch.py "${scriptURL}scripts/clock.patch.py"
updateP8YearTables $(python /tmp/netboot/clock.patch.py $(LANG=C date +"%a %m/%d/%y"))
if [[ ! $autoAnswerYes ]]; then
echo
@@ -558,16 +678,19 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
if [[ -f $spectrumDir/Spectrum ]]; then
echo " is already installed."
else
mkdir -p $spectrumDir
echo
mkdir -p $spectrumDir
# remove images that might have been installed by 1.2.5
cd $spectrumDir
rm SPECTRUM.HDV MANUALS.HDV SOUNDS.HDV EXTRAS.HDV &> /dev/null
# install Spectrum into GS/OS
mkdir -p /tmp/netboot/spectrum
cd /tmp/netboot/spectrum
# install Spectrum into GS/OS
if [[ $useExternalURL ]]; then
wget -qO spectrum_gold_2mg.zip http://www.speccie.co.uk/speccie/software/spectrum_gold_2mg.zip
unzip -p spectrum_gold_2mg.zip 2> /dev/null | dd bs=64 skip=1 of=Spectrum.Gold.HDV 2> /dev/null
fi
if [[ ! -f Spectrum.Gold.2mg ]]; then
if [[ ! -f Spectrum.Gold.HDV || $(wc -c < Spectrum.Gold.HDV) -eq 0 ]]; then
wget -qO spectrum_gold_2mg.zip ${binaryURL}external/appleii/spectrum_gold_2mg.zip
unzip -p spectrum_gold_2mg.zip 2> /dev/null | dd bs=64 skip=1 of=Spectrum.Gold.HDV 2> /dev/null
fi
@@ -591,9 +714,69 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
mkdir -p $gsosDir/"${thisFolder##*^}"/.AppleDouble
cp -R Spectrum.Gold/${thisFolder%%^*}/.AppleDouble/* $gsosDir/"${thisFolder##*^}"/.AppleDouble
done
mv Spectrum.Gold/Installer/SoundPatch Spectrum.Gold/Spectrum.2.5.4/Spectrum $spectrumDir
mkdir -p $spectrumDir/.AppleDouble
mv Spectrum.Gold/Installer/.AppleDouble/SoundPatch Spectrum.Gold/Spectrum.2.5.4/.AppleDouble/Spectrum $spectrumDir/.AppleDouble
cpAD Spectrum.Gold/Installer/SoundPatch $spectrumDir
cpAD Spectrum.Gold/Spectrum.2.5.4/Spectrum $spectrumDir
afpsync -v $gsosDir > /dev/null
fi
echo -n "Marinetti 3.0b8"
if [[ -f $gsosDir/System/CDevs/TCPIP ]]; then
echo " is already installed."
else
echo
mkdir -p /tmp/netboot/marinetti
cd /tmp/netboot/marinetti
# Marinetti 3.0b1
wget -qO MarinettiB1.SHK ${binaryURL}appleii/MarinettiB1.SHK
cppo -ad -s -n MarinettiB1.SHK $gsosDir > /dev/null
# TCP/IP update (3.0b8)
if [[ $useExternalURL ]]; then
wget -qO Marinetti3.0b8.po http://www.a2retrosystems.com/downloads/Marinetti3.0b8.po
fi
if [[ $? != 0 || ! -f Marinetti3.0b8.po || $(wc -c < Marinetti3.0b8.po) != "819200" ]]; then
wget -qO Marinetti3.0b8.po ${binaryURL}external/appleii/Marinetti3.0b8.po
fi
cppo -ad Marinetti3.0b8.po /MARINETTI3.0B8/TCPIP $gsosDir/System/System.Setup > /dev/null
cppo -ad Marinetti3.0b8.po /MARINETTI3.0B8/CHANGELOG.3.0B8 $commDir/Marinetti > /dev/null
# PPP Scripted Link Layer update (1.3d4)
if [[ $useExternalURL ]]; then
wget -qO PPPX.1.3d4.SHK http://www.apple2.org/marinetti/PPPX.1.3d4.SHK
fi
if [[ $? != 0 || ! -f PPPX.1.3d4.SHK || $(wc -c < PPPX.1.3d4.SHK) != "22068" ]]; then
wget -qO PPPX.1.3d4.SHK ${binaryURL}external/appleii/PPPX.1.3d4.SHK
fi
cppo -ad -s PPPX.1.3d4.SHK . &> /dev/null
cd PPPX.1.3d4
cpAD PPP.scripted $gsosDir/System/TCPIP
cpAD PPP.Script.DOC $commDir/Marinetti/Documentation
mkdir -p $commDir/Marinetti/PPP.scripted
cpAD Connect.Script $commDir/Marinetti/PPP.scripted
cpAD ChangeLog $commDir/Marinetti/PPP.scripted
# Uthernet Link Layer
if [[ $useExternalURL ]]; then
wget -qO uthernetll.bxy http://www.speccie.co.uk/speccie/software/uthernetll.bxy
fi
if [[ $? != 0 || ! -f uthernetll.bxy || $(wc -c < uthernetll.bxy) -eq 0 ]]; then
wget -qO uthernetll.bxy ${binaryURL}external/appleii/uthernetll.bxy
fi
cppo -ad -s -n uthernetll.bxy $gsosDir/System/TCPIP > /dev/null
# Uthernet II Link Layer
if [[ $useExternalURL ]]; then
wget -qO uthernet2ll.bxy http://www.speccie.co.uk/speccie/software/uthernet2ll.bxy
fi
if [[ $? != 0 || ! -f uthernet2ll.bxy || $(wc -c < uthernet2ll.bxy) -eq 0 ]]; then
wget -qO uthernet2ll.bxy ${binaryURL}external/appleii/uthernet2ll.bxy
fi
cppo -ad -s -n uthernet2ll.bxy $gsosDir/System/TCPIP > /dev/null
# MacIP Link Layer settings for A2SERVER
wget -qO- ${binaryURL}macip-prefs.tgz | tar Pxz
afpsync -v $gsosDir > /dev/null
fi
fi
@@ -603,13 +786,13 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
if [[ -f $protermDir/PROTERM ]]; then
echo " are already installed."
else
echo
mkdir -p $protermDir
mkdir -p $protermDir/.AppleDouble
mkdir -p $zlinkDir
mkdir -p $zlinkDir/.AppleDouble
echo
cd /tmp/netboot
wget -qO A2CLOUD.HDV "${binaryURL}A2CLOUD.HDV"
wget -qO A2CLOUD.HDV "${binaryURL}appleii/A2CLOUD.HDV"
cppo -ad A2CLOUD.HDV . &> /dev/null
cd A2CLOUD
mv *PT3* *PROTERM* $protermDir
@@ -660,7 +843,7 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
# Farallon bridge patch for GS/OS courtesy of Geoff Body
echo "A2SERVER: Downloading Farallon bridge patch..."
wget -O /tmp/FARALLON.PO "${binaryURL}FARALLON.B1.PO" &> /dev/null
wget -qO /tmp/FARALLON.PO "${binaryURL}appleii/FARALLON.B1.PO" &> /dev/null
if [[ -d $gsosDir/SYSTEM/SYSTEM.SETUP ]]; then
cppo -s -ad /tmp/FARALLON.PO /ATALKPATCH/ATALKIRQ $gsosDir/SYSTEM/SYSTEM.SETUP &> /dev/null
echo

180
scripts/clock.patch.py Executable file
View File

@@ -0,0 +1,180 @@
#!/usr/bin/env python
'''CLOCK.PATCH by Greg Branche implemented in Python 2/3 for A2SERVER
This is a line-for-line conversion of an edited version of CLOCK.PATCH
from the System Tools 2 disk in GS/OS 6.0.1. It's not good Python,
but I thought it would be an interesting exercise. In general
I have tried replicate each line as closely to BASIC as possible.
Because BASIC substrings are 1-based and python's are 0-based, various
indexes are minus one of their BASIC equivalents.
The one change is that you can optionally pass the day and date by
command line argument (e.g "Wed 3/13/15"). I also improved error
checking. These are in the BASIC lines that don't end in 0.
Rather than modifying PRODOS, this outputs a string of comma-separated
year values for a calling script (the a2server-setup installer),
followed by a space and a dd-Mmm-yy date string.
'''
# imports for python 3 code compatibility
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import division
# other imports
import sys
import datetime
# substitute raw_input for input in Python2
try: input = raw_input
except NameError: pass
dow_str = None
day = None
if len(sys.argv) > 2:
dow_str = sys.argv[1] # day of week passed on command line
day = sys.argv[2] # date passed on command line
# 60000 REM # of days in each month
data = [31,28,31,30,31,30,31,31,30,31,30] # 60010 DATA 31,28,31,30,31,30,31,31,30,31,30
# 60020 REM Names of days of week
data += [ # 60030 DATA SUN,MON,TUE,WED,THU,FRI,SAT
"SUN","MON","TUE","WED","THU","FRI","SAT"]
data = iter(data)
# 110 REM cu() = cumulative # of days in year
cu = [0] * 13 # 120 DIM CU(12)
# 130 REM fill array with # of days in year
cu[1] = 0 # 140 CU(1) = 0: REM January
for i in range(2,13): # 150 FOR I = 2 TO 12
x = next(data) # 160 READ X
cu[i] = cu[i-1] + x # 170 CU(I) = CU(I - 1) + X
# 180 NEXT I
# 200 REM DN$() = Names for days of week
dn = [""] * 8 # 210 DIM DN$(7)
# 220 REM fill array with names of days of week
for i in range(1,8): # 230 FOR I = 1 TO 7
dn[i] = next(data) # 240 READ DN$(I)
# 250 NEXT I
# 270 REM yt() is the year table values
yt = [0] * 8 # 280 DIM YT(7)
def mod7(x): # 340 DEF FN MOD7(X) = INT (((X / 7) - INT (X / 7)) * 7 + .5)
return int(((x / 7) - int(x / 7)) * 7 + .5)
def find_slash_pos(day): # 799 REM Finds position of / within date string
x = -1 # 800 X = 0: REM On exit, contains position of /, or 0 if none found
for i in range(0,3): # 810 FOR I = 1 TO 3
if day[i:i+1] == "/": x = i; break # 820 IF MID$ (DAY$,I,1) = "/" THEN X = I:I = 3
# 830 NEXT I
return x # 840 RETURN
while True: # 999 REM get the user's input and convert
if not day:
print( # 1010 PRINT "Please enter today's date (mm/dd/yy)"
"Please enter today's date (mm/dd/yy)")
day = input("-> ") # 1020 INPUT "-> ";DAY$
x = find_slash_pos(day) # 1030 GOSUB 800: REM find slash separator
input_ok = False
while not input_ok:
if not (x != -1): # 1040 IF X < > 0 THEN 1080
print( # 1050 PRINT "Invalid date entered. Please try again."; CHR$ (7)
"Invalid date entered. Please try again.\x07")
break # 1060 GOTO 1010
# 1070 REM Convert month value to numeric variable
mo = int(day[0:0+x]) # 1080 MO = VAL ( MID$ (DAY$,1,X - 1))
day = day[x+1:] # 1090 DAY$ = MID$ (DAY$,X + 1)
if mo < 1 or mo > 12: x = -1; continue # 1100 IF MO < 1 OR MO > 12 THEN 1050: REM Range check the month value
x = find_slash_pos(day) # 1110 GOSUB 800: REM Parse out the current day
if x == -1: continue # 1120 IF X = 0 THEN 1050
# 1130 REM Convert day string into numeric value
da = int(day[0:0+x]) # 1140 DA = VAL ( MID$ (DAY$,1,X - 1))
day = day[x+1:] # 1150 DAY$ = MID$ (DAY$,X + 1)
if da < 1 or da > 31: x = -1; continue # 1160 IF DA < 1 OR DA > 31 THEN 1050: REM Range check the day value
if mo == 2 and da > 29: # 1161 IF MO = 2 AND DA > 29 THEN 1050
x = -1; continue
if (mo == 4 or # 1162 IF (MO = 4 OR MO = 6 OR MO = 9 OR MO = 11) AND DA > 30 THEN 1050
mo == 6 or
mo == 9 or
mo == 11): x = -1; continue
# 1170 REM Convert year string into numeric value
yr = int(day) # 1180 YR = VAL (DAY$)
if yr < 0 or yr > 99: x = -1; continue # 1190 IF YR < 0 OR YR > 99 THEN 1050: REM Only allow 0-99
if yr > 39: yr = yr + 1900 # 1200 IF YR > 39 THEN YR = YR + 1900: REM 40-99 must be 1940-1999
if yr < 40: yr = yr + 2000 # 1210 IF YR < 40 THEN YR = YR + 2000: REM 0-39 must be 2000-2039
if ((yr / 4) != int(yr / 4) and # 1211 IF ((YR / 4) < > INT(YR / 4)) AND MO = 2 AND DA > 28 THEN 1050
mo == 2 and
da > 28): x = -1; continue
input_ok = True
if x != -1: break
else: dow_str = ""; day = ""
while True:
if not dow_str:
print(
"Please enter the day of the week") # 1230 PRINT "Please enter the day of the week"
dow_str = input("(e.g. Wed) -> ") # 1240 INPUT "(e.g. Wed) -> ";DOW$
input_ok = False
while not input_ok:
if not (len(dow_str) >= 3): # 1250 IF LEN (DOW$) > = 3 THEN 1270: REM Must be at least 3 characters
print( # 1260 PRINT "Invalid day of week. Please try again."; CHR$ (7): GOTO 1230
"Invalid day of week. Please try again.\x07")
break
if len(dow_str) > 3: # 1270 IF LEN (DOW$) > 3 THEN DOW$ = LEFT$ (DOW$,3)
dow_str = dow_str[0:0+3]
# 1280 REM Shift any lower case letters to upper case
b = "" # 1290 B$ = ""
for i in range(0,3): # 1300 FOR I = 1 TO 3
a = dow_str[i:i+1] # 1310 A$ = MID$ (DOW$,I,1)
if ( # 1320 IF ASC (A$) > = ASC ("a") AND ASC (A$) < = ASC ("z") THEN A$ = CHR$ ( ASC (A$) - ( ASC ("a") - ASC ("A")))
ord(a) >= ord("a") and ord(a) <= ord("z")): a = chr(ord(a) - (ord("a") - ord("A")))
b = b + a # 1330 B$ = B$ + A$
# 1340 NEXT I
dow_str = b # 1350 DOW$ = B$
# 1360 REM Now convert day-of-week string to numeric value
dow_num = 0 # 1370 DOW = 0
for i in range (1,8): # 1380 FOR I = 1 TO 7
if dow_str == dn[i]: # 1390 IF DOW$ = DN$(I) THEN DOW = I:I = 7
dow_num = i; i = 7
# 1400 NEXT I
if dow_num == 0: dow_str = ""; continue # 1410 IF DOW = 0 THEN 1260
input_ok = True
if len(dow_str) >= 3: break
else: dow_str = ""; day = ""
# 1430 REM Calculate the number of days so far this year
dys = da + cu[mo] # 1440 DYS = DA + CU(MO)
oyr = yr
# 1450 REM Must account for extra day in leap year
if ((yr / 4) == int(yr / 4)) and (mo > 2): # 1460 IF (YR / 4) = INT (YR / 4) AND MO > 2 THEN DYS = DYS + 1
dys = dys + 1
# 1480 REM Now calculate the index to use to fill in the table
idx = dow_num - mod7(dys) + 1 # 1490 IDX = DOW - FN MOD7(DYS) + 1
idx = abs(idx - 10) # 1500 IDX = ABS (IDX - 10)
if idx > 7: idx = idx - 7 # 1510 IF IDX > 7 THEN IDX = IDX - 7
# 1530 REM Now we can fill in the year table
for i in range(1,8): # 1540 FOR I = 1 TO 7
if '_i' in vars() and i < (_i + 1): continue # python: simulate change of i within loop
x = yr - 1900 # 1550 X = YR - 1900
if x >= 100: x = x - 100 # 1560 IF X > = 100 THEN X = X - 100
yt[idx] = x # 1570 YT(IDX) = X: REM store the year into table
idx = idx - 1 # 1580 IDX = IDX - 1
if idx < 1: idx = 7 # 1590 IF IDX < 1 THEN IDX = 7
if not ((yr / 4) != int(yr / 4)): # 1600 IF (YR / 4) < > INT (YR / 4) THEN 1660: REM not a leap year
i = i + 1; _i = i # 1610 I = I + 1: REM update index
if i > 7: continue # 1620 IF I > 7 THEN 1670: REM if entire array done, exit
yt[idx] = x # 1630 YT(IDX) = X: REM duplicate entry for leap year
idx = idx - 1 # 1640 IDX = IDX - 1
if idx < 1: idx = 7 # 1650 IF IDX < 1 THEN IDX = 7
yr = yr + 1 # 1660 YR = YR + 1
# 1670 NEXT I
print(",".join([str(x) for x in yt[1:]]) + " " +
str(da).encode("L1").decode("L1").zfill(2) + "-" +
datetime.date(1900, mo, 1).strftime('%b') + "-" +
str(oyr).encode("L1").decode("L1")[2:])

View File

@@ -2,12 +2,11 @@
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=python:
"""cppo: Copy/catalog files from a ProDOS/DOS 3.3/ShrinkIt image/archive.
copy all files:
cppo [options] imagefile target_directory
copy one file:
cppo [options] imagefile /extract/path target_path
catalog image:
cppo -cat [options] imagefile
copy all files: cppo [options] imagefile target_directory
copy one file : cppo [options] imagefile /extract/path target_path
catalog image : cppo -cat [options] imagefile
options:
-shk: ShrinkIt archive as source (also auto-enabled by filename).
-ad : Netatalk-compatible AppleDouble metadata files and resource forks.
@@ -20,9 +19,9 @@ options:
"MY FILENAME" (DOS 3.3 image source)
Dir:SubDir:FileName (ShrinkIt archive source)
+ after a file name indicates a GS/OS or Mac OS extended (forked) file.
Wildcard matching (*) is not supported and images are not validated.
ShrinkIt support requires Nulib2. cppo requires Python 2.6+ or 3.0+.
"""
ShrinkIt support requires Nulib2. cppo requires Python 2.6+ or 3.0+."""
# cppo by Ivan X, ivan@ivanx.com, ivanx.com/appleii
@@ -75,14 +74,15 @@ g.imageFile = None
g.extractFile = None
# runtime options
g.AD = 0 # -ad (AppleDouble headers + resource forks)
g.EX = 0 # -e (extended filenames + resource forks)
g.DIR = 0 # -cat (catalog only, no extract)
g.UC = 0 # -uc (GS/OS mixed case filenames extract as uppercase)
g.SHK = 0 # -shk (ShrinkIt archive source)
g.D33 = 0 # (DOS 3.3 image source, selected automatically)
g.PNAME = 0 # -pro (adapt DOS 3.3 names to ProDOS)
g.nomsg = 0 # -s (suppress afpsync message at end)
g.AD = 0 # -ad (AppleDouble headers + resource forks)
g.EX = 0 # -e (extended filenames + resource forks)
g.CAT = 0 # -cat (catalog only, no extract)
g.UC = 0 # -uc (GS/OS mixed case filenames extract as uppercase)
g.SHK = 0 # -shk (ShrinkIt archive source)
g.PNAME = 0 # -pro (adapt DOS 3.3 names to ProDOS)
g.nomsg = 0 # -s (suppress afpsync message at end)
g.nodir = 0 # -n (don't create parent dir for SHK, extract files in place)
g.D33 = 0 # (DOS 3.3 image source, selected automatically)
# functions
@@ -489,14 +489,16 @@ def processDir(arg1, arg2=None, arg3=None, arg4=None, arg5=None):
g.DIRPATH = (g.DIRPATH + "/" + workingDirName)
if g.PDOSPATH_INDEX:
if (g.PDOSPATH_INDEX == 1):
if (("/" + g.PDOSPATH_SEGMENT) != g.DIRPATH):
if (("/" + g.PDOSPATH_SEGMENT.lower()) !=
g.DIRPATH.lower()):
print("ProDOS volume name does not match disk image.")
sys.exit(2)
else:
g.PDOSPATH_INDEX += 1
g.PDOSPATH_SEGMENT = g.PDOSPATH[g.PDOSPATH_INDEX]
else:
print(g.DIRPATH)
pass
# print(g.DIRPATH)
while (pe < entryCount):
if (getStorageType(arg1, e) > 0):
#print(pe, e, entryCount)
@@ -527,6 +529,8 @@ def processEntry(arg1, arg2):
g.outFileData = bytearray(b'')
if g.SHK: # ShrinkIt archive
g.activeFileName = (arg2 if g.EX else arg2.split('#')[0])
if g.UC:
g.activeFileName = g.activeFileName.upper()
origFileName = g.activeFileName
else: # ProDOS or DOS 3.3 image
g.activeFileName = getFileName(arg1 ,arg2).decode("L1")
@@ -537,15 +541,15 @@ def processEntry(arg1, arg2):
if (not g.PDOSPATH_INDEX or
g.activeFileName.upper() == g.PDOSPATH_SEGMENT.upper()):
# if ProDOS directory, not file
if (not g.SHK and getStorageType(arg1, arg2) == 13):
if not g.PDOSPATH_INDEX:
g.targetDir = (g.targetDir + "/" + g.activeFileName)
g.ADdir = (g.targetDir + "/.AppleDouble")
if not (g.DIR or os.path.isdir(g.targetDir)):
if not (g.CAT or os.path.isdir(g.targetDir)):
makedirs(g.targetDir)
if not (g.DIR or (not g.AD) or os.path.isdir(g.ADdir)):
if not (g.CAT or (not g.AD) or os.path.isdir(g.ADdir)):
makedirs(g.ADdir)
if g.PDOSPATH_SEGMENT:
g.PDOSPATH_INDEX += 1
@@ -556,17 +560,24 @@ def processEntry(arg1, arg2):
g.targetDir = g.targetDir.rsplit("/", 1)[0]
g.ADdir = (g.targetDir + "/.AppleDouble")
else: # ProDOS or DOS 3.3 file either from image or ShrinkIt archive
dirPrint = ""
if g.DIRPATH:
dirPrint = g.DIRPATH + "/"
else:
if g.SHK:
if ("/".join(dirName.split('/')[3:])):
dirPrint = ("/".join(dirName.split('/')[3:]) + "/")
if (not g.extractFile or
(os.path.basename(g.extractFile) ==
origFileName.split('#')[0])):
print(" " + g.activeFileName.split("#")[0] +
(os.path.basename(g.extractFile.lower()) ==
origFileName.split('#')[0].lower())):
print(dirPrint + g.activeFileName.split("#")[0] +
("+" if (g.shk_hasrf or
(not g.SHK and getStorageType(arg1, arg2) == 5))
else "") +
((" [" + origFileName + "] ")
if (g.PNAME and (origFileName != g.activeFileName))
else ""))
if g.DIR:
if g.CAT:
return
if not g.targetName:
g.targetName = g.activeFileName
@@ -616,7 +627,9 @@ def processEntry(arg1, arg2):
if (g.exFileData != None):
saveFile((saveName + "r"), g.exFileData)
touch((saveName + "r"), modifiedDate)
if g.PDOSPATH_SEGMENT or (g.extractFile == origFileName):
if (g.PDOSPATH_SEGMENT or
(g.extractFile and
(g.extractFile.lower() == origFileName.lower()))):
syncExit()
g.targetName = None
#else:
@@ -1080,22 +1093,26 @@ def isnumber(number):
args = sys.argv
while True: # breaks when there are no more arguments starting with dash
if (len(args) == 1):
usage()
if (slyce(args[1],0,1) != "-"):
break
if (args[1] == "-s"):
g.nomsg = 1
args = args[1:] #shift
elif (args[1] == "-n"):
g.nodir = 1
args = args[1:] #shift
elif (args[1] == "-uc"):
g.UC = 1
args = args[1:] #shift
elif (args[1] == "-ad"):
if g.EX: usage()
g.AD = 1
g.PNAME = 1
args = args[1:] #shift
@@ -1109,21 +1126,25 @@ while True: # breaks when there are no more arguments starting with dash
args = args[1:] #shift
elif (args[1] == "-e"):
if g.AD: usage()
g.EX = 1
g.PNAME = 1
args = args[1:] #shift
elif (args[1] == "-cat"):
if g.AD or g.EX: usage()
g.DIR = 1
g.CAT = 1
args = args[1:] #shift
else:
usage()
if not ((g.DIR and len(args) >= 2) or (len(args) >= 3)):
usage()
if g.EX:
if g.AD: usage()
if g.AD:
if g.EX: usage()
if g.CAT:
if not (len(args) == 2): usage()
else:
if not ((len(args) == 3) or (len(args) == 4)): usage()
g.imageFile = args[1]
if not os.path.isfile(g.imageFile):
@@ -1152,19 +1173,25 @@ if (len(args) == 4):
if g.SHK:
g.PNAME = 0
if not g.DIR:
if not g.CAT:
targetDir = (args[3] if g.extractFile else args[2])
unshkdir = ("/tmp/cppo-" + str(uuid.uuid4()))
makedirs(unshkdir)
if not os.system("cd " + unshkdir + "; " +
"nulib2 -xse " +
os.path.abspath(g.imageFile) + " " +
(args[2].replace('/', ':') if g.extractFile else "") +
" | grep -q 'no records match' > /dev/null"):
result = os.system("/bin/bash -c 'cd " + unshkdir + "; " +
"result=$(nulib2 -xse " + os.path.abspath(g.imageFile) +
((" " + args[2].replace('/', ':'))
if g.extractFile else "") + " 2> /dev/null); " +
"if [[ $result == \"Failed.\" ]]; then exit 3; " +
"else if grep -q \"no records match\" <<< \"$result\"" +
" > /dev/null; then exit 2; else exit 0; fi; fi'")
if (result == 512):
print(
"File not found in ShrinkIt archive. Try cppo -cat to get the path,")
print(" and omit any leading slash or colon.")
sys.exit(1)
elif (result != 0):
print("ShrinkIt archive is invalid, or some other problem happened.")
sys.exit(1)
if g.extractFile:
g.extractFile = g.extractFile.replace(':', '/')
extractPath = (unshkdir + "/" + g.extractFile)
@@ -1179,7 +1206,9 @@ if g.SHK:
fileNames = [name for name in os.listdir(unshkdir)
if not name.startswith(".")]
if (len(fileNames) == 1 and os.path.isdir(unshkdir + "/" + fileNames[0])):
if g.nodir:
oneDir = True # force extract in place
elif (len(fileNames) == 1 and os.path.isdir(unshkdir + "/" + fileNames[0])):
oneDir = True
volumeName = toProdosName(fileNames[0])
else:
@@ -1189,25 +1218,23 @@ if g.SHK:
volumeName[-4:].lower() == ".sdk" or
volumeName[-4:].lower() == ".bxy"):
volumeName = volumeName[0:-4]
if not g.DIR and not g.extractFile:
if not g.CAT and not g.nodir and not g.extractFile:
print("Extracting into " + volumeName)
# recursively process unshrunk archive hierarchy
for dirName, subdirList, fileList in os.walk(unshkdir):
subdirList.sort()
if not g.DIR:
if not g.CAT:
g.targetDir = (targetDir + ("" if oneDir else ("/" + volumeName)) +
("/" if (dirName.count('/') > 2) else "") +
("/".join(dirName.split('/')[3:]))) # chop tempdir
if g.extractFile: # solo item, so don't put it in the tree
g.targetDir = targetDir
if g.UC:
g.targetDir = g.targetDir.upper()
g.ADdir = (g.targetDir + "/.AppleDouble")
makedirs(g.targetDir)
if g.AD:
makedirs(g.ADdir)
if not g.extractFile:
print("/".join(dirName.split('/')[3:])
if "/".join(dirName.split('/')[3:])
else "(top level)")
for fname in sorted(fileList):
g.shk_hasrf = ""
g.shk_rfork = False
@@ -1306,7 +1333,7 @@ if g.extractFile:
print("Target directory not found.")
sys.exit(2)
else:
if not g.DIR:
if not g.CAT:
if not os.path.isdir(args[2]):
print("Target directory not found.")
sys.exit(2)
@@ -1319,7 +1346,7 @@ if g.D33:
diskName = os.path.splitext(diskName)[0]
if g.PNAME:
diskName = toProdosName(diskName)
if not g.DIR:
if not g.CAT:
g.targetDir = (args[3] if g.extractFile
else (args[2] + "/" + diskName))
g.ADdir = (g.targetDir + "/.AppleDouble")
@@ -1357,7 +1384,7 @@ if g.extractFile:
print("ProDOS file not found within image file.")
sys.exit(2)
else:
if not g.DIR:
if not g.CAT:
# print(args[0], args[1], args[2])
g.targetDir = (args[2] + "/" + getVolumeName().decode("L1"))
g.ADdir = (g.targetDir + "/.AppleDouble")
@@ -1366,6 +1393,6 @@ else:
if not ((not g.AD) or os.path.isdir(g.ADdir)):
makedirs(g.ADdir)
processDir(2)
if not g.DIR:
if not g.CAT:
syncExit()

View File

@@ -9,7 +9,7 @@
# to download and execute, type:
# wget ivanx.com/a2server/setup; source setup
a2serverVersion="1.2.9"
a2serverVersion="130"
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in