-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgetfreedos
executable file
·94 lines (76 loc) · 2.47 KB
/
getfreedos
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
#!/bin/sh
DEFAULT_MIRROR=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files
BASE_URL=$DEFAULT_MIRROR/distributions/1.1/repos/base
ARCHIVES="kernel command assign attrib choice comp debug defrag deltree diskcomp diskcopy display \
edit edlin exe2bin fc find format help label mem mode more move nansi replace share shsucdx \
sort swsubst tree xcopy"
BWBASIC_URL=${DEFAULT_MIRROR}/devel/basic/bwbasic/bwb220ax.zip
LIB_URL=${DEFAULT_MIRROR}/devel/tools/lib-sk32.zip
TOUCH_URL=${DEFAULT_MIRROR}/util/file/touch/1.44/touch144.zip
WCD_URL=${DEFAULT_MIRROR}/util/user/wcd/wcd530b.zip
TMP_DIR=/tmp/freedos-$USER
DRIVE_ROOT="$1"
extract_freedos_archives()
{
for filename in ${ARCHIVES} bwbasic touch wcd
do
unzip -d "$DRIVE_ROOT" -qq -LL "${TMP_DIR}"/"$filename".zip -x packages/* source/* bin/kernl86.sys 2>/dev/null
done
}
extract_lib()
{
unzip -d "$DRIVE_ROOT"/bin -qq -LL -j "${TMP_DIR}"/lib.zip llib32/lib.exe
unzip -d "$DRIVE_ROOT"/doc/lib -qq -LL -j "${TMP_DIR}"/lib.zip llib32/readme
}
download_file()
{
SOURCE=$1
DESTINATION=$2
if [ -f "$DESTINATION" ]
then
echo "$DESTINATION" found, not redownloading
else
echo Downloading "$SOURCE"...
wget --quiet "$SOURCE" -O "$DESTINATION"
fi
}
download_archives()
{
echo Downloading FreeDOS...
mkdir -p "${TMP_DIR}"
for filename in ${ARCHIVES}
do
download_file "${BASE_URL}"/"$filename".zip "${TMP_DIR}"/"$filename".zip
done
download_file "${BWBASIC_URL}" "${TMP_DIR}"/bwbasic.zip
download_file "${LIB_URL}" "${TMP_DIR}"/lib.zip
download_file "${TOUCH_URL}" "${TMP_DIR}"/touch.zip
download_file "${WCD_URL}" "${TMP_DIR}"/wcd.zip
echo Downloading done
}
verify_system()
{
if [ ! `which unzip` ] ; then
echo Please install unzip and make sure that unzip is on your PATH
exit 1
fi
if [ ! `which wget` ] ; then
echo Please install wget and make sure that wget is on your PATH
exit 1
fi
}
verify_system
download_archives
echo Extracting FreeDOS...
mkdir -p "${DRIVE_ROOT}"
extract_freedos_archives
extract_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
mv "${DRIVE_ROOT}"/share/doc/* "${DRIVE_ROOT}"/doc
rmdir "${DRIVE_ROOT}"/share/doc "${DRIVE_ROOT}"/share
chmod 644 "${DRIVE_ROOT}"/appinfo/* "${DRIVE_ROOT}"/bin/* "${DRIVE_ROOT}"/doc/*/* "${DRIVE_ROOT}"/nls/*
chmod 755 "${DRIVE_ROOT}"/doc/*
echo Extraction complete