Skip to content

Commit

Permalink
Sync with armbian stable
Browse files Browse the repository at this point in the history
remove klipper installation
fix overlays in common.sh
  • Loading branch information
L Diaz committed Aug 9, 2020
1 parent 2864a3a commit 0c4a62f
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 43 deletions.
44 changes: 31 additions & 13 deletions boards/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ function add_overlay() {
echo "Overlay ${ov} was already added to /boot/armbianEnv.txt, skipping"
else
sed -i -e "/^overlays=/ s/$/ ${ov}/" /boot/armbianEnv.txt
fi
fi
else
sed -i -e "\$overlays=${ov}" /boot/armbianEnv.txt
#sed -i -e "\$overlays=${ov}" /boot/armbianEnv.txt
echo -e "overlays=${ov}" >> /boot/armbianEnv.txt
fi
# adding parameters at the end of the file
if [ ! -z $pars ] ; then
Expand Down Expand Up @@ -226,13 +227,14 @@ function install_octoprint_plugins() {
# $1 -> user
function install_mjpgstreamer() {
local user=$1
pushd /home/$user
su -l $user -c "git clone --depth 1 $MJPGSTREAMER_REPO mjpg-streamer"
popd
#pushd /home/$user
#su -l $user -c "git clone --depth 1 $MJPGSTREAMER_REPO mjpg-streamer"
#popd

pushd /home/$user/mjpg-streamer
su -l $user -c "cd /home/$user/mjpg-streamer && mv mjpg-streamer-experimental/* . && make && mkdir -p www-octopi"
su -l $user -c "cd /home/$user/mjpg-streamer && make && mkdir -p www-octopi"

cat <<EOT >> www-octopi/index.html
cat <<EOT >> www-octopi/index.html
<html>
<head><title>mjpg_streamer test page</title></head>
<body>
Expand Down Expand Up @@ -260,10 +262,10 @@ function install_extras() {
su -l $user -c "virtualenv .platformio/penv"
su -l $user -c "/home/$user/.platformio/penv/bin/pip --no-cache-dir install -U platformio"
su -l $user -c "echo 'export PATH=\$PATH:~/.platformio/penv/bin' >> /home/$user/.profile"
su -l $user -c "git clone --depth 1 $KLIPPER_REPO"
sed -i 's/pip -r/pip --no-cache-dir -r /g' ./klipper/scripts/install-debian.sh
su -l $user -c "chmod u+x ./klipper/scripts/install-debian.sh && ./klipper/scripts/install-debian.sh"
systemctl disable klipper.service
#su -l $user -c "git clone --depth 1 $KLIPPER_REPO"
#sed -i 's/pip -r/pip --no-cache-dir -r /g' ./klipper/scripts/install-debian.sh
#su -l $user -c "chmod u+x ./klipper/scripts/install-debian.sh && ./klipper/scripts/install-debian.sh"
#systemctl disable klipper.service
popd
echo $? "[EXTRAS]"
}
Expand All @@ -286,10 +288,11 @@ function customize() {
#users_and_groups $ROOTPASSWD $OCTO_USER $OCTO_PASSWD
tweak_base
change_host_name "citrico-$board"
df -h
install_octoprint $OCTO_USER
df -h
install_octoprint_plugins $OCTO_USER
install_mjpgstreamer $OCTO_USER
install_extras $OCTO_USER
df -h

# unpack FS
unpack_file $rt_dir/filesystem/boot/octopi.txt /boot/octopi.txt root
Expand All @@ -301,6 +304,21 @@ function customize() {
unpack $rt_dir/common_fs/etc /etc root
unpack $rt_dir/common_fs/home/$OCTO_USER /home/$OCTO_USER $OCTO_USER

# make home/$user/scripts executable
chmod u+x /home/$OCTO_USER/scripts/*

# unpack MJPG STREAMER
unpack $rt_dir/mjpg-streamer/mjpg-streamer-experimental /home/$OCTO_USER/mjpg-streamer $OCTO_USER
# unpack Klipper
#unpack $rt_dir/klipper /home/$OCTO_USER/klipper $OCTO_USER

df -h
# Install extras
install_mjpgstreamer $OCTO_USER
df -h
install_extras $OCTO_USER
df -h

#enable/disable services
systemctl enable gencert.service
systemctl enable octoprint.service
Expand Down
123 changes: 93 additions & 30 deletions octocitrico.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
ARMBIAN_REPO="https://github.com/armbian/build"
ARMBIAN_TAG="v20.05"
OCTOPI_REPO="https://github.com/guysoft/OctoPi"
MJPGSTREAMER_REPO="https://github.com/jacksonliam/mjpg-streamer.git"
OCTOPI_TAG="0.17.0"
AR_DIR=armbian_build
UP_DIR=$AR_DIR/userpatches
Expand All @@ -10,63 +12,93 @@ VAGRANT_DIR=armbian_build/config/templates
VAGRANT_BOX="ubuntu/bionic64"
#VAGRANT_BOX="ubuntu/focal64"

BOS=$(uname -s)


set -e
echo "OptoCitrico script => $1"
echo "OptoCitrico script => $1 [runining on $BOS]"

if [ $# -eq 0 ] ; then
echo "Usage:"
echo " $0 box : install ubuntu box for builing"
echo " $0 drop : destroy build virtual manchine"
echo " $0 clean : delete all build resources"
echo " $0 assets : download build assets"
echo " $0 build <board> : Build image for board <board>"
echo " $0 native <board> : Build image in native supported Ubuntu"
echo " $0 release : Create a git release (use for maintenance)"
echo " $0 box : install ubuntu box for builing"
echo " $0 drop : destroy build virtual manchine"
echo " $0 clean : delete all build resources (assets,box,vm)"
echo " $0 assets : download build assets"
echo " $0 build <board> : Build image for board <board> uisng vagrant"
echo " $0 dbuild <board> : Build image for board <board> using docker"
echo " $0 native <board> : Build image in native supported Ubuntu"
echo " $0 release : Create a git release (use for maintenance)"
exit 1
fi

if [ "$BOS" != "Darwin" ] && [ "$BOS" != "Linux" ] ; then
echo "$BOS not supported."
exit 2
fi

SEDI="sed -i bup -e"
[ "$BOS" == "Linux" ] && SEDI="sed -i"

function clean_vm() {
if [ -d $AR_DIR ] && [ -d $UP_DIR ]; then
pushd $UP_DIR
if [ -d $VAGRANT_DIR ]; then
pushd $VAGRANT_DIR
echo "Cleaning virtual machine...."
vagrant destroy
popd
else
echo "$UP_DIR do not exist. nothing to clean"
echo "$VAGRAT_DIR do not exist. nothing to clean"
fi
}

function build_start() {
local board=$1
local native=$2
local build_mode=$2
local enable_cache=$3

echo "Setting up build environment for $board..."
cp -v -R -p opi_source/src/modules/octopi/filesystem $OV_DIR
cp -v -p boards/manifest $OV_DIR
cp -v -p boards/common.sh $OV_DIR
cp -v -R -p boards/common_fs $OV_DIR
cp -v -R -p boards/$board $OV_DIR
if [ -z $native ] ; then
cp -v -p boards/$board/config.conf $UP_DIR/config-vagrant-guest.conf
dest_conf="$UP_DIR/config-vagrant-guest.conf"
if [ -z $build_mode ] ; then
dest_conf="$UP_DIR/config-vagrant-guest.conf"
elif [ "$build_mode" == "docker" ] ; then
dest_conf="$UP_DIR/config-dbuild.conf"
else
cp -v -p boards/$board/config.conf $UP_DIR/config-native.conf
dest_conf="$UP_DIR/config-native.conf"
fi
cp -v -p boards/$board/config.conf $dest_conf

# errase clean level if enable cache
if [[ ! -z $enable_cache ]] ; then
echo "Setting max cache!"
${SEDI} "s/^CLEAN_LEVEL=\".*\"/CLEAN_LEVEL=\"\"/" $dest_conf
echo
fi

source boards/manifest
# generate customize script
cat > $UP_DIR/customize-image.sh <<EOF
#! /bin/bash
set -x
#set -e
set -e
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
source $RT_DIR/manifest
source $RT_DIR/common.sh
echo_green "Starting customization script...."
if [[ ! -z "$BASE_PACKS" ]] ; then
apt-get -y update
apt-get -y install $BASE_PACKS
fi
customize $board $RT_DIR
if [ -f $RT_DIR/$board/extra.sh ] ; then
echo_green "Starting extra customization for $board..."
chmod +x $RT_DIR/$board/extra.sh
#chmod +x $RT_DIR/$board/extra.sh
source $RT_DIR/$board/extra.sh
fi
Expand All @@ -76,24 +108,32 @@ EOF
# Add additional pacakages to build
source boards/manifest
cat > $UP_DIR/lib.config <<EOF
PACKAGE_LIST_ADDITIONAL="\$PACKAGE_LIST_ADDITIONAL ${BASE_PACKS}"
PACKAGE_LIST_ADDITIONAL="\$PACKAGE_LIST_ADDITIONAL ${BASE_UTILS}"
EOF

chmod +x $UP_DIR/customize-image.sh

echo "Launching..."
if [ -z $native ] ; then
echo "Launching build mode=[$build_mode]..."
if [ -z $build_mode ] ; then
pushd $VAGRANT_DIR
vagrant halt
vagrant up
vagrant ssh-config
vagrant ssh -c "cd armbian; sudo ./compile.sh vagrant-guest"
vagrant ssh -c "cd armbian ; \
sudo git fetch && sudo git fetch --tags ; \
if [ \"\$(git tag --points-at HEAD)\" != \"$ARMBIAN_TAG\" ] ; then \
sudo git checkout $ARMBIAN_TAG ; \
fi ; \
sudo ./compile.sh vagrant-guest"
vagrant halt
popd
else
elif [ "$build_mode" == "docker" ] ; then
pushd $AR_DIR
sudo ./compile.sh native
./compile.sh docker dbuild
popd
else
echo "Native build not ready yet!"
exit 1
fi
}

Expand All @@ -116,18 +156,31 @@ fi
if [ "$1" == "assets" ] ; then

# clone armbian buil repository
git clone --depth 1 $ARMBIAN_REPO armbian_build
git clone --depth 1 $ARMBIAN_REPO $AR_DIR
pushd $AR_DIR
git fetch && git fetch --tags
git checkout $ARMBIAN_TAG
popd
# fix vm memory + Drive
$SEDI 's/#vb\.memory = "8192"/vb\.memory="4096"/g' $VAGRANT_DIR/Vagrantfile
$SEDI 's/disksize\.size = "40GB"/disksize\.size = "45GB"/g' $VAGRANT_DIR/Vagrantfile

# clone octopi repo
git clone $OCTOPI_REPO opi_source
pushd opi_source
git fetch && git fetch --tags
git checkout $OCTOPI_TAG
popd
mkdir -p $OV_DIR
pushd $OV_DIR
git clone --depth 1 $MJPGSTREAMER_REPO mjpg-streamer
#git clone --depth 1 $KLIPPER_REPO klipper
popd
exit $?
fi

# Build
if [ "$1" == "build" ] || [ "$1" == "native" ]; then
if [ "$1" == "build" ] || [ "$1" == "native" ] || [ "$1" == "dbuild" ] ; then

if [ ! -d armbian_build ] ; then
echo "Error:Armbian build asset not found"
Expand All @@ -148,9 +201,11 @@ if [ "$1" == "build" ] || [ "$1" == "native" ]; then
mkdir -p $UP_DIR
mkdir -p $OV_DIR
if [ "$1" == "build" ] ; then
build_start $2
build_start $2 "" $3
elif [ "$1" == "dbuild" ] ; then
build_start $2 "docker" $3
else
build_start $2 "native"
build_start $2 "native" $3
fi
exit $?
else
Expand Down Expand Up @@ -179,8 +234,16 @@ if [ "$1" == "clean" ] ; then
fi

if [ "$1" == "release" ] ; then
echo "TODO automatic release"
exit 1
git status -s | egrep 'M|\?\?'
if [ $0 -eq 0 ] ; then
echo "There are pending commits aborting"
exit 1
fi
echo "Puhsing repository..."
git push



fi

echo "Invalid command"
Expand Down

0 comments on commit 0c4a62f

Please sign in to comment.