-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtlaloc.sh
More file actions
executable file
·149 lines (120 loc) · 5.32 KB
/
Copy pathtlaloc.sh
File metadata and controls
executable file
·149 lines (120 loc) · 5.32 KB
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
#!/bin/sh
# tlaloc script
# Copyright Timo Pallach <timo@pallach.de>, see LICENSE for details
# Set some tlaloc global variables
TLALOC_VERSION=master
TLALOC_DIRECTORY=`pwd`
. ./tlaloc.conf
. ./tlaloc.sub
debug "DEBUG" "Entering the tlaloc.sh sricpt. Already sourced the tlaloc.conf and tlaloc.sub files."
# Set the variables to default
show_config=${DEFAULT_SHOW_CONFIG}
enable_debug=${DEFAULT_ENABLE_DEBUG}
enable_vga=${DEFAULT_ENABLE_VGA}
cleanup_directories=${DEFAULT_CLEANUP_DIRECTORIES}
cleanup_base_directory=${DEFAULT_CLEANUP_BASE_DIRECTORY}
cleanup_package_directory=${DEFAULT_CLEANUP_PACKAGE_DIRECTORY}
cleanup_binary_directory=${DEFAULT_CLEANUP_BINARY_DIRECTORY}
cleanup_image_directory=${DEFAULT_CLEANUP_IMAGE_DIRECTORY}
cleanup_resflash_directory=${DEFAULT_CLEANUP_RESFLASH_DIRECTORY}
openbsd_version=${DEFAULT_OPENBSD_VERSION}
openbsd_version_short=${DEFAULT_OPENBSD_VERSION_SHORT}
openbsd_arch=${DEFAULT_OPENBSD_ARCH}
openbsd_url=${DEFAULT_OPENBSD_URL}
openbsd_package_url=${DEFAULT_OPENBSD_PACKAGE_URL}
openbsd_binary_url=${DEFAULT_OPENBSD_BINARY_URL}
base_directory=${DEFAULT_BASE_DIRECTORY}
package_directory=${DEFAULT_PACKAGE_DIRECTORY}
binary_directory=${DEFAULT_BINARY_DIRECTORY}
image_directory=${DEFAULT_IMAGE_DIRECTORY}
resflash_directory=${DEFAULT_RESFLASH_DIRECTORY}
package_path=${DEFAULT_PACKAGE_PATH}
package_list=${DEFAULT_PACKAGE_LIST}
binary_list=${DEFAULT_BINARY_LIST}
com0_speed=${DEFAULT_COM0_SPEED}
image_size=${DEFAULT_IMAGE_SIZE}
resflash_version=${DEFAULT_RESFLASH_VERSION}
resflash_source_url=${DEFAULT_RESFLASH_SOURCE_URL}
# The user of tlaloc has the posibility to overwrite the default configuration
# options by copying his own script tlaloc.conf.logl into the tlaloc root directory.
if [ -f ./tlaloc.conf.local ]; then
. ./tlaloc.conf.local
change_openbsd_version ${openbsd_version}
change_openbsd_arch ${openbsd_arch}
fi
# Parse options first
while :; do
# Exit the while loop if we have no options passed.
if [ ${#} -eq 0 ]; then
break;
fi
case ${1} in
--help) print_usage; shift;;
--version) print_version && exit 1; shift;;
--show-config) show_config=YES; shift;;
--enable-debug) enable_debug=YES; shift;;
--enable-vga) enable_vga=YES; shift;;
--cleanup-directories) cleanup_directories=YES; shift;;
--cleanup-base-directory) cleanup_base_directory=YES; shift;;
--cleanup-package-directory) cleanup_package_directory=YES; shift;;
--cleanup-binary-directory) cleanup_binary_directory=YES; shift;;
--cleanup-image-directory) cleanup_image_directory=YES; shift;;
--cleanup-resflash-directory) cleanup_resflash_directory=YES; shift;;
--openbsd-version) change_openbsd_version ${2}; shift 2;;
--openbsd-arch) change_openbsd_arch ${2}; shift 2;;
--openbsd-url) openbsd_url=${2} shift 2;;
--package-directory) package_directory=${2}; shift 2;;
--binary-directory) binary_directory=${2}; shift 2;;
--base-directory) base_directory=${2}; shift 2;;
--image-directory) image_directory=${2}; shift 2;;
--package-list) package_list=${2}; shift 2;;
--binary-list) binary_list=${2}; shift 2;;
--com0-speed) com0_speed=${2}; shift 2;;
--image-size) image_size=${2}; shift 2;;
--resflash-version) resflash_version=${2}; shift 2;;
--resflash-source-url) resflash_source_url=${2}; shift 2;;
-*|--*) print_usage;;
*) break;;
esac
done
# Enable some additional options if the enable-debug configuration parameter is Set
debug "DEBUG" "Checking if the enable debug was set to activate some more options."
if [ "${enable_debug}" == "YES" ]; then
debug "DEBUG" "Execute \"set -o errexit\" and other options."
set -o errexit
set -o nounset
if [ "$(set -o|grep pipefail)" ]; then
set -o pipefail
fi
fi
# Show the configuration and exit
debug "DEBUG" "Running show_config"
show_config
# Check if the script is executed as root user
debug "DEBUG" "Running is_user_root"
is_user_root
# Delete the working directories base, package, binary, image and resflash.
debug "DEBUG" "Running cleanup_working_directories"
cleanup_working_directories
# Check if git is installed
debug "DEBUG" "Running is_git_installed"
is_git_installed
# Fetch the resflash sources and checkout the specific version
debug "DEBUG" "Running fetch_resflash"
fetch_resflash
# Fetch the OpenBSD binary packages
debug "DEBUG" "Running fetch_binaries"
fetch_binaries
# Populate the base directory
debug "DEBUG" "Running populate_base_directory"
populate_base_directory
# Do the final base directory modifications
debug "DEBUG" "Running do_base_modifications"
do_base_modifications
# Call the resflash script to create the image and filesystem files
debug "DEBUG" "Running run_resflash"
run_resflash
# Move the image and filesystem files to the image directory
debug "DEBUG" "Running move_image_files"
move_image_files
debug "DEBUG" "Exiting the tlaloc.sh script."