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

     1  #!/bin/bash
     2  
     3  ###########################################################################
     4  # Packaging script which creates standalone package.
     5  #
     6  # Usage:
     7  #> bin/package_standalone <os>
     8  #
     9  # Package (specific OS: linux, darwin, windows):
    10  #> bin/package_standalone linux
    11  #
    12  # Package (specific binary):
    13  #> BINARY=build/myst/myst_darwin_amd64 bin/package_standalone darwin
    14  
    15  set -e
    16  
    17  source bin/helpers/output.sh
    18  source bin/helpers/functions.sh
    19  
    20  OS=$1
    21  if [[ ! "$OS" =~ ^(linux|darwin|windows)$ ]]; then
    22      print_error "Missing OS! Should be: linux, darwin or windows"
    23      exit 1
    24  fi
    25  
    26  BINARY=${BINARY:-"build/myst/myst"}
    27  DIR_BUILD="build/package"
    28  mkdir -p $DIR_BUILD
    29  
    30  # Put all files to package directory (to avoid preserving directory structure)
    31  printf "Building Standalone package for OS '$OS' ..\n"
    32  DIR_TEMP=`mktemp -d ${DIR_BUILD}/${tempname}.XXXXXX`
    33  
    34  if [ "$OS" == "windows" ]; then
    35      cp -vp ${BINARY} ${DIR_TEMP}/myst.exe
    36  else
    37      cp -vp ${BINARY} ${DIR_TEMP}/myst
    38  fi
    39  copy_config $OS $DIR_TEMP
    40  if [ "$OS" == "windows" ]; then
    41      cp -vp build/myst_supervisor/myst_supervisor.exe ${DIR_TEMP}/myst_supervisor.exe
    42  else
    43      cp -vp build/myst_supervisor/myst_supervisor ${DIR_TEMP}/myst_supervisor
    44  fi
    45  
    46  # Tarball package directory
    47  if [ "$OS" == "windows" ]; then
    48      PACKAGE_FILE="${DIR_BUILD}/`basename -s .exe ${BINARY}`.zip"
    49      (cd ${DIR_TEMP} && zip -r - .) > ${PACKAGE_FILE}
    50  else
    51      PACKAGE_FILE="${DIR_BUILD}/`basename ${BINARY}`.tar.gz"
    52      tar -zcv -f ${PACKAGE_FILE} -C ${DIR_TEMP} .
    53  fi
    54  rm -rf ${DIR_TEMP}
    55  
    56  print_success "Standalone package '$PACKAGE_FILE' complete!"
    57