golang.org/x/build@v0.0.0-20240506185731-218518f32b70/env/netbsd-386/make.bash (about)

     1  #!/bin/bash
     2  # Copyright 2016 The Go Authors. All rights reserved.
     3  # Use of this source code is governed by a BSD-style
     4  # license that can be found in the LICENSE file.
     5  
     6  # This script uses Anita (an automated NetBSD installer) for setting up
     7  # the VM. It needs the following things on the build host:
     8  #  - curl
     9  #  - qemu
    10  #  - cdrtools
    11  #  - GNU tar (not BSD tar)
    12  #  - Python 3
    13  #  - python-pexpect
    14  
    15  set -e -x
    16  
    17  ANITA_VERSION=2.10
    18  ARCH=i386
    19  RELEASE=9.3
    20  # The release that the packages have been built for.
    21  PKG_RELEASE=9.0_2022Q2
    22  
    23  # Must use GNU tar. On NetBSD, tar is BSD tar and gtar is GNU.
    24  TAR=tar
    25  if which gtar > /dev/null; then
    26    TAR=gtar
    27  fi
    28  
    29  LATEST_BUILD=`curl -Ls -w '%{url_effective}'  -o /dev/null https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/ | xargs basename`
    30  
    31  WORKDIR=work-NetBSD-${ARCH}
    32  VM_IMAGE=vm-image-netbsd-${ARCH}-${LATEST_BUILD}.tar.gz
    33  
    34  # Remove WORKDIR unless -k (keep) is given.
    35  if [ "$1" != "-k" ]; then
    36    rm -rf ${WORKDIR}
    37  fi
    38  
    39  # Download and build anita (automated NetBSD installer).
    40  if ! sha1sum -c anita-${ANITA_VERSION}.tar.gz.sha1; then
    41    curl -vO https://www.gson.org/netbsd/anita/download/anita-${ANITA_VERSION}.tar.gz
    42    sha1sum -c anita-${ANITA_VERSION}.tar.gz.sha1 || exit 1
    43  fi
    44  
    45  tar xfz anita-${ANITA_VERSION}.tar.gz
    46  cd anita-${ANITA_VERSION}
    47  python3 setup.py build
    48  cd ..
    49  
    50  env PYTHONPATH=${PWD}/anita-${ANITA_VERSION} python3 ../netbsd-amd64/mkvm.py ${ARCH} ${RELEASE} ${PKG_RELEASE}
    51  
    52  echo "Archiving wd0.img (this may take a while)"
    53  ${TAR} -Szcf ${VM_IMAGE} --transform s,${WORKDIR}/wd0.img,disk.raw, ${WORKDIR}/wd0.img
    54  echo "Done. GCE image is ${VM_IMAGE}."