-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstalldos
executable file
·132 lines (109 loc) · 3.19 KB
/
installdos
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
#!/bin/sh
SOURCE="$1"
DRIVE_ROOT="$2"
DOS_DIRECTORY=dos
if which msexpand >/dev/null 2>&1 ; then
MSEXPAND=msexpand
elif which dosemu-msexpand >/dev/null 2>&1 ; then
MSEXPAND=dosemu-msexpand
else
echo "msexpand tool not found!"
exit 1
fi
extract_freedos_archives()
{
for filename in $(ls $SOURCE/*.zip)
do
unzip -d "$DRIVE_ROOT" -qq -o -LL "$filename" -x packages/* source/* bin/kernl86.sys 2>/dev/null
done
}
extract_freedos_lib()
{
unzip -d "$DRIVE_ROOT"/bin -qq -LL -o -j "${SOURCE}"/lib.zip llib32/lib.exe
unzip -d "$DRIVE_ROOT"/doc/lib -qq -o -LL -j "${SOURCE}"/lib.zip llib32/readme
}
install_freedos()
{
echo Installing FreeDOS...
mkdir -p "${DRIVE_ROOT}"
extract_freedos_archives
extract_freedos_lib
ln -s swsubst.exe "${DRIVE_ROOT}"/bin/join.exe
ln -s swsubst.exe "${DRIVE_ROOT}"/bin/subst.exe
mv "${DRIVE_ROOT}"/bin/kernl386.sys "${DRIVE_ROOT}"/kernel.sys
ln -s bin/command.com "${DRIVE_ROOT}"/command.com
chmod 644 "${DRIVE_ROOT}"/appinfo/* "${DRIVE_ROOT}"/bin/* "${DRIVE_ROOT}"/doc/*/* "${DRIVE_ROOT}"/nls/*
chmod 755 "${DRIVE_ROOT}"/doc/*
echo Installation complete
}
expand_files_with_extension()
{
EXTENSION=$1
EXTENSION_COMPRESSED="${1%?}_"
EXTENSION_CUT="${1%?}"
ls "$SOURCE"/*.$EXTENSION_COMPRESSED > /dev/null 2> /dev/null
if [ $? -eq 0 ] # continue only if there are compressed files with this extension
then
for i in "$SOURCE"/*.$EXTENSION_COMPRESSED
do
$MSEXPAND "$i" ${DRIVE_ROOT}/"${DOS_DIRECTORY}"/$(basename "${i%.???}.$EXTENSION")
done
fi
}
move_to_rootdir()
{
mv "${DRIVE_ROOT}"/"${DOS_DIRECTORY}"/$1 "${DRIVE_ROOT}"/ 2> /dev/null
}
# Manual MS-DOS installation as described in Microsoft KB117245
install_msdos()
{
echo Installing MS-DOS...
mkdir -p "${DRIVE_ROOT}"/"${DOS_DIRECTORY}"
# it's not possible to deduce the final letter of the extension, so we have to provide the list
EXTENSION_LIST="inf 386 bin com cpi dll exe ovl sys txt grp hlp lst pro"
# fill C:\DOS
for extension in $EXTENSION_LIST
do
cp "$SOURCE"/*.$extension "${DRIVE_ROOT}"/"${DOS_DIRECTORY}" 2> /dev/null
expand_files_with_extension $extension
done
ROOTDIR_FILES="wina20.386 ???space.bin io.sys msdos.sys command.com"
for rootdir_file in $ROOTDIR_FILES
do
move_to_rootdir $rootdir_file
done
echo Installation complete
}
extract_7z()
{
ARCHIVE="$1"
FILENAME="$2"
DESTINATION_DIR=$3
echo Extracting $FILENAME
7z e "$ARCHIVE" $FILENAME -o"$DESTINATION_DIR" -y -ssc- >/dev/null
}
install_opendos_from_rpm()
{
TMP_DIR=/tmp/"$(basename $0)-$USER-$$"
mkdir -p "$TMP_DIR" "${DRIVE_ROOT}"
extract_7z $SOURCE/opendos-hdimage*.rpm "" "$TMP_DIR"
extract_7z "$TMP_DIR"/opendos-hdimage*.cpio hdimage.od "$TMP_DIR"
MTOOLS_LOWER_CASE=1 mcopy -sn -i "$TMP_DIR"/hdimage.od@@32384 ::* "${DRIVE_ROOT}"
rm -r "$TMP_DIR"
}
# Detect which DOS is provided and run the appropriate installation routine
if [ -e $SOURCE/kernel.zip ] ; then
install_freedos
exit 0
fi
if [ -e $SOURCE/msdos.sys ] ; then
install_msdos
exit 0
fi
if [ -e $SOURCE/opendos-hdimage*.rpm ] ; then
install_opendos_from_rpm
exit 0
fi
echo "No DOS installation files were found."
echo "Run loaddosinstall as root to download a version of DOS."
exit 1