Versions Compared

Key

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

...

Info

Теперь Вы можете запустить его в формате ./create_zone.sh <zone-name> <zone-ip-domain> <zone-ip-node> , например!:

./create_zone.sh zone02 192.168.0 3

...

Обновите файл /etc/apt/sources.list :

Code Block
languagebash
cat > /etc/apt/sources.list <<EOT
deb http://apt.dilos.org/dilos dg2-unstable main contrib non-free
deb http://apt.dilos.org/dilos du2-unstable main contrib non-free
EOT
apt-get update

...

Теперь получите зависимости. Для этого создайте скопируйте этот скрипт в файл, например, get_deps.sh и сделайте его исполняемым или выполните следующую команду:

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

#File create for save temporary values
>list_one
>list_two
>pkg_dep
>tmp0
>tmp1
>tmp
#
function get_depends()
{
        ## This function get depends for build component
     
  [ -z "\$(grep -f pkg_dep <<< \$1)" ] &&
 
      apt-get install -s \$1 2>/dev/null | grep Inst | awk '{print \$2}'| sort -u &&
    
   echo \$pkg >> pkg_dep
}
#
#
function all_dep()
{
  ##  This    ##This recursion function for get recursion depends for build conmponents
        for pkg in \$@; do
                all_dep \$all_dep \$(get_depends \$pkg)
 
      done
}

## Loop for get depends for build components
while read component; do
        if [[ "" == "\$component" ]]; then
       
       continue
     
  fi
        apt-get --dry-run build-dep \$component 2>/dev/null | grep Inst | awk '{print \$2}' >> list_one
done < list_component

while read pkg; do

       if [[ "" == "\$pkg" ]]; then
    continue
  fi
  apt-get install -s   continue
        fi
        apt-get install -s \$pkg 2>/\$pkg 2>/dev/null | grep Inst | awk '{print \$2}' >> list_two
done < list_pkg_sec

cat list_one       >> tmp0
cat list_two       >> tmp0
cat list_component >> tmp0
cat list_pkg_sec   >> tmp0
cat tmp0 | sort -u >> tmp1

## Loop for get depends, use function 'all_dep'
while read pkg; do
        if [[ "" == "\$pkg" ]]; then
  
            continue
        fi
 
      all_dep \$pkg >/dev/null
done < tmp1

cat pkg_dep        >> tmp1
cat tmp1 | sort -u >> tmp

while read pkg; do
  if      if [[ [[ "" == "\$pkg" ]]; then

              continue
        fi
        sudo apt-get download \$pkg
done < tmp
EOT

Сделайте его исполняемым и запустите:

Code Block
languagebash
chmod 777 ./get_deps.sh

Запустите его:

Code Block
languagebash
./get_deps.sh
exit

4. Создайте новую зону для создания локального репозитория

...

Code Block
languagebash
echo -n "Codename:  du2-prebuild
Suite:  unstableprebuild
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

...

Получите исходные файлы для локального репозитория, для чего создайте файл, например, get_sources.sh и сделайте его исполняемым (для работы скрипта требуется установленный пакет dpkg-dev):

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

COMPONENTS='main'
CODENAME='du2-prebuild'

while read component; do
        if [[ "" == "\$component" ]]; then
   
           continue
        fi
        apt-get source --download-only \$component
     
  reprepro -b /data/repo -C \$COMPONENTS includedsc \$CODENAME \$component*.dsc

       rm -rf \$component
done < /data/repo/pkg/list_component
EOT
chmod 777 ./get_sources.sh

...

Code Block
languagebash
cat > prepare.sh <<EOT
# by
Denis Kozadaev
apt-get clean
apt-get autoclean
apt-get remove libiconv-dev -y

APTLIST="/tmp/apt_sources.list"
APTLISTETC="/etc/apt/sources.list"

echo "" > \$APTLIST
echo "deb [trusted=yes] http://192.168.0.3/dilos du2-prebuild main contrib non-free" >> \$APTLIST
echo "deb-src [trusted=yes] http://192.168.0.3/dilos du2-unstableprebuild main contrib non-free" 2>/dev/null >> \$APTLIST

mv \$APTLIST \$APTLISTETC

apt-get update -y
test -f /var/lib/dpkg/lock && rm -f /var/lib/dpkg/lock
test -f /var/cache/apt/archives/lock && rm -f /var/cache/apt/archives/lock
dpkg --configure -a
rm -rf \${WORKSPACE} && mkdir -p \${WORKSPACE}
apt-get upgrade -y
env DEBIAN_FRONTEND=noninteractive apt-get install -y -f
env DEBIAN_FRONTEND=noninteractive apt-get install -y git openssh-server
oracle-jdk
EOT
chmod 777 ./prepare.sh

...

Code Block
languagebash
./prepare.sh

6. Постройте компоненты

Эти переменные зарегистрированы в Jenkins:

  1. {WORKSPACE}

  2. {COMPONENT}

  3. {JOBS}

В нашем случае в скрипте нужно объявить три переменные

Создайте файл, например, buildСкопируйте этот скрипт в файл, например, build_all.sh и сделайте его выполняемым или выполните команду:

Code Block
languagebash
cat > build_all.sh <<EOT
#!/bin/bash
# by Denis Kozadaev
COMPONENT=$1WORKDIR=/export/home/admin;
WORKSPACE=$2\${WORKDIR}/du2;
JOBS=$34;
umask 022
export WORKDIRCCACHE_DISABLE="/export/home/admin"
#export CCACHE_DIR="\${BUILD_RESULT}/.ccache"
#export CCACHE_SIZE="2G"
export CCACHE_DISABLE="true"
export WORKSPACE="\${WORKDIR}/du2"

set -x

"true"
echo '===================== ENVIRONMENT =================='
env

echo '===================== GET SOURCES =================='
test -L /etc/dpkg/origins/default || sudo ln -fs dilos /etc/dpkg/origins/dilos
test -f /usr/bin/gmake || sudo ln -fs make /usr/bin/gmake
git clone https://bitbucket.org/dilos/du2.git \${WORKSPACE}

echo '===================== GET PACKAGES =================='
cd \${WORKDIR}
export DEB_BUILD_OPTIONS="parallel= 2"
sudo -E apt-get update
#sudosudo apt-get install -y libssl1.0.2/du-unstable openssl/du-unstable tar/du-unstable --allow-downgrades
#sudoacl iputils-ping kbd ksh scheduler system-data-console-fonts traceroute gmake build-essential
DEBIAN_FRONTEND=nkvmoninteractive sudo -E apt-get install -f -y
libssl1.0.2/du-unstable openssl/du-unstable tar/du-unstable --allow-downgrades
#sudo apt-get install -y libbz2-1./du2-unstable --allow-downgrades
sudo apt-get install -y acl iputils-ping kbd ksh scheduler system-data-console-fonts traceroute gmake  build-essential
#sudo apt-get install -y acl iputils-ping kbd ksh scheduler system-data-console-fonts traceroute gmake  build-essential 
#sudo apt-get install -y libicu-dev/du-unstable libicu57/du-unstable icu-devtools/du-unstable --allow-downgrades

DEBIAN_FRONTEND=nkvmoninteractive sudo -E apt-get install -f -y
DEBIAN_FRONTEND=DEBIAN_FRONTEND=noninteractive sudo -E apt-get upgrade -y

if ! getent group shadow | grep -q '^shadow:[^:]*:42'; then
sudo -E groupadd -g 42 shadow 
fi

test -L /usr/lib/jvm/default-java || sudo -E /usr/bin/ln -fsE groupadd oracle-default-jdk /usr/lib/jvm/default-java
-g 42 shadow 
fi
sudo -E apt-get install -y libx11-6 libxi6 libxtst6
sudo -E /usr/bin/ln -fs libX11.so.6 /usr/lib/64/libX11.so.4
sudo -E /usr/bin/ln -fs libXi.so.6 /usr/lib/64/libXi.so.5
sudo -E /usr/bin/ln -fs libXtst.so.6 /usr/lib/64/libXtst.so.1.so.1
while read COMPONENT; do
  if [[ "" == "\$COMPONENT" ]]; then
    continue
  fi
  echo '======================================='
echo "${COMPONENT}"
test -d ${WORKSPACE}/components/${COMPONENT} || exit 1
#cd \${WORKSPACE}/components
#yes Y |sudo -E gmake setup= BUILD \${COMPONENT} =================='
  cd "\${WORKSPACE}/components/\${COMPONENT}"

#sudo -E gmake debclobber
#if (( \$? > 0 )); then
#exit 1
#fi

#export LD_DEBUG=files,libs"
  sudo -E mkdir -p /data/repo/\${COMPONENT}
BLD_COMPONENT = BLD_COMPONENT=\${COMPONENT}-\$(date '+%Y-%m-%d')
  BUILD_RESULT=/data/repo/\${COMPONENT}
  export COMPONENT_RESULT=\`echo \${BLD_COMPONENT} | sed -e 's;/;-;'\`
  sudo -E /usr/bin/rm -rf \${BUILD_RESULT}/du/\${COMPONENT_RESULT}
  mkdir -p \${BUILD_RESULT}/du/\${COMPONENT_RESULT} 2>/dev/null

#export SHELLOPTS= 

sudo -E gmake JOBS=\${JOBS} WS_DEBS=\${BUILD_RESULT}/du/\${COMPONENT_RESULT} deb
#fakeroot 2>/dev/null
  sudo -E gmake JOBS=\${JOBS} WS_DEBS=\${BUILD_RESULT}/du/\${COMPONENT_RESULT} deb
#| tee \${WORKSPACE}/log.${COMPONENT}.txt RES=\$?
  echo '===================== BUILD DEBCLOBBER =================='
  sudo -E gmake debclobber
  if (( \$RES > 0 )); then
    echo '"===================== ERROR : \${RES} =================='"
  sudo -E apt-getexit install1
-y oracle-jdk iffi
((done \$RES > 0 )); then
exit 1
fi
EOT
< /data/repo/pkg/list_component
echo '===================== DONE =================='
EOT

Сделайте его исполняемым и запустите:

Code Block
languagebash
chmod 777 ./build_all.sh

Запустите его:

Code Block
languagebash
./build_all.sh lynx /export/home/admin/du2 4

После сборки компонент Вы можете проверить их установку в отдельной новой зоне.

...