-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathydt_old.sh
758 lines (616 loc) · 25.9 KB
/
ydt_old.sh
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
#!/bin/bash
#
# Author : [email protected]
# Homepage :
# License : BSD http://en.wikipedia.org/wiki/BSD_license
# Copyright (c) 2014, peter ducai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Purpose : Yocto development toolkit installer
# Usage : run without paramaters to see usage
#
#coding guidelines: http://google-styleguide.googlecode.com/svn/trunk/shell.xml
####################################################################################################
# #
# GLOBAL VALUES #
####################################################################################################
###################
# TERMINAL COLORS #
###################
NONE='\033[00m'
RED='\033[01;31m'
GREEN='\033[01;32m'
YELLOW='\033[01;33m'
BLACK='\033[30m'
BLUE='\033[34m'
VIOLET='\033[35m'
CYAN='\033[36m'
GREY='\033[37m'
############################
# system values #
############################
NOW=$(date +"%s-%d-%m-%Y")
################
# HOST values #
################
HOST_ARCH=$(uname -m)
HOST_OS=$(uname -o)
HOST_KERNEL_VERSION=$(uname -r)
HOST_DISTRO="N/A"
HOST_PYTHON_VERSION=$(python -c 'import sys; print("%i" % (sys.hexversion<0x03000000))')
HOST_INSTALL_QEMU="NO"
HOST_INSTALL_NFS="NO"
HOST_CPU_THREADS=$(cat /proc/cpuinfo|grep process|wc -l)
###################
# target values #
###################
declare -a TARGETS=("qemumips" "qemuppc" "qemux86" "qemux86-64" "genericx86" "genericx86-64" "beagleboard" "mpc8315e-rdb" "routerstationpro")
declare -a TARGETS_EXTERNAL
declare -a PACKAGE_MANAGERS=("rpm" "ipk" "tar" "deb")
PACKAGE_MANAGER="ipk" #default package manager
#######################
# Global adt values #
#######################
INSTALL_FOLDER="${HOME}/.ydt" #current location as default
DOWNLOAD_FOLDER="${HOME}/.ydt/down" #The central download directory used by the build process to store downloads
CONFIG_FOLDER="${HOME}/.ydt/configs"
YOCTO_ADT_REPO="http://downloads.yoctoproject.org/releases/yocto/yocto-1.5.1/"
LOG_FOLDER="${HOME}/.ydt/log"
LOG="${LOG_FOLDER}/ydt_ng.log"
HISTORY="${HOME}/.ydt/history"
EXTERNAL_TARGETS_FOLDER="${HOME}/.ydt/external_targets"
INTERACTIVE="N" #by default not interactive
FULL_INSTALL="N"
############################
# YOCTO version #
############################
YOCTO_VERSION="1.5.1"
YOCTO_DISTRO="poky"
####################################################################################################
# #
# LOGGING FUNCTIONS #
####################################################################################################
########################
# logging functions #
########################
adt_log_write() {
#echo "logging [$NOW] $1 [$2]"
echo "[$NOW] $1 [$2]" >> $LOG
}
adt_history_write() {
#echo "history writes [$NOW] $1"
echo "[$NOW] $1" >> $HISTORY
}
####################################################################################################
# #
# DISTRO RELATED FUNCTIONS #
####################################################################################################
#########################################
# find out type of linux distro of HOST #
#########################################
get_distro() {
echo -e "checking for right Python version.."
if [ ${HOST_PYTHON_VERSION} -eq 0 ]; then
echo -e "${RED}[ERROR]${NONE} we require python version 2.x"
exit
else
echo -e "${GREEN}[OK]${NONE} python version is 2.x\n"
fi
if [ -f /etc/redhat-release ] ; then
HOST_DISTRO='redhat'
elif [ -f /etc/SuSE-release ] ; then
HOST_DISTRO="suse"
elif [ -f /etc/debian_version ] ; then
HOST_DISTRO="debian" # including Ubuntu!
fi
}
################################################
# install required software for current distro #
################################################
install_essentials() {
case "${HOST_DISTRO}" in
redhat) yum install gawk make wget tar bzip2 gzip python unzip perl patch \
diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \
ccache perl-Data-Dumper perl-Text-ParseWords
;;
suse) zypper install python gcc gcc-c++ git chrpath make wget python-xml \
diffstat texinfo python-curses patch
;;
debian) apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath
;;
*) echo "DISTRO error"
exit 1
;;
esac
}
######################################
# install additional graphics libs #
######################################
install_graphical_extras() {
case "${HOST_DISTRO}" in
redhat) yum install SDL-devel xterm
;;
suse) zypper install libSDL-devel xterm
;;
debian) apt-get install libsdl1.2-dev xterm
;;
*) echo "DISTRO error"
exit 1
;;
esac
}
#####################################
# install documentation #
#####################################
install_documentation() {
case "${HOST_DISTRO}" in
redhat) yum install make docbook-style-dsssl docbook-style-xsl \
docbook-dtds docbook-utils fop libxslt dblatex xmlto
;;
suse) zypper install make fop xsltproc dblatex xmlto
;;
debian) apt-get install make xsltproc docbook-utils fop dblatex xmlto
;;
*) echo "DISTRO error"
exit 1
;;
esac
}
########################
# install ADT extras #
########################
install_adt_extras() {
case "${HOST_DISTRO}" in
redhat) yum install autoconf automake libtool glib2-devel
;;
suse) zypper install autoconf automake libtool glib2-devel
;;
debian) apt-get install autoconf automake libtool libglib2.0-dev
;;
*) echo "DISTRO error"
exit 1
;;
esac
}
###############################
# install qemu (default NO) #
###############################
install_qemu() {
if [[ "$HOST_INSTALL_QEMU" == "Y" ]];then
case "${HOST_DISTRO}" in
redhat) yum install autoconf automake libtool glib2-devel
;;
suse) zypper install autoconf automake libtool glib2-devel
;;
debian) apt-get install autoconf automake libtool libglib2.0-dev
;;
*) echo "DISTRO error"
exit 1
;;
esac
else
echo -e "skipping installation of Qemu"
fi
}
########################
# install NFS #
########################
install_nfs() {
case "${HOST_DISTRO}" in
redhat) yum install autoconf automake libtool glib2-devel
;;
suse) zypper install autoconf automake libtool glib2-devel
;;
debian) apt-get install autoconf automake libtool libglib2.0-dev
;;
*) echo "DISTRO error"
exit 1
;;
esac
}
####################################################################################################
# #
# INITIAL CHECKS, SELF-HEALING FEATURES, BACKUPS # ####################################################################################################
##############################################
# prepare essential folders and config files #
##############################################
prepare_essentials() {
echo -e "\ninitializing CHECKs"
echo ""
printf "checking for user rights.. "
##########################
# check if user is root #
##########################
if [ $(id -u) == "0" ]; then
echo -e "${RED}"
echo -e "#######################################################"
echo -e "# WARNING!!! running script as ROOT USER #"
echo -e "# Are you sure you want to run this script as root? #"
echo -e "# User access to ROOT's files can be limited!!! #"
echo -e "#######################################################"
echo -e "${NONE}[Y/n]"
read USER_INPUT
if [[ "${USER_INPUT}" == "Y" ]];then
printf "[OK]"
else
echo "exiting"
exit
fi
else
echo -e "running as as ${GREEN}${USER}${NONE}.. OK"
fi
###############################
# check for top .ydt folder #
###############################
echo -e "checking for .ydt folder..."
if [[ -d $HOME/.ydt ]];then
echo -e "you're running YDT installer for first time as ${GREEN}${USER}${NONE}"
else
echo -e "no .ydt folder... creating in $HOME/.ydt ."
mkdir $HOME/.ydt
fi
########################
# check log file #
########################
if [[ -d $LOG_FOLDER ]];then
echo "$LOG_FOLDER exists.. OK"
adt_log_write " " ""
adt_log_write "installer run by $USER" "INFO"
else
echo "$LOG_FOLDER not found.. creating one"
mkdir $LOG_FOLDER
touch ${LOG_FOLDER}/ydt_ng.log
echo "#created on ${NOW}" >> ${LOG_FOLDER}/ydt_ng.log
adt_log_write " " "new entry"
adt_log_write "FIRST INITIALIZATION, run by $USER" "INFO"
adt_log_write "log file missing.. recreated in ${LOG_FOLDER}" "WARNING"
fi
#######################
# check CONFIG files #
#######################
if [[ -d $CONFIG_FOLDER ]];then
echo "config found... OK"
else
echo "missing config directory... creating default one"
mkdir $CONFIG_FOLDER
echo "creating default config file"
touch ${CONFIG_FOLDER}/default.config
echo "writing default parameters into config"
echo "#autogenerated default config" >> ${CONFIG_FOLDER}/default.config
echo "# logged on [$NOW]"
echo -e "--interactive" >> ${CONFIG_FOLDER}/default.config
adt_log_write "config file missing.. recreated in ${CONFIG_FOLDER}" "WARNING"
fi
#######################
# check HISTORY file #
#######################
if [[ -f ${HISTORY} ]];then
echo "history found at ${HISTORY}... OK"
else
echo "history not found... creating new one"
touch ${HISTORY}
adt_log_write "history file missing.. recreated in ${HISTORY}" "WARNING"
adt_history_write "history file missing.. recreated in ${HISTORY}"
fi
}
####################################################################################################
# #
# COMMON FUNCTIONS #
####################################################################################################
###################################
# list possible Yocto targets #
###################################
list_targets() {
echo -e "available targets:"
echo -e "${GREEN}qemumips qemuppc qemux86 qemux86-64 genericx86 genericx86-64 beagleboard mpc8315e-rdb routerstationpro${NONE}"
}
################################################################################
# define target(s) separated by space, to see values use list_targets switch. #
################################################################################
set_targets() {
if [[ "${INTERACTIVE}" == "Y" ]];then
echo -e "your HOST is ${GREEN}${HOST_ARCH}${NONE}, what targets you want to install?"
list_targets
echo -e "${NONE}[target names]"
read TRGT
# TODO validate target
else
echo "setting targets to $TARGETS[@]"
fi
}
#############################
# list available rootfs #
#############################
list_rootfs() {
echo -e "available rootfs:"
echo -e "${GREEN}minimal minimal-dev sato sato-dev sato-sdk lsb lsb-dev lsb-sdk${NONE}"
}
###############################
# download specific toolchain #
###############################
download_toolchain() {
echo "DOWNLOADING http://downloads.yoctoproject.org/releases/yocto/yocto-${YOCTO_VERSION}/toolchain/${YOCTO_DISTRO}-eglibc-${HOST_ARCH}-core-image-sato-${TARGET}-toolchain-1.5.1.sh"
wget -O $DOWNLOAD_FOLDER/${YOCTO_DISTRO}-eglibc-${HOST_ARCH}-core-image-sato-${TARGET}-toolchain-${YOCTO_VERSION}.sh http://downloads.yoctoproject.org/releases/yocto/yocto-${YOCTO_VERSION}/toolchain/${YOCTO_DISTRO}-eglibc-${HOST_ARCH}-core-image-sato-${TARGET}-toolchain-${YOCTO_VERSION}.sh
}
run_interactive() {
echo -e "welcome to interactive mode\nthese are current parameters"
print_parameters
echo -e "${GREEN}specify install folder${NONE}"
}
run_installer() {
echo "running INSTALLER"
adt_log_write "running INSTALLER" "INFO"
adt_history_write "running INSTALLER"
if [[ "${INTERACTIVE}" == "Y" ]];then
adt_log_write "running interactive mode.. collecting user input" "INFO"
adt_history_write "running interactive mode.. collecting user input"
run_interactive
else
adt_log_write "running non-interactive mode" "INFO"
adt_history_write "running non-interactive mode"
fi
echo -e "${GREEN}running installation..${NONE}"
adt_log_write "running installation with following parameters:" "INFO"
adt_log_write "params" "INFO"
adt_history_write "running installation with following parameters:"
adt_history_write "params"
# END OF INSTALLATION
adt_log_write "end of install" "INFO"
adt_history_write "end of install"
}
#TODO
build_full_distro() {
echo "The build process using Sato currently consumes about 50GB of disk space. To allow for variations in the build process and for future package expansion, we recommend having at least 100GB of free disk space."
wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.5.1/poky-dora-10.0.1.tar.bz2
#OR
git clone git://git.yoctoproject.org/poky
tar xjf poky-dora-10.0.1.tar.bz2
cd poky-dora-10.0.1
#From the parent directory your Source Directory, initialize your environment and provide a meaningful Build Directory name:
#$ source poky/oe-init-build-env mybuilds
source oe-init-build-env
#Initializing the build environment creates a conf/local.conf configuration file in the Build Directory. You need to manually edit this file to specify the machine you are building and to optimize your build time. Here are the minimal changes to make:
# BB_NUMBER_THREADS = "8"
# PARALLEL_MAKE = "-j 8"
# MACHINE ?= "beagleboard"
#Briefly, set BB_NUMBER_THREADS and PARALLEL_MAKE to twice your host processor's number of cores.
#By default, the OpenEmbedded build system uses the RPM package manager.
bitbake -k core-image-sato
#OR
bitbake core-image-minimal
runqemu qemux86
}
install_toolchain() {
#You can download a tarball installer, which includes the pre-built toolchain, the runqemu script, and support files from the appropriate directory under http://downloads.yoctoproject.org/releases/yocto/yocto-1.5.1/toolchain/. Toolchains are available for 32-bit and 64-bit x86 development systems from the i686 and x86_64 directories, respectively. The toolchains the Yocto Project provides are based off the core-image-sato image and contain libraries appropriate for developing against that image. Each type of development system supports five or more target architectures.
#The names of the tarball installer scripts are such that a string representing the host system appears first in the filename and then is immediately followed by a string that represents the target architecture.
#poky-eglibc-<host_system>-<image_type>-<arch>-toolchain-<release_version>.sh
#Where:
#<host_system> is a string representing your development system:
#i686 or x86_64.
#<image_type> is a string representing the image you wish to
#develop a Software Development Toolkit (SDK) for use against.
#The Yocto Project builds toolchain installers using the
#following BitBake command:
#bitbake core-image-sato -c do_populatesdk core-image-sato
#<arch> is a string representing the tuned target architecture:
#i586, x86_64, powerpc, mips, armv7a or armv5te
#<release_version> is a string representing the release number of the
#Yocto Project:
#1.5.1, 1.5.1+snapshot
#F#or example, the following toolchain installer is for a 64-bit development host system and a i586-tuned target architecture based off the SDK for core-image-sato:
#poky-eglibc-x86_64-core-image-sato-i586-toolchain-1.5.1.sh
#Toolchains are self-contained and by default are installed into /opt/poky. However, when you run the toolchain installer, you can choose an installation directory.
}
####################################################################################################
# #
# INFO #
####################################################################################################
##################################
# print history of installations #
##################################
show_history() {
echo -e "\nHISTORY.......................\n"
cat $HISTORY
}
list_configs() {
echo -e "\nFollowing configs were found.."
ls $HOME/.ydt/configs/
}
print_parameters() {
get_distro
echo -e "@${NOW}"
echo -e "- ${YELLOW}HOST PARAMETERS ${NONE}------------------------------------"
echo -e " architecture: ${GREEN}${HOST_ARCH}${NONE}"
echo -e " operating system: ${GREEN}${HOST_OS}${NONE}"
echo -e " kernel version: ${GREEN}${HOST_KERNEL_VERSION}${NONE}"
echo -e " distribution: ${GREEN}${HOST_DISTRO}${NONE}"
echo -e " CPU threads: ${GREEN}${HOST_CPU_THREADS}${NONE}"
echo -e "------------------------------------------------------"
echo -e "- ${YELLOW}DISTRO PARAMETERS ${NONE}----------------------------------"
echo -e " distro: ${GREEN}${YOCTO_DISTRO}${NONE}"
echo -e " version: ${GREEN}${YOCTO_VERSION}${NONE}"
echo -e "------------------------------------------------------"
echo -e "- ${YELLOW}TARGET PARAMETERS ${NONE}----------------------------------"
echo -e " targets: ${GREEN}${TARGETS[@]}${NONE}"
echo -e " external targets: ${GREEN}${TARGETS_EXTERNAL[@]}${NONE}"
echo -e " package managers: ${GREEN}${PACKAGE_MANAGERS[@]}${NONE}"
echo -e "------------------------------------------------------"
echo -e "- ${YELLOW}INSTALL PARAMETERS ${NONE}----------------------------------"
echo -e " install folder: ${GREEN}${INSTALL_FOLDER}${NONE}"
echo -e " download folder: ${GREEN}${DOWNLOAD_FOLDER}${NONE}"
echo -e " ADT repo: ${GREEN}${YOCTO_ADT_REPO}${NONE}"
echo -e " log file: ${GREEN}${LOG}${NONE}"
echo -e " history file: ${GREEN}${HISTORY}${NONE}"
echo -e " install NFS: ${GREEN}${HOST_INSTALL_NFS}${NONE}"
echo -e " install Qemu: ${GREEN}${HOST_INSTALL_QEMU}${NONE}"
echo -e "------------------------------------------------------"
}
print_usage() {
echo "running under BASH ${BASH_VERSION}"
print_parameters
echo -e "\nUsage:\n"
echo -e "--interactive [enter interactive mode where installer will ask for every parameter]"
echo -e "--list-parameters [list all parameters]"
echo -e "--list-targets [list all available targets]"
echo -e "--set-targets = ${GREEN}qemuarm qemuppc qemux86 qemux86-64 genericx86 genericx86-64 beagleboard mpc8315e-rdb routerstationpro${NONE}"
echo -e " [external targets] ${GREEN}${EXT_TARGETS}${NONE}"
echo -e " [set targets, for more than one, separate with space]"
echo -e "--list-rootfs [list rootfs variables]"
echo -e "--set-rootfs = ${GREEN}minimal minimal-dev sato sato-dev sato-sdk lsb lsb-dev lsb-sdk${NONE}"
echo -e " [external rootfs] ${GREEN}${EXT_ROOTFS}${NONE}"
echo -e "--set-package-system = ${GREEN}ipk tar deb rpm${NONE}"
echo -e " [set packaging system for YOCTO]"
echo -e "--install-qemu [install Qemu package for simulation of other architectures] ROOT required!${NONE}"
echo -e "--install_nfs [install NFS package] ROOT required!${NONE}"
echo -e "--install-path ${GREEN}PATH${NONE}"
echo -e " [specify installation path]${NONE}"
echo -e "--show-history [show installation history]${NONE}"
echo -e "--load-from-config = <path_to_config>${NONE}"
echo -e " [load values from specified config file]${NONE}"
echo -e "--save-to-config = <path_to_config>${NONE}"
echo -e " [save values to specified config file]${NONE}"
echo -e "--list-configs [list available config files]"
echo -e "--set-external-targets-path = <path_to_folder>"
echo -e "--set-download-folder = <path>"
echo -e "--clean-download-folder [to clean all downloads]"
echo -e "--view-log [view log file content]"
echo -e "--clear-log [delete log file]"
echo -e "--install-full-yocto []"
echo -e "--install-toolchain-only []"
}
print_banner() {
echo -e "\n \/ _ __|_ _ "
echo -e " / (_)(_ | (_) development toolkit \n"
}
####################################################################################################
# #
# MAIN FUNCTION #
####################################################################################################
print_banner
# if no parameters, run interactive
if [[ -z "$1" ]]; then
echo -e "${RED}###################################################################${NONE}"
echo -e "${RED}# Are you sure you want to run installer with default parameters? #${NONE}"
echo -e "${RED}###################################################################${NONE}"
read CONTINUE
if [[ "${CONTINUE}" != "Y" ]];then
print_usage
exit
else
echo "skipping to installer"
fi
fi
#######################
# process parameters #
#######################
for i in "$@"
do
case "$i" in
--install-folder=*) INSTALL_FOLDER="${i#*=}"
LOG_FOLDER="${INSTALL_FOLDER}/log"
echo -e "INSTALL FOLDER set to ${INSTALL_FOLDER}"
;;
--list-parameters) print_parameters # to list all parameters
exit
;;
--list-targets) list_targets
exit
;;
--set-targets=*) TARGETS=("${i#*=}") # define target(s) separated by space, to see values use list_targets switch. Example "arm x86"
print_parameters
;;
--list-rootfs) list_rootfs
exit
;;
--set-rootfs=*) ROOTFS="${i#*=}"
;;
--set-package-system=*) PACKAGE_MANAGER="${i#*=}" # define packaging system, possible values: rpm, ipk, tar, deb
;;
--install-path) INSTALL_FOLDER="${i#*=}" # path to install dir
;;
--show-history) show_history
;;
--install-qemu=*) HOST_INSTALL_QEMU="${i#*=}"
install_qemu
;;
--install-nfs) HOST_INSTALL_NFS="${i#*=}"
install_nfs
;;
--save-to-config) echo "something" # save values to config
;;
--load-from-config) echo "something"
;;
--list-configs) list_configs
exit
;;
--interactive)
INTERACTIVE="Y"
;;
--set-download-folder) DOWNLOAD_FOLDER="${i#*=}"
echo -e "download folder set to ${DOWNLOAD_FOLDER}"
;;
--clean-download-folder) echo -e "cleaning download folder ${DOWNLOAD_FOLDER}"
rm -rf ${DOWNLOAD_FOLDER}/*
;;
--set-external-targets-path=*) EXTERNAL_TARGETS_FOLDER="${i#*=}"
;;
--view-log) if [[ -d $LOG_FOLDER ]];then
cat $LOG_FOLDER/ydt_ng.log
else
echo -e "${RED}log file not found.. re-run installer to see default log${NONE}"
fi
exit
;;
--clear-log) rm -rf ${LOG_FOLDER}/ydt_ng.log
echo "log file deleted at ${NOW} by ${USER}"
LOG_CLEARED="Y"
;;
--install-full-yocto) FULL_INSTALL="Y"
;;
--install-toolchain-only) FULL_INSTALL="N"
;;
*) echo "invalid option!!!"
print_usage
;;
esac
done
LOG_FOLDER="${INSTALL_FOLDER}/log"
prepare_essentials
if [[ "${LOG_CLEARED}" == "Y" ]];then
echo "log file deleted at ${NOW} by ${USER}" > ${LOG_FOLDER}/ydt_ng.log
exit
fi
adt_log_write "INITIALIZATION finished" "INFO"
adt_history_write "INITIALIZATION finished"
run_installer
############################
# continue with params set #
############################
##############################
# END OF INSTALER #
##############################
exit $?