Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
cat > create_zone.sh <<SCRIPT
#!/bin/bash

TYPE_ZONE=\$1
IP=\$2
SER=\$3

cat > \${HOME}/\${TYPE_ZONE}.cmd <<EOT
create
set zonename=\${TYPE_ZONE}
set zonepath=/zones/\${TYPE_ZONE}
set autoboot=false
set ip-type=exclusive
add net
set physical=iz\${SER}
set global-nic=vsw0
add property (name=ip,value="\${IP}.\${SER}")
add property (name=gateway,value="\${IP}.254")
add property (name=netmask,value="255.255.255.0")
add property (name=primary,value="true")
end
add attr
set name=resolvers
set type=string
set value=8.8.8.8
end
add fs
set dir="/export/home/admin"
set special="/export/home/admin"
set type="lofs"
end
add fs
set dir="/export/builds"
set special="/export/builds"
set type="lofs"
end
add fs
set dir="/data/repo"
set special="/data/repo"
set type="lofs"
end
verify
commit
exit
EOT
zonecfg -z \${TYPE_ZONE} -f \${HOME}/\${TYPE_ZONE}.cmd
zoneadm 2>&1 | /usr/bin/tee -z \a /var/tmp/${TYPE_ZONE} install &&-bts.log
zoneadm -z \${TYPE_ZONE} boot
echo "127.0.0.1 localhost.\ install 2>&1 | /usr/bin/tee -a /var/tmp/${TYPE_ZONE} \${TYPE-bts.log
zoneadm -z ${TYPE_ZONE} boot 2>&1 | /usr/bin/tee -a /var/tmp/${TYPE_ZONE}-bts.log
echo "127.0.0.1 localhost.${TYPE_ZONE} ${TYPE_ZONE}" >> /zones/\${TYPE_ZONE}/root/etc/hosts
SCRIPT

...

res=$(grep -e 'WARNING:' -e 'warning:' -e 'W:' -e 'error:' -e 'E:' -e 'cannot' /var/tmp/${TYPE_ZONE}-bts.log | sort -u)
if [[ "$res" == "" ]]; then
  echo " =========== Zone ${TYPE_ZONE} is successfully created and ready to use ============="
else
  echo " =========== Zone ${TYPE_ZONE} creation log ============="
  echo "$res"
  echo "$res" | sed '/W: --force-yes is deprecated/d; /\/man\//d'
  if [[ "$res" != "" ]]; then
    echo " ========================================================"
    echo "Please stop and report about zone bootstrap errors!"
  fi
fi
SCRIPT

Make it executable:

Code Block
languagebash
chmod 777 ./create_zone.sh

Info

Now you will be able to run it with the format of ./create_zone.sh <zone-name> <zone-ip-domain> <zone-ip-node> , for example!:

./create_zone.sh zone02 192.168.0 3

...

Code Block
languagebash
echo -n "Codename:  du2-prebuild
Suite:  prebuild
Version: 2.0
Origin: DilOS
Label: DilOS prebuild
Description: DilOS Prebuild Repository
Architectures: solaris-i386 solaris-sparc source
Components: main contrib non-free
##SignWith: default
DebIndices: Packages Release . .gz .bz2 .xz
DscIndices: Sources Release . .gz .bz2 .xz
Contents: . .gz .bz2 .xz
" > /data/repo/conf/distributions
Note

Workaround : For local repository creation you need reprepro of version 5.3 or higher. For the moment it is absent in DU2. So, till it is not there you need to get it from another place with help of the following commands:

mv /etc/apt/sources.list /etc/apt/sources.list.bak

cat > /etc/apt/sources.list <<EOT

deb http://10.20.50.188/dilos du3-unstable main contrib non-free

EOT

apt-get update && apt-get install reprepro -y

mv /etc/apt/sources.list.bak /etc/apt/sources.list

apt-get update

: solaris-i386 solaris-sparc source
Components: main contrib non-free
##SignWith: default
DebIndices: Packages Release . .gz .bz2 .xz
DscIndices: Sources Release . .gz .bz2 .xz
Contents: . .gz .bz2 .xz
" > /data/repo/conf/distributions

5. Create the local repository:

...

Expand
titleRunning with the screen utility

If you are connected by SSH and would like to turn off SSH session or even temporary turn off your computer, then you have enter the following command for tests running:

Code Block
screen ./make_repo.sh

Then you can in any time press Ctrl-A d and after that close your SSH session.

When you would like to get back, login again to SSH please and enter the command:

Code Block
screen -r

...

Code Block
languagebash
cat > build_all.sh <<EOT
#!/bin/bash

BLD_PARALLEL="4"
WORKSPACE=/export/home/admin/du2

#STOP_ON_ERROR=1
STOP_ON_ERROR=0
#GCC_COMPILER="gcc-6"
GCC_COMPILER=""

# Build a component: \$1 - component name, \$2 - stop-on-error flag
function build_component {
  local START_TIME
  local END_TIME
  local BLD_RESULT

  BLD_RESULT="/data/repo/du/\$1"
  test -z "\$1" && exit 1
  test -d \${BLD_RESULT} && rm -rf \${BLD_RESULT}
  DEB_BUILD_OPTIONS="nocheck notest parallel=\${BLD_PARALLEL}"
  export DEB_BUILD_OPTIONS
  test -d \${WORKSPACE}/\$1 && rm -rf \${WORKSPACE}/\$1
  mkdir -p \${WORKSPACE}/\$1
  cd \${WORKSPACE}/\$1/\$1
  START_TIME=\$(date +%s)
  echo "====================== \$1 ======================"  | tee berror.log
  if [[ \$2 -eq 0 ]]; then
    apt-get build-dep -y \$1 >> berror.log || return 0 2>&1
    apt-get source --compile \$1 >> berror.log || return 0 2>&1
  else
    apt-get build-dep -y \$1 >> berror.log || return 1 2>&1
    apt-get source --compile \$1 >> berror.log || return 1 2>&1
  fi
  END_TIME=\$(date +%s)
  printf     apt-get source --compile"%06d %s\\n" \$((\${END_TIME} - \${START_TIME})) \$1 >> berror.log || return 1 2>&1
  fi\${WORKSPACE}/tmpbt.log
  mkdir -p \${BLD_RESULT}
  cp -ax *.deb \${BLD_RESULT}/ || exit 1
  cp -ax *.changes \${BLD_RESULT}/ || exit 1
  cp -ax *.buildinfo \${BLD_RESULT}/ || exit 1

}

if [[ "\$GCC_COMPILER" != "" ]]; then
  echo "====================== Building GCC ======================"
  build_component \$GCC_COMPILER 1
  if [[ \$? -eq 1 ]]; then
    exit 1
  fi
  dpkg -i 1
  fi
  dpkg -i \$WORKSPACE/\$GCC_COMPILER/*.deb
fi
if [[ ! -f \$WORKSPACE/build_components ]]; then
  cp /data/repo/pkg/list_component \$WORKSPACE/\$GCC_COMPILER/*.deb
fi
build_components
fi
rm -f tmpbt.log
while read COMP; do
  if [[ "" == "\$COMP" ]] || [[ "\$GCC_COMPILER" == "\$COMP" ]]; then
    continue
  fi
  build_component \$COMP \$STOP_ON_ERROR
  if [[ \$? -eq 1 ]]; then
    exit 1
  fi
done < /data/repo/pkg/list_component\$WORKSPACE/build_components
sort tmpbt.log > build_components
sed -i 's/^[0-9]* //g' build_components
EOT

If you’d like stop process on the first error, put 1 the STOP_ON_ERROR variable STOP_ON_ERROR=1. In other case it will build all components one-by-one regardless of errors. And in every component folder theberror.log file will be created, where build errors will be stored.

...

Expand
titleRunning with the screen utility

If you are connected by SSH and would like to turn off SSH session or even temporary turn off your computer, then you have enter the following command for tests running:

Code Block
screen ./build_all.sh

Then you can in any time press Ctrl-A d and after that close your SSH session.

When you would like to get back, login again to SSH please and enter the command:

Code Block
screen -r

...