github.com/coreos/rocket@v1.30.1-0.20200224141603-171c416fac02/scripts/pkg/build-pkgs.sh (about)

     1  #!/bin/bash
     2  
     3  ##
     4  ## build .deb and .rpm packages from an already-built
     5  ## version of rkt
     6  
     7  set -e
     8  set -x
     9  
    10  version=$1
    11  
    12  MAINTAINER=security@coreos.com
    13  LICENSE="APLv2"
    14  VENDOR="CoreOS, Inc."
    15  HOMEPAGE="https://www.github.com/rkt/rkt"
    16  #iteration is the package version; bump if you need to repackage without
    17  #changing the rkt version
    18  ITERATION="${ITERATION:-1}" 
    19  builddir="${BUILDDIR:-/opt/build-rkt}"
    20  
    21  function usage {
    22      echo "usage: BUILDDIR=<builddir> $0 <version>" >&2 
    23      exit 1
    24  }
    25  
    26  if [ ! -d $builddir ]; then
    27      echo "could not find build dir $builddir" >&2
    28      usage
    29  fi
    30  
    31  if [ -z $version ]; then
    32      echo "version not specified" >&2
    33      usage
    34  fi
    35  
    36  srcdir=`dirname "$0"`
    37  projectdir=$srcdir/../..
    38  
    39  ###################################
    40  ## INSTALL RKT
    41  #################################
    42  workdir=$(mktemp -d /tmp/rkt-pkg.XXXXXX)
    43  prefix=$workdir/rootfs
    44  mkdir -p $prefix
    45  
    46  ## install binary
    47  install -Dm755 $builddir/target/bin/rkt $prefix/usr/bin/rkt
    48  
    49  ## install stage1s
    50  for flavor in fly coreos kvm; do
    51      stage1_aci="$builddir/target/bin/stage1-${flavor}.aci"
    52      [[ -f "$stage1_aci" ]] || continue # skip nonexistent
    53      install -Dm644 $stage1_aci $prefix/usr/lib/rkt/stage1-images/stage1-${flavor}.aci
    54  done
    55  
    56  ## manpages & doc
    57  for f in $projectdir/dist/manpages/*; do 
    58      install -Dm644 -t $prefix/usr/share/man/man1 "${f}" 
    59  done
    60  
    61  for dir in . subcommands networking performance; do
    62      for f in $projectdir/Documentation/$dir/*.*; do
    63          install -Dm644 -t $prefix/usr/share/doc/rkt "${f}"
    64      done
    65  done
    66  
    67  install -Dm644 $projectdir/dist/bash_completion/rkt.bash $prefix/usr/share/bash-completion/completions/rkt
    68  install -Dm644 $projectdir/dist/init/systemd/tmpfiles.d/rkt.conf $prefix/usr/lib/tmpfiles.d/rkt.conf
    69  
    70  for unit in rkt-gc.{timer,service} rkt-metadata.{socket,service} rkt-api{.service,-tcp.socket}; do
    71      install -Dm644 -t $prefix/usr/lib/systemd/system/  $projectdir/dist/init/systemd/${unit}
    72  done
    73  
    74  ## Copy before and after-install
    75  cp $srcdir/*-{install,remove} $workdir/
    76  
    77  
    78  #######################
    79  ## BUILD THE PACKAGES
    80  #######################
    81  cd $builddir/target/bin
    82  fpm -s dir -t deb \
    83      -n "rkt" -v "$version" --iteration "$ITERATION" \
    84      --after-install $workdir/after-install \
    85      --before-install $workdir/before-install \
    86  	--after-remove $workdir/after-remove \
    87  	--before-remove $workdir/before-remove \
    88  	--after-upgrade $workdir/after-install \
    89      --license "$LICENSE" --vendor "$VENDOR" --url "$HOMEPAGE" -m "$MAINTAINER" --category utils \
    90      -d adduser \
    91      -d dbus \
    92      -d libc6 \
    93      -d systemd \
    94      -d iptables \
    95      --deb-suggests ca-certificates \
    96      -C ${prefix} 
    97  
    98  fpm -s dir -t rpm \
    99      -n "rkt" -v "$version" --iteration "$ITERATION" \
   100      --after-install $workdir/after-install \
   101      --before-install $workdir/before-install \
   102  	--after-remove $workdir/after-remove \
   103  	--before-remove $workdir/before-remove \
   104  	--after-upgrade $workdir/after-install \
   105      --license "$LICENSE" --vendor "$VENDOR" --url "$HOMEPAGE" -m "$MAINTAINER" --category utils \
   106      --provides rkt \
   107      -d '/usr/sbin/groupadd' \
   108      -C ${prefix} 
   109  
   110  rm -rf $workdir