Last active
August 18, 2021 07:05
-
-
Save wolfeidau/6761104 to your computer and use it in GitHub Desktop.
Build nodejs from source and assemble a deb package which installs on the Raspberry pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -o errtrace | |
node_version="0.10.20" | |
source_bundle="http://nodejs.org/dist/v${node_version}/node-v${node_version}.tar.gz" | |
# store the location of the base working area. | |
pushd . | |
curl ${source_bundle} | tar xvz | |
temp_dir=$(mktemp -d) | |
# cross compile vars | |
# Toolchain pulled down from https://github.com/raspberrypi/tools | |
export PATH=$HOME/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin:$PATH | |
export TOOL_PREFIX="arm-bcm2708hardfp-linux-gnueabi" | |
export CC="${TOOL_PREFIX}-gcc" | |
export CXX="${TOOL_PREFIX}-g++" | |
export AR="${TOOL_PREFIX}-ar" | |
export RANLIB="${TOOL_PREFIX}-ranlib" | |
export LINK="${CXX}" | |
export CCFLAGS="-march=armv6j -mfpu=vfp -mfloat-abi=hard -DUSE_EABI_HARDFLOAT" | |
export CXXFLAGS="-march=armv6j -mfpu=vfp -mfloat-abi=hard -DUSE_EABI_HARDFLOAT" | |
export OPENSSL_armcap=6 | |
export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=false -Dv8_can_use_vfp2_instructions=true -Darm7=0 -Darm_vfp=vfp" | |
export VFP3=off | |
export VFP2=on | |
mkdir -p ${temp_dir}/usr | |
# navigate into the sources directory | |
cd node-v${node_version} | |
# configure and install | |
./configure --prefix=/usr --without-dtrace --dest-os=linux --without-snapshot | |
make -j4 install DESTDIR=${temp_dir} DESTCPU=arm | |
# copy over docs | |
mkdir -p ${temp_dir}/usr/share/doc/nodejs | |
for i in README.md doc/\* AUTHORS ChangeLog LICENSE | |
do | |
cp -R $i ${temp_dir}/usr/share/doc/nodejs | |
done | |
# back to the base working area. | |
popd | |
package_revision=${BUILD_NUMBER:-1} | |
package_version=${node_version}_${package_revision} | |
fpm -s dir -t deb -n nodejs -v ${package_version} -C ${temp_dir} \ | |
--deb-user root --deb-group root \ | |
--deb-compression xz \ | |
--description "Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications." \ | |
--category "web" \ | |
--url http://nodejs.org \ | |
--architecture all \ | |
-p nodejs-${package_version}_armhf.deb \ | |
-d "libstdc++6 (>= 4.7.2)" \ | |
usr/bin usr/lib usr/share |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment