github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/bin/package_debian (about)

     1  #!/bin/bash
     2  
     3  ###########################################################################
     4  # Packaging script which creates Debian package.
     5  #
     6  # Requirements:
     7  # - GOPATH must be set
     8  # - 'fpm' tool must be on the path (https://github.com/jordansissel/fpm)
     9  #
    10  # for macOS:
    11  # - brew install gnu-tar
    12  # - sudo gem install --no-ri --no-rdoc fpm
    13  #
    14  # To package a build, simple execute:
    15  #> bin/package_debian <version> <architecture>
    16  
    17  # Usage:
    18  #> bin/package_debian 0.0.1 amd64
    19  
    20  OS_DIR_BIN="/usr/bin"
    21  OS_DIR_CONFIG="/etc/mysterium-node"
    22  OS_DIR_DOC="/usr/share/doc/mysterium-node"
    23  OS_DIR_INSTALLATION="/usr/lib/mysterium-node/installation"
    24  OS_DIR_SUDOERS="/etc/sudoers.d"
    25  BINARY=${BINARY:-"build/myst/myst"}
    26  
    27  VERSION=$1
    28  if [ -z "$VERSION" ]; then
    29      printf "\e[0;31m%s\e[0m\n" "Missing version!"
    30      exit 1
    31  fi
    32  
    33  ARCH=$2
    34  if [ -z "$ARCH" ]; then
    35      printf "\e[0;31m%s\e[0m\n" "Missing architecture!"
    36      exit 1
    37  fi
    38  
    39  FPM_BIN=`which fpm`
    40  if [ ! -x "$FPM_BIN" ]; then
    41      printf "\e[0;31m%s\e[0m\n" "Missing tool 'fpm'!"
    42      exit 1
    43  fi
    44  
    45  DIR_BUILD="build/package"
    46  PACKAGE_FILE="${DIR_BUILD}/myst_linux_${ARCH}.deb"
    47  
    48  printf "Building Debian package '$PACKAGE_FILE' for architecture '$ARCH' ..\n" \
    49      && mkdir -p ${DIR_BUILD} \
    50      && rm -f ${PACKAGE_FILE} \
    51      && ${FPM_BIN} \
    52          --name="myst" \
    53          --description="Mysterium Node for decentralised VPN Network" \
    54          --url="https://mysterium.network/" \
    55          --vendor="MysteriumNetwork" \
    56          --license="GPL-3.0" \
    57          --version "$VERSION" \
    58          --architecture="$ARCH" \
    59          --package="$PACKAGE_FILE" \
    60          --depends "openvpn (>= 2.4.0)" \
    61          --depends "resolvconf" \
    62          --depends "ca-certificates" \
    63          --depends "iptables" \
    64          --depends "iproute2" \
    65          --depends "sudo" \
    66          --depends "debconf" \
    67          --depends "wireguard" \
    68          --deb-templates bin/package/installation/templates \
    69          --before-install bin/package/installation/pre-install.sh \
    70          --after-install bin/package/installation/post-install.sh \
    71          --after-remove bin/package/installation/post-uninstall.sh \
    72          -s dir -t deb \
    73          ${BINARY}=${OS_DIR_BIN}/myst \
    74          bin/package/config/linux/=${OS_DIR_CONFIG}/ \
    75          bin/package/config/common/=${OS_DIR_CONFIG}/ \
    76          bin/package/sudoers/=${OS_DIR_SUDOERS}/ \
    77          bin/package/installation/=${OS_DIR_INSTALLATION}/ \
    78          INSTALL.md=${OS_DIR_DOC}/
    79  
    80  if [ $? -ne 0 ] ; then
    81      printf "\e[0;31m%s\e[0m\n" "Failed to build Debian package!"
    82      exit 1
    83  fi
    84  
    85  debber deb:contents ${PACKAGE_FILE}
    86  
    87  printf "\e[0;32m%s\e[0m\n" "Debian packaging process for architecture '$ARCH' complete!"
    88  exit 0