This file is indexed.

/usr/sbin/tcos-buildchroot is in initramfs-tools-tcos 0.89.86.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#!/bin/bash
#
# tcos-buildchroot This script creates a chroot to build TCOS 32bits images
#
# Copyright (C) 2006-2011  mariodebian at gmail
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#


if [ $(id -u) != 0 ]; then
  echo "Error: need to exec as root user" >&2
  exit 1
fi

. /etc/tcos/tcos.conf
. /etc/tcos/version.conf
. ${TCOS_DIR}/tcos-generation-functions.sh

for tpl in $(tcos_get_templates); do
  . $tpl
done

# load forced settings for derivatives
if [ -d /etc/tcos/conf.d/ ]; then
  for file in /etc/tcos/conf.d/tcos*conf; do
    [ -e $file ] && . $file
  done
fi


export LC_ALL=C
export LC_MESSAGES=C
export DEBCONF_FRONTEND="noninteractive"
export DEBIAN_FRONTEND="noninteractive"

# default settings
TCOS_ARCH=i386
TCOS_FLAVOUR=standard
TCOS_MIRROR="http://www.tcosproject.org"


TCOS_PACKAGES="tcos-keyring initramfs-tools-tcos p910nd xvnc4viewer fgetty"
TCOS_PACKAGES="${TCOS_PACKAGES} binutils acpid alsa-utils twm dropbear mbr file"
TCOS_PACKAGES="${TCOS_PACKAGES} rdesktop pulseaudio pulseaudio-module-x11 pulseaudio-utils pulseaudio-esound-compat libasound2-plugins"


DISTRO_PACKAGES="xserver-xorg xutils xfonts-base xfonts-100dpi libgl1-mesa-dri libgl1-mesa-glx libglu1-mesa mtools xterm wget dosfstools"
DISTRO_PACKAGES="${DISTRO_PACKAGES} x11-utils debootstrap eject debconf syslinux squashfs-tools mknbi"
DISTRO_PACKAGES="${DISTRO_PACKAGES} python python-dbus alsa-base xauth xserver-xorg-input-all xserver-xorg-input-mouse"


# apt options (force-yes)
APT_OPTS="-y --force-yes"
ACTION=
GENTCOS_OPTS="-tftp"
MIRROR_EXTRAS=""
TCOS_EXPERIMENTAL=""

UBUNTU_DEF_MIRROR=http://archive.ubuntu.com/ubuntu/
UBUNTU_DEF_MIRROR2=http://security.ubuntu.com/ubuntu/
DEBIAN_DEF_MIRROR=http://ftp.de.debian.org/debian/


set_conf() {
    if [ "${DISTRIBUTION}" = "ubuntu" ]; then
      if [ ! $MIRROR ]; then MIRROR=$UBUNTU_DEF_MIRROR ; fi
      if [ ! $MIRROR2 ]; then MIRROR2=$UBUNTU_DEF_MIRROR2 ; fi
      MIRROR_EXTRAS="universe restricted multiverse"
      DISTRO_PACKAGES="console-setup ${DISTRO_PACKAGES}"
    else
      if [ ! $MIRROR ]; then MIRROR=$DEBIAN_DEF_MIRROR ; fi
      #DISTRO_PACKAGES="console-data ${DISTRO_PACKAGES} libltdl3 "
      DISTRO_PACKAGES="console-tools console-data ${DISTRO_PACKAGES}"
    fi
}

# load forced settings for derivatives
if [ -d /etc/tcos/conf.d/ ]; then
  for file in /etc/tcos/conf.d/tcos*conf; do
    [ -e $file ] && . $file
  done
fi

usage() {
  cat << EOF
tcos-buildchroot usage:

     Actions:
        --create                     (Create chroot)
        --update                     (Update chroot)
        --install=package1,package2  (Install some packages in chroot)
        --update-images              (Update chroot TCOS images)

     Options:
        --arch=xxx           (Set Architecture of chroot, default: $TCOS_ARCH)
        --flavour=xxx        (Set flavour of chroot, default: $TCOS_FLAVOUR)  
        --version=xxx        (Set version of chroot, default: $TCOS_DISTRO)
        --forcedistro=xxx    (Set distro of chroot, default: $DISTRIBUTION)
        --dir=xxx            (Set dir of chroot, default: $TCOS_CHROOT)
        --tcos-exp           (Enable experimental TCOS branch)
EOF
if [ "$DISTRIBUTION" = "ubuntu" ]; then
cat << EOF
        --mirror=xxx         (Set mirror of chroot, default: $UBUNTU_DEF_MIRROR)
        --securitymirror=xxx (Set security mirror of chroot, default: $UBUNTU_DEF_MIRROR2)
EOF
else
cat << EOF
        --mirror=xxx         (Set mirror of chroot, default: $DEBIAN_DEF_MIRROR)
EOF
fi
cat << EOF
        --tcosmirror=xxx     (Set mirror of TCOS, default: $TCOS_MIRROR)
        --kversion=xxx       (Set kernel version of chroot, default: $TCOS_KERNEL)
        --gentcos="xxx"      (Set gentcos cmdline options)

EOF
}

createEmptyCMD() {
cat << CMD > ${TCOS_CHROOT}/$1
#!/bin/sh
#echo " * Fake $1 called: '\$@'"
exit 0
CMD
  chmod +x ${TCOS_CHROOT}/$1
}

chrootcreate() {
  mkdir -p ${TCOS_CHROOT}
 
  debootstrap --arch "${TCOS_ARCH}" ${TCOS_DISTRO} ${TCOS_CHROOT} ${MIRROR}


  if [ $? != 0 ]; then echo "Error running debootstrap." ; exit $?; fi

  # Add TCOS mirror
  echo "deb ${TCOS_MIRROR} $TCOS_DISTRO main $TCOS_EXPERIMENTAL" >> ${TCOS_CHROOT}/etc/apt/sources.list

  # add extras (universe and multiverse repos)
  if [ "${MIRROR_EXTRAS}" != "" ]; then
    echo "deb ${MIRROR} ${TCOS_DISTRO} ${MIRROR_EXTRAS}" >> ${TCOS_CHROOT}/etc/apt/sources.list
    echo "deb ${MIRROR2} ${TCOS_DISTRO}-security main ${MIRROR_EXTRAS}" >> ${TCOS_CHROOT}/etc/apt/sources.list
    echo "deb ${MIRROR} ${TCOS_DISTRO}-updates main ${MIRROR_EXTRAS}" >> ${TCOS_CHROOT}/etc/apt/sources.list
  fi
  
  # add extra source include in forced settings
  if [ ! -z ${MIRROR_EXTRA} ];then
    echo ${MIRROR_EXTRA} >> ${TCOS_CHROOT}/etc/apt/sources.list
  fi

  # add /etc/resolv.conf (some versions of cdebootstrap don't create it)
  cat /etc/resolv.conf > ${TCOS_CHROOT}/etc/resolv.conf

  # avoid to use a shell script in chroot
  chroot ${TCOS_CHROOT} dpkg-divert --package initramfs-tools-tcos \
                                    --add --rename --quiet \
                                    --divert /sbin/start-stop-daemon.original \
                                    /sbin/start-stop-daemon

  chroot ${TCOS_CHROOT} dpkg-divert --package initramfs-tools-tcos \
                                    --add --rename --quiet \
                                    --divert /usr/sbin/invoke-rc.d.original \
                                    /usr/sbin/invoke-rc.d

  # avoid calling udevadm inside chroot
  # http://bugs.debian.org/627790
  chroot ${TCOS_CHROOT} dpkg-divert --package initramfs-tools-tcos \
                                    --add --rename --quiet \
                                    --divert /sbin/udevadm.original \
                                    /sbin/udevadm
  createEmptyCMD /sbin/udevadm


  cat << EOF > ${TCOS_CHROOT}/etc/apt/apt.conf
APT::Install-Recommends "false";
APT::Install-Suggests "false";
EOF

  mount --bind /proc ${TCOS_CHROOT}/proc
  mount --bind /sys ${TCOS_CHROOT}/sys

  # preseed linux-image message
  cat << EOF > ${TCOS_CHROOT}/preseed
linux-image-${TCOS_KERNEL}	linux-image-${TCOS_KERNEL}/preinst/lilo-initrd-${TCOS_KERNEL}	boolean	false
linux-image-${TCOS_KERNEL}	linux-image-${TCOS_KERNEL}/preinst/bootloader-initrd-${TCOS_KERNEL}	boolean	false
linux-image-${TCOS_KERNEL}	linux-image-${TCOS_KERNEL}/postinst/create-kimage-link-${TCOS_KERNEL}	boolean	false
linux-image-${TCOS_KERNEL}	shared/kernel-image/really-run-bootloader	boolean	false
console-common	console-data/keymap/policy	select	Don't touch keymap
console-data	console-data/keymap/policy	select	Don't touch keymap
console-setup	console-setup/variant	select	USA
console-setup	console-setup/charmap	select	UTF-8
console-setup	console-setup/layoutcode	string	us
console-setup	console-setup/compose	select	No compose key
console-setup	console-setup/fontsize-text	select	16
console-setup	console-setup/optionscode	string	
console-setup	console-setup/layout	select	USA
console-setup	console-setup/detect	detect-keyboard	
console-setup	console-setup/detected	note	
console-setup	console-setup/variantcode	string	
console-setup	console-setup/codesetcode	string	Uni1
console-setup	console-setup/dont_ask_layout	error	
console-setup	console-setup/modelcode	string	pc105
console-setup	console-setup/ask_detect	boolean	false
console-setup	console-setup/altgr	select	No AltGr key
console-setup	console-setup/ttys	string	/dev/tty[1-6]
console-setup	console-setup/model	select	Generic 105-key (Intl) PC
console-setup	console-setup/fontsize-fb	select	16
console-setup	console-setup/switch	select	No temporary switch
console-setup	console-setup/codeset	select	. Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic
console-setup	console-setup/toggle	select	No toggling
console-setup	console-setup/fontface	select	Fixed
console-setup	console-setup/fontsize	string	16
dash	dash/sh	boolean	false
EOF

  createEmptyCMD /sbin/start-stop-daemon
  createEmptyCMD /usr/sbin/invoke-rc.d

  cat << EOC | chroot ${TCOS_CHROOT}
apt-get $APT_OPTS update
apt-get $APT_OPTS dist-upgrade
apt-get install $APT_OPTS tcos-keyring
apt-get $APT_OPTS update
apt-get install $APT_OPTS ${DISTRO_PACKAGES} 
apt-get clean
debconf-set-selections /preseed
rm -f /preseed
apt-get $APT_OPTS upgrade
apt-get $APT_OPTS remove --purge grub grub-pc
EOC



  if [ "${DISTRIBUTION}" = "ubuntu" ]; then

  cat << EOC | chroot ${TCOS_CHROOT}
apt-get install $APT_OPTS linux-image-${TCOS_KERNEL} 
apt-get install $APT_OPTS linux-ubuntu-modules-${TCOS_KERNEL}
apt-get install $APT_OPTS linux-restricted-modules-${TCOS_KERNEL} 
apt-get install $APT_OPTS ${TCOS_PACKAGES}
apt-get install $APT_OPTS tcos-extra-modules-${TCOS_KERNEL}
apt-get clean
/etc/init.d/dropbear stop || true
EOC

  # need umount this directory to allow remove later chroot from distros grather than gutsy
  #if [ ${TCOS_DISTRO} = "gutsy" -o ${TCOS_DISTRO} = "hardy" ]; then
  if [ -d ${TCOS_CHROOT}/lib/modules/${TCOS_KERNEL}/volatile/ ]; then
    umount ${TCOS_CHROOT}/lib/modules/${TCOS_KERNEL}/volatile/ >/dev/null 2>&1
  fi
  
  ######################################
  else # DISTRO != ubuntu
  cat << EOC | chroot ${TCOS_CHROOT}
apt-get install $APT_OPTS linux-image-${TCOS_KERNEL}
apt-get install $APT_OPTS tcos-extra-modules-${TCOS_KERNEL}
apt-get install $APT_OPTS ${TCOS_PACKAGES}
apt-get clean
/etc/init.d/dropbear stop || true
rm -f /preseed
EOC
  fi

  touch ${TCOS_CHROOT}/etc/tcos/chroot
  umount -l ${TCOS_CHROOT}/proc
  umount -l ${TCOS_CHROOT}/sys
  # remove udevadm diversion
  chrootexit
} # end of chrootcreate()

###############################################################################

chrootenter() {
cat /etc/resolv.conf > ${TCOS_CHROOT}/etc/resolv.conf
[ ! -e ${TCOS_CHROOT}/sbin/start-stop-daemon ] &&   createEmptyCMD /sbin/start-stop-daemon
[ ! -e ${TCOS_CHROOT}/usr/sbin/invoke-rc.d ] && createEmptyCMD /usr/sbin/invoke-rc.d

if [ ! -e /sbin/udevadm.original ]; then
  chroot ${TCOS_CHROOT} dpkg-divert --package initramfs-tools-tcos \
                                    --add --rename --quiet \
                                    --divert /sbin/udevadm.original \
                                    /sbin/udevadm
  createEmptyCMD /sbin/udevadm
fi
}

chrootexit() {
if [ -e ${TCOS_CHROOT}/sbin/udevadm.original ]; then
  rm -f ${TCOS_CHROOT}/sbin/udevadm
  chroot ${TCOS_CHROOT} dpkg-divert --package initramfs-tools-tcos \
                                    --remove --rename --quiet \
                                    --divert /sbin/udevadm.original \
                                    /sbin/udevadm
fi
}

chrootupdate() {
  chrootenter

# copy console keymap
if [ -e /etc/console/boottime.kmap.gz ]; then
	mkdir -p ${TCOS_CHROOT}/etc/console
	cp /etc/console/boottime.kmap.gz ${TCOS_CHROOT}/etc/console
fi
if [ -e /etc/console-setup/boottime.kmap.gz ]; then
	mkdir -p ${TCOS_CHROOT}/etc/console-setup
	cp /etc/console-setup/boottime.kmap.gz ${TCOS_CHROOT}/etc/console-setup/
fi
if [ -e /etc/console-setup/cached.kmap.gz ]; then
	mkdir -p ${TCOS_CHROOT}/etc/console-setup
	cp /etc/console-setup/cached.kmap.gz ${TCOS_CHROOT}/etc/console-setup/
fi

  cat << EOC | chroot ${TCOS_CHROOT}
apt-get update
apt-get $APT_OPTS dist-upgrade
apt-get install $APT_OPTS ${TCOS_PACKAGES}
apt-get install $APT_OPTS ${DISTRO_PACKAGES}
apt-get clean
EOC

# need umount this directory to allow remove later chroot from distros grather than gutsy
if [ -d ${TCOS_CHROOT}/lib/modules/${TCOS_KERNEL}/volatile/ ]; then
  umount ${TCOS_CHROOT}/lib/modules/${TCOS_KERNEL}/volatile/ >/dev/null 2>&1
fi

touch ${TCOS_CHROOT}/etc/tcos/chroot
chrootexit
}

###############################################################################

chrootinstallpkg() {
  chrootenter

  cat << EOC | chroot ${TCOS_CHROOT}
apt-get update
apt-get $APT_OPTS install $@
apt-get clean
EOC
  chrootexit
}

###############################################################################
chrootcp() {
  if [ -e "$1" ]; then
    mkdir -p "${TCOS_CHROOT}/$(dirname $1)"
    cp "$1" "${TCOS_CHROOT}/$(dirname $1)/"
  fi
}
chrootupdateimages() {
chrootenter
# remove udevadm diversion before gentcos
chrootexit

# copy some files
chrootcp /usr/share/tcos-core/lockscreen-custom.png
chrootcp /etc/default/console-setup
chrootcp /etc/default/keyboard
chrootcp /etc/adjtime
chrootcp /etc/hosts

TCOS_KERNEL=$(awk -F"=" '/^TCOS_KERNEL=/ {print $2}' ${TCOS_CHROOT}/etc/tcos/tcos.conf | sed 's/"//g')
if [ -f /etc/tcos/templates/tcosconfig.conf ]; then
  mkdir -p ${TCOS_CHROOT}/etc/tcos/templates/
  cp /etc/tcos/templates/tcosconfig.conf ${TCOS_CHROOT}/etc/tcos/templates/
  if grep -q "TCOS_KERNEL" ${TCOS_CHROOT}/etc/tcos/templates/tcosconfig.conf; then
    TCOS_KERNEL=$(awk -F"=" '/^TCOS_KERNEL=/ {print $2}' ${TCOS_CHROOT}/etc/tcos/templates/tcosconfig.conf | sed 's/"//g')
  fi
fi


mount --bind /proc ${TCOS_CHROOT}/proc

  cat << EOC | chroot ${TCOS_CHROOT}
gentcos ${GENTCOS_OPT}
EOC

umount -l ${TCOS_CHROOT}/proc

# this is exec outside chroot
rm -rf /var/lib/tcos/tftp/vmlinuz-${TCOS_KERNEL} \
       /var/lib/tcos/tftp/usr-${TCOS_KERNEL}.squashfs \
       /var/lib/tcos/tftp/initramfs-${TCOS_KERNEL} \
       /var/lib/tcos/tftp/linux-${TCOS_KERNEL}.nbi \
       /var/lib/tcos/fs-${TCOS_KERNEL}

[ ! -e /var/lib/tcos/tftp/vmlinuz-${TCOS_KERNEL} ] && \
	ln -s ${TCOS_CHROOT}/boot/vmlinuz-${TCOS_KERNEL} /var/lib/tcos/tftp/

[ ! -e /var/lib/tcos/tftp/usr-${TCOS_KERNEL}.squashfs ] && \
	ln -s ${TCOS_CHROOT}/var/lib/tcos/tftp/usr-${TCOS_KERNEL}.squashfs /var/lib/tcos/tftp/

[ ! -e /var/lib/tcos/tftp/initramfs-${TCOS_KERNEL} ] && \
	[ -e ${TCOS_CHROOT}/var/lib/tcos/tftp/initramfs-${TCOS_KERNEL} ] && \
	ln -s ${TCOS_CHROOT}/var/lib/tcos/tftp/initramfs-${TCOS_KERNEL} /var/lib/tcos/tftp/

[ ! -e /var/lib/tcos/tftp/linux-${TCOS_KERNEL}.nbi ] && \
	[ -e ${TCOS_CHROOT}/var/lib/tcos/tftp/linux-${TCOS_KERNEL}.nbi ] && \
	ln -s ${TCOS_CHROOT}/var/lib/tcos/tftp/linux-${TCOS_KERNEL}.nbi /var/lib/tcos/tftp/

# NFS files and dirs
[ ! -e /var/lib/tcos/tftp/initramfs-${TCOS_KERNEL}-nfs ] && \
	[ -e ${TCOS_CHROOT}/var/lib/tcos/tftp/initramfs-${TCOS_KERNEL}-nfs ] && \
	ln -s ${TCOS_CHROOT}/var/lib/tcos/tftp/initramfs-${TCOS_KERNEL}-nfs /var/lib/tcos/tftp/

[ ! -d /var/lib/tcos/fs-${TCOS_KERNEL} ] && \
	[ -d ${TCOS_CHROOT}/var/lib/tcos/fs-${TCOS_KERNEL} ] && \
	ln -s ${TCOS_CHROOT}/var/lib/tcos/fs-${TCOS_KERNEL} /var/lib/tcos/

# generate pxelinux.cfg/default
parse_pxelinuxcfg
}

###############################################################################

#
# Script begins here
#

if [ "$#" = 0 ]; then
  echo "No parameters !!"
  usage
  exit 1
fi


OPTIONS=`getopt -o d:ko:r:v --long create,update,install:,update-images,help,version:,forcedistro:,arch:,flavour:,dir:,mirror:,securitymirror:,tcosmirror:,kversion:,gentcos:,debug,quiet,verbose,tcos-exp -n "$0" -- "$@"`

if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$OPTIONS"


while true; do
        case "$1" in
                --help) usage ; exit 0              ;;
                --version) TCOS_DISTRO=$2; shift 2 ;;
                --forcedistro) DISTRIBUTION=$2; shift 2;;
                --arch) TCOS_ARCH=$2 ; shift 2      ;;
                --flavour) TCOS_FLAVOUR=$2; shift 2 ;;
                --mirror) MIRROR=$2; shift 2    ;;
                --securitymirror) MIRROR2=$2; shift 2;;
                --tcosmirror) TCOS_MIRROR=$2; shift 2    ;;
                --dir) TCOS_CHROOT=$2 ; shift 2     ;;
                --kversion) TCOS_KERNEL=$2; shift 2   ;;
                --gentcos) GENTCOS_OPT=$2; shift 2   ;;
                --debug) echo "FIXME DEBUG"; shift  ;;
                --quiet) echo "FIXME QUIET"; shift  ;;
                --verbose) echo "FIXME VERBOSE";shift ;;
                --tcos-exp) TCOS_EXPERIMENTAL="experimental"; shift ;;

                --create) ACTION=create ; shift     ;;
                --update) ACTION=update ; shift     ;;
                --install) ACTION=installpkgs PKGS="$2"; shift 2;;
                --update-images) ACTION=update-images; shift;;

                --) shift ; break ;;
                *) usage; echo "Unknow option $1"; exit -1
                       ;;
        esac
done

# load conf with forces settings
set_conf

# save data in tcos-buildchroot.conf or load if chroot exists
if [ ! -f ${TCOS_CHROOT}/tcos-buildchroot.conf ]; then
    mkdir -p ${TCOS_CHROOT}
    echo "DISTRIBUTION=$DISTRIBUTION" >  ${TCOS_CHROOT}/tcos-buildchroot.conf
    echo "MIRROR=$MIRROR"             >> ${TCOS_CHROOT}/tcos-buildchroot.conf
    echo "MIRROR2=$MIRROR2"           >> ${TCOS_CHROOT}/tcos-buildchroot.conf
    echo "TCOS_MIRROR=$TCOS_MIRROR"   >> ${TCOS_CHROOT}/tcos-buildchroot.conf
    echo "TCOS_KERNEL=$TCOS_KERNEL"   >> ${TCOS_CHROOT}/tcos-buildchroot.conf
    echo "TCOS_DISTRO=$TCOS_DISTRO"   >> ${TCOS_CHROOT}/tcos-buildchroot.conf
    echo "TCOS_EXPERIMENTAL=$TCOS_EXPERIMENTAL"   >> ${TCOS_CHROOT}/tcos-buildchroot.conf
else
    . ${TCOS_CHROOT}/tcos-buildchroot.conf
fi

if [ "$ACTION" != "" ]; then
  case $ACTION in
     update)
       chrootupdate; exit
       ;;
     create)
       chrootcreate; exit
       ;;
     installpkgs)
       tmp=$(echo $PKGS | sed 's/,/ /g')
       chrootinstallpkg $tmp ; exit
       ;;
     update-images)
       chrootupdateimages; exit
       ;;
     *)
       echo "Error, unknow action: $ACTION"
       exit 1
       ;;
  esac
fi