mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 06:33:28 +00:00
Refactor distribute.sh into a Makefile
This commit is contained in:
parent
6a96506833
commit
eb7e8014bc
29
Makefile
Normal file
29
Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
distribute-win32: release/build/distrib/resin-cli-win32.zip
|
||||
distribute-darwin: release/build/distrib/resin-cli-darwin.tar.gz
|
||||
distribute-linux: release/build/distrib/resin-cli-linux.tar.gz
|
||||
|
||||
installer-win32: release/build/distrib/resin-cli-setup.exe
|
||||
|
||||
release/build/resin-cli-%:
|
||||
mkdir -p $@
|
||||
cp -rf bin build package.json $@ && rm -rf $@/bin/node
|
||||
cd $@ && RESIN_BUNDLE=$(subst resin-cli-,,`basename $@`) npm install --production --force
|
||||
flatten-packages $@
|
||||
|
||||
release/build/distrib/resin-cli-win32.zip: release/build/resin-cli-win32
|
||||
mkdir -p `dirname $@`
|
||||
cd $< && zip -r ../../../$@ .
|
||||
|
||||
release/build/distrib/resin-cli-darwin.tar.gz: release/build/resin-cli-darwin
|
||||
mkdir -p `dirname $@`
|
||||
tar fcz $@ -C `dirname $<` `basename $<`
|
||||
|
||||
release/build/distrib/resin-cli-linux.tar.gz: release/build/resin-cli-linux
|
||||
mkdir -p `dirname $@`
|
||||
tar fcz $@ -C `dirname $<` `basename $<`
|
||||
|
||||
release/build/distrib/resin-cli-setup.exe: release/installers/win32/resin-cli.nsi release/build/distrib/resin-cli-win32.zip
|
||||
makensis $<
|
||||
|
||||
clean:
|
||||
rm -rf release/build
|
@ -6,7 +6,7 @@
|
||||
!include "zipdll.nsh"
|
||||
|
||||
Name "Resin CLI"
|
||||
OutFile "..\..\build\distrib\setup-resin-cli.exe"
|
||||
OutFile "..\..\build\distrib\resin-cli-setup.exe"
|
||||
BrandingText "Resin.io"
|
||||
|
||||
InstallDir "$PROGRAMFILES\Resin.io\resin-cli"
|
||||
@ -31,14 +31,14 @@ InstallDir "$PROGRAMFILES\Resin.io\resin-cli"
|
||||
|
||||
Section "Install"
|
||||
SetOutPath $INSTDIR
|
||||
File "..\..\build\distrib\resin-cli-0.0.1-win32.zip"
|
||||
!insertmacro ZIPDLL_EXTRACT "$INSTDIR\resin-cli-0.0.1-win32.zip" "$INSTDIR" "<ALL>"
|
||||
Delete "$INSTDIR\resin-cli-0.0.1-win32.zip"
|
||||
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\resin-cli-0.0.1-win32\bin"
|
||||
File "..\..\build\distrib\resin-cli-win32.zip"
|
||||
!insertmacro ZIPDLL_EXTRACT "$INSTDIR\resin-cli-win32.zip" "$INSTDIR" "<ALL>"
|
||||
Delete "$INSTDIR\resin-cli-win32.zip"
|
||||
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\resin-cli-win32\bin"
|
||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||
SectionEnd
|
||||
|
||||
Section "Uninstall"
|
||||
RMDir /r "$INSTDIR"
|
||||
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\resin-cli-0.0.1-win32\bin"
|
||||
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\resin-cli-win32\bin"
|
||||
SectionEnd
|
||||
|
@ -1,74 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# http://stackoverflow.com/questions/1955505/parsing-json-with-sed-and-awk
|
||||
function parse_json() {
|
||||
echo $1 | sed -e 's/[{}]/''/g' | awk -F=':' -v RS=',' "\$1~/\"$2\"/ {print}" | sed -e "s/\"$2\"://" | tr -d "\n\t" | sed -e 's/\\"/"/g' | sed -e 's/\\\\/\\/g' | sed -e 's/^[ \t]*//g' | sed -e 's/^"//' -e 's/"$//'
|
||||
}
|
||||
|
||||
PACKAGE_JSON=`cat package.json`
|
||||
VERSION=$(parse_json "$PACKAGE_JSON" version)
|
||||
NAME=$(parse_json "$PACKAGE_JSON" name)
|
||||
OUTPUT=release/build
|
||||
|
||||
if [ -z flatten-packages ]; then
|
||||
echo "Missing flatten-packages npm module."
|
||||
echo "Install it with:"
|
||||
echo " $ npm install -g flatten-packages"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function print_banner() {
|
||||
local message=$1
|
||||
|
||||
echo ""
|
||||
echo $message
|
||||
echo ""
|
||||
}
|
||||
|
||||
function distribute() {
|
||||
local os=$1
|
||||
|
||||
local package="$NAME-$VERSION-$os"
|
||||
|
||||
print_banner "Copying necessary files"
|
||||
|
||||
# Copy all needed files
|
||||
mkdir -p $OUTPUT/$package
|
||||
|
||||
cp -rf bin $OUTPUT/$package
|
||||
|
||||
# TODO: Omit bin/node in a better way
|
||||
rm -rf $OUTPUT/$package/bin/node
|
||||
|
||||
cp -rf build $OUTPUT/$package
|
||||
cp -rf package.json $OUTPUT/$package
|
||||
|
||||
print_banner "Running npm install"
|
||||
|
||||
cd $OUTPUT/$package
|
||||
|
||||
RESIN_BUNDLE=$os npm install --production --force
|
||||
flatten-packages .
|
||||
|
||||
cd ..
|
||||
|
||||
mkdir -p distrib
|
||||
|
||||
print_banner "Compression package"
|
||||
|
||||
if [ "$os" == "win32" ]; then
|
||||
zip -r distrib/$package.zip $package
|
||||
else
|
||||
tar fcz distrib/$package.tar.gz $package
|
||||
tar fcj distrib/$package.tar.bz2 $package
|
||||
fi
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
# distribute "darwin"
|
||||
# distribute "linux"
|
||||
distribute "win32"
|
||||
# distribute "sunos"
|
||||
|
||||
tree $OUTPUT/distrib
|
Loading…
Reference in New Issue
Block a user