summaryrefslogtreecommitdiff
path: root/scripts/build-docker-subpackages
blob: 84e5333c7501cb5d0f636981f204f5703489f03f (plain)
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
#!/bin/bash 
#set -x
if [ ! -d "packages" ]; then
  echo "This script needs to be executed inside the top root of vyos-build"
  exit 1
fi

status_start() {
echo -ne "[    ] $1"
}
status_ok() {
echo -ne "\r[\e[32m OK \e[39m]\n"
}

status_fail() {
echo -ne "\r[\e[31mFAIL\e[39m]\n"
}

status_skip() {
echo -ne "\r[SKIP] $1\n"
}

error_msg() {
echo -ne "      $1\n"
}

echo "Cleaning up buildfiles..."
rm -rf packages/*.deb
rm -rf packages/*.changes
echo "-----------------------------------------------------"
echo "Starting build process for all packages"
echo ""
for PKG in mdns-repeater \
           pmacct \
           udp-broadcast-relay \
           vyatta-bash \
           vyatta-cfg \
           vyatta-cfg-firewall \
           vyatta-cfg-op-pppoe \
           vyatta-cfg-qos \
           vyatta-cfg-quagga \
           vyatta-cfg-system \
           vyatta-cfg-vpn \
           vyatta-cluster \
           vyatta-config-mgmt \
           vyatta-config-migrate \
           vyatta-conntrack \
           vyatta-conntrack-sync \
           vyatta-eventwatch \
           vyatta-iproute \
           vyatta-ipv6-rtradv \
           vyatta-lldp \
           vyatta-nat \
           vyatta-netflow \
           vyatta-op \
           vyatta-op-dhcp-server \
           vyatta-op-firewall \
           vyatta-op-qos \
           vyatta-op-quagga \
           vyatta-op-vpn \
           vyatta-openvpn \
           vyatta-ravpn \
           vyatta-vrrp \
           vyatta-wanloadbalance \
           vyatta-webgui \
           vyatta-webproxy \
           vyatta-wireless \
           vyatta-wirelessmodem \
           vyatta-zone \
           vyos-keepalived \
           vyos-nhrp \
           vyos-pppoe-server \
           vyos-strongswan \
           vyos-world \
           ; do
  if [ -d "packages/$PKG/debian" ]; then
    status_start "Building package: $PKG"
    docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/$PKG \
               --sysctl net.ipv6.conf.lo.disable_ipv6=0 \
               vyos-builder \
               dpkg-buildpackage -uc -us -tc -b >packages/$PKG.buildlog 2>&1
    if [ $? -ne 0 ]; then
      status_fail
      error_msg "Failed to build package $PKG, look in $PKG.buildlog to examine the fault\n"
    else
      status_ok
    fi
  else
    status_skip "No source for: $PKG"
  fi
done

# KERNEL
if [ -f "packages/vyos-kernel/Makefile" ]; then
  status_start "Building-package: vyos-kernel"
  docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/vyos-kernel \
               --sysctl net.ipv6.conf.lo.disable_ipv6=0 \
               vyos-builder \
               bash -c '../../scripts/build-kernel' >packages/vyos-kernel.buildlog 2>&1
  if [ $? -ne 0 ]; then
    status_fail
    error_msg "Failed to build package vyos-kernel, look in vyos-kernel.buildlog to examine the fault\n"
  else
    VERSION=$(grep "^VERSION" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
    PATCHLEVEL=$(grep "^PATCHLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
    SUBLEVEL=$(grep "^SUBLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
    ARCH=$(dpkg --print-architecture)
    sed -i.bak "s/--linux-packages .* \\\/--linux-packages linux-image-$VERSION\.$PATCHLEVEL\.$SUBLEVEL \\\/" scripts/live-build-config 
    status_ok
  fi
else
  status_skip "No source for: vyos-kernel"
fi



# WIREGUARD
if [ -d "packages/vyos-wireguard/debian" ]; then
  if [ -f "packages/vyos-kernel/Makefile" ]; then
    status_start "Building package: vyos-wireguard"
    if  grep -q "KBUILD_OUTPUT" packages/vyos-kernel/Makefile; then
      VERSION=$(grep "^VERSION" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
      PATCHLEVEL=$(grep "^PATCHLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
      SUBLEVEL=$(grep "^SUBLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
      ARCH=$(dpkg --print-architecture)
      echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > packages/vyos-wireguard/debian/wireguard-modules.install
      docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/vyos-wireguard \
                 --sysctl net.ipv6.conf.lo.disable_ipv6=0 \
                 vyos-builder \
                 bash -c 'KERNELDIR=/vyos/packages/vyos-kernel dpkg-buildpackage -uc -us -tc -b' >packages/vyos-wireguard.buildlog 2>&1
      if [ $? -ne 0 ]; then
        status_fail
        error_msg "Failed to build package vyos-wireguard, look in vyos-wireguard.buildlog to examine the fault\n"
      else
        status_ok
      fi
    else
      status_fail
      error_msg "Failed to build package vyos-wireguard, no kernel source found\n"
    fi
  else
    seeor_msg "Something wrong with the kernel module?"
  fi
else 
    status_skip "No source for: vyos-wireguard"
fi