github.com/pquerna/agent@v2.1.8+incompatible/scripts/utils/build-linux-package.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  if [[ ${#} -lt 4 ]]
     5  then
     6    echo "Usage: ${0} [type] [arch] [binary] [version] [revision]" >&2
     7    exit 1
     8  fi
     9  
    10  function info {
    11    echo -e "\033[35m$1\033[0m"
    12  }
    13  
    14  PACKAGE_TYPE=${1}
    15  BUILD_ARCH=${2}
    16  BUILD_BINARY_PATH=${3}
    17  VERSION=${4}
    18  REVISION=${5}
    19  
    20  NAME="buildkite-agent"
    21  MAINTAINER="dev@buildkite.com"
    22  URL="https://buildkite.com/agent"
    23  DESCRIPTION="The Buildkite Agent is an open-source toolkit written in Golang for securely running build jobs on any device or network"
    24  LICENCE="MIT"
    25  VENDOR="Buildkite"
    26  
    27  if [ "$BUILD_ARCH" == "amd64" ]; then
    28    ARCH="x86_64"
    29  elif [ "$BUILD_ARCH" == "386" ]; then
    30    ARCH="i386"
    31  elif [ "$BUILD_ARCH" == "arm" ]; then
    32    ARCH="arm"
    33  elif [ "$BUILD_ARCH" == "armhf" ]; then
    34    ARCH="armhf"
    35  elif [ "$BUILD_ARCH" == "arm64" ]; then
    36    ARCH="arm64"
    37  else
    38    echo "Unknown architecture: $BUILD_ARCH"
    39    exit 1
    40  fi
    41  
    42  DESTINATION_PATH="$PACKAGE_TYPE"
    43  
    44  PACKAGE_NAME=$NAME"_"$VERSION"-"$REVISION"_"$ARCH".$PACKAGE_TYPE"
    45  PACKAGE_PATH="$DESTINATION_PATH/$PACKAGE_NAME"
    46  
    47  mkdir -p $DESTINATION_PATH
    48  
    49  info "Building $PACKAGE_TYPE package $PACKAGE_NAME to $DESTINATION_PATH"
    50  
    51  bundle exec fpm -s "dir" \
    52    -t "$PACKAGE_TYPE" \
    53    -n "$NAME" \
    54    --url "$URL" \
    55    --maintainer "$MAINTAINER" \
    56    --architecture "$ARCH" \
    57    --license "$LICENCE" \
    58    --description "$DESCRIPTION" \
    59    --vendor "$VENDOR" \
    60    --depends "git-core" \
    61    --verbose \
    62    --debug \
    63    --force \
    64    --category admin \
    65    --deb-priority optional \
    66    --deb-compression bzip2 \
    67    --rpm-compression bzip2 \
    68    --rpm-os linux \
    69    --before-install "packaging/linux/scripts/before-install.sh" \
    70    --after-install "packaging/linux/scripts/after-install-and-upgrade.sh" \
    71    --before-remove "packaging/linux/scripts/before-remove.sh" \
    72    --after-remove "packaging/linux/scripts/after-remove.sh" \
    73    --before-upgrade "packaging/linux/scripts/before-upgrade.sh" \
    74    --after-upgrade "packaging/linux/scripts/after-install-and-upgrade.sh" \
    75    -p "$PACKAGE_PATH" \
    76    -v "$VERSION" \
    77    --iteration "$REVISION" \
    78    "./$BUILD_BINARY_PATH=/usr/bin/buildkite-agent" \
    79    "templates/bootstrap.sh=/usr/share/buildkite-agent/bootstrap.sh" \
    80    "packaging/linux/root/=/"
    81  
    82  echo ""
    83  echo -e "Successfully created \033[33m$PACKAGE_PATH\033[0m 👏"
    84  echo ""
    85  
    86  if [ "$PACKAGE_TYPE" == "deb" ]; then
    87    echo "    # To install this package"
    88    echo "    $ sudo dpkg -i $PACKAGE_PATH"
    89    echo ""
    90    echo "    # To uninstall"
    91    echo "    $ sudo dpkg --purge $NAME"
    92  elif [ "$PACKAGE_TYPE" == "rpm" ]; then
    93    echo "    # To install this package"
    94    echo "    $ sudo rpm -i $PACKAGE_PATH"
    95    echo ""
    96    echo "    # To uninstall"
    97    echo "    $ sudo rpm -ev $NAME"
    98  fi
    99  
   100  echo ""