github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/contrib/builder/deb/ppc64le/generate.sh (about) 1 #!/bin/bash 2 set -e 3 4 # This file is used to auto-generate Dockerfiles for making debs via 'make deb' 5 # 6 # usage: ./generate.sh [versions] 7 # ie: ./generate.sh 8 # to update all Dockerfiles in this directory 9 # or: ./generate.sh ubuntu-xenial 10 # to only update ubuntu-xenial/Dockerfile 11 # or: ./generate.sh ubuntu-newversion 12 # to create a new folder and a Dockerfile within it 13 14 cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 15 16 versions=( "$@" ) 17 if [ ${#versions[@]} -eq 0 ]; then 18 versions=( */ ) 19 fi 20 versions=( "${versions[@]%/}" ) 21 22 for version in "${versions[@]}"; do 23 echo "${versions[@]}" 24 distro="${version%-*}" 25 suite="${version##*-}" 26 from="ppc64le/${distro}:${suite}" 27 28 mkdir -p "$version" 29 echo "$version -> FROM $from" 30 cat > "$version/Dockerfile" <<-EOF 31 # 32 # THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/ppc64le/generate.sh"! 33 # 34 35 FROM $from 36 37 EOF 38 39 extraBuildTags='pkcs11' 40 runcBuildTags= 41 42 # this list is sorted alphabetically; please keep it that way 43 packages=( 44 apparmor # for apparmor_parser for testing the profile 45 bash-completion # for bash-completion debhelper integration 46 btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible) 47 build-essential # "essential for building Debian packages" 48 cmake # tini dep 49 curl ca-certificates # for downloading Go 50 debhelper # for easy ".deb" building 51 dh-apparmor # for apparmor debhelper 52 dh-systemd # for systemd debhelper integration 53 git # for "git commit" info in "docker -v" 54 libapparmor-dev # for "sys/apparmor.h" 55 libdevmapper-dev # for "libdevmapper.h" 56 libltdl-dev # for pkcs11 "ltdl.h" 57 libsqlite3-dev # for "sqlite3.h" 58 pkg-config # for detecting things like libsystemd-journal dynamically 59 vim-common # tini dep 60 ) 61 62 # trusty uses a different go package name then xenial and newer, so track that for later 63 goPackage= 64 case "$suite" in 65 trusty) 66 # ppc64le doesn't have go binaries, so install go to bootstrap go 67 # trusty doesn't have a ppc64le golang-go package 68 packages+=( golang-1.6 ) 69 goPackage='golang-1.6' 70 71 packages+=( libsystemd-journal-dev ) 72 ;; 73 *) 74 # libseccomp isn't available until ubuntu xenial and is required for "seccomp.h" & "libseccomp.so" 75 packages+=( golang-go ) 76 goPackage='golang-go' 77 78 packages+=( libseccomp-dev ) 79 packages+=( libsystemd-dev ) 80 ;; 81 esac 82 83 # buildtags 84 case "$suite" in 85 # trusty has no seccomp package 86 trusty) 87 runcBuildTags="apparmor selinux" 88 ;; 89 # ppc64le support was backported into libseccomp 2.2.3-2, 90 # so enable seccomp by default 91 *) 92 extraBuildTags+=' seccomp' 93 runcBuildTags="apparmor seccomp selinux" 94 ;; 95 esac 96 97 # update and install packages 98 echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile" 99 echo >> "$version/Dockerfile" 100 101 # ppc64le doesn't have an official downloadable binary as of go 1.6.2. so use the 102 # older packaged go(v1.6.1) to bootstrap latest go, then remove the packaged go 103 echo "# Install Go" >> "$version/Dockerfile" 104 echo "# ppc64le doesn't have official go binaries, so use a distro packaged version of go" >> "$version/Dockerfile" 105 echo "# to build go from source." >> "$version/Dockerfile" 106 echo "# NOTE: ppc64le has compatibility issues with older versions of go, so make sure the version >= 1.6" >> "$version/Dockerfile" 107 108 awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.ppc64le >> "$version/Dockerfile" 109 echo 'ENV GO_DOWNLOAD_URL https://golang.org/dl/go${GO_VERSION}.src.tar.gz' >> "$version/Dockerfile" 110 echo 'ENV GOROOT_BOOTSTRAP /usr/lib/go-1.6' >> "$version/Dockerfile" 111 echo >> "$version/Dockerfile" 112 113 echo 'RUN curl -fsSL "$GO_DOWNLOAD_URL" -o golang.tar.gz \' >> "$version/Dockerfile" 114 echo ' && tar -C /usr/local -xzf golang.tar.gz \' >> "$version/Dockerfile" 115 echo ' && rm golang.tar.gz \' >> "$version/Dockerfile" 116 echo ' && cd /usr/local/go/src && ./make.bash 2>&1 \' >> "$version/Dockerfile" 117 echo " && apt-get purge -y $goPackage && apt-get autoremove -y" >> "$version/Dockerfile" 118 echo >> "$version/Dockerfile" 119 120 echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile" 121 echo >> "$version/Dockerfile" 122 123 echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile" 124 echo >> "$version/Dockerfile" 125 126 # print build tags in alphabetical order 127 buildTags=$( echo "apparmor selinux $extraBuildTags" | xargs -n1 | sort -n | tr '\n' ' ' | sed -e 's/[[:space:]]*$//' ) 128 echo "ENV DOCKER_BUILDTAGS $buildTags" >> "$version/Dockerfile" 129 echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile" 130 done