Jump to content

automated build script


Recommended Posts

Hi all,

since i didnt want to manualy start building images for the boards i have, i decided to make a automated script for this.

Now i finished the script i wanted to share it with everyone:

cd /home/alexander/build

./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus2e BRANCH=next RELEASE=xenial BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus BRANCH=next RELEASE=xenial BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepizero BRANCH=next RELEASE=xenial BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus2e BRANCH=next RELEASE=stretch BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus BRANCH=next RELEASE=stretch BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepizero BRANCH=next RELEASE=stretch BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus2e BRANCH=next RELEASE=jessie BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus BRANCH=next RELEASE=jessie BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepizero BRANCH=next RELEASE=jessie BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=odroidxu4 BRANCH=next RELEASE=xenial BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=odroidxu4 BRANCH=next RELEASE=stretch BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes
./compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=odroidxu4 BRANCH=next RELEASE=jessie BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes

cd /home/alexander/build/output/images
sudo mkdir build_$(date '+%d-%m-%Y')
sudo mv -v /home/alexander/build/output/images/*.img /home/alexander/build/output/images/build_*/

cd /home/alexander/build/output/images/build_*/
gzip -kv *.img

cd
sudo cp -rv --backup=numbered  /home/alexander/build/output/images/* /data/
sudo rm -rv /home/alexander/build/output/images/*
sudo chown -R alexander /data

Feel free to comment, 

Ideas or suggestions for improvement are welcome to.

Link to comment
Share on other sites

ok, so now i wanted the above script to be executed automaticaly using crontab.

For this i made changes to it to get it working.

Only now i came across a problem. 

the compile.sh seems to work (see logfile) only at the end it looks like chroot and parted dont like to work this way.

here is the last part of the logfile:

dpkg-deb: building package 'linux-dtb-next-sunxi' in '../linux-dtb-next-sunxi_5.41_armhf.deb'.
dpkg-deb: building package 'linux-headers-next-sunxi' in '../linux-headers-next-sunxi_5.41_armhf.deb'.
dpkg-deb: building package 'linux-image-next-sunxi' in '../linux-image-next-sunxi_5.41_armhf.deb'.
dpkg-genchanges: warning: package linux-libc-dev-next-sunxi in control file but not in files list
dpkg-genchanges: binary-only upload (no source code included)
dpkg-deb: building package 'linux-source-4.14.20-next-sunxi' in '/home/alexander/build/.tmp/linux-source-next-sunxi_5.41_all.deb'.
[[0;32m o.k. [0m] Creating board support package [[0;33m orangepiplus next [0m]
[[0;32m .... [0m] Fingerprinting 
[[0;32m o.k. [0m] Building package [[0;33m linux-xenial-root-next-orangepiplus [0m]
dpkg-deb: building package 'linux-xenial-root-next-orangepiplus' in '/home/alexander/build/.tmp/xenial/linux-xenial-root-next-orangepiplus_5.41_armhf.deb'.
[[0;32m o.k. [0m] Starting rootfs and image building process for [[0;33m orangepiplus xenial [0m]
[[0;32m o.k. [0m] Extracting xenial-ng-armhf.24c...fa6.tar.lz4 [[0;33m 10 days old [0m]
[[0;32m o.k. [0m] Applying distribution specific tweaks for [[0;33m xenial [0m]
/home/alexander/build/lib/distributions.sh: line 210: chroot: command not found
[[0;32m o.k. [0m] Applying common tweaks 
/home/alexander/build/lib/distributions.sh: line 56: chroot: command not found
/home/alexander/build/lib/distributions.sh: line 59: chroot: command not found
/home/alexander/build/lib/distributions.sh: line 61: chroot: command not found
[[0;32m .... [0m] Installing [[0;33m linux-image-next-sunxi_5.41_armhf.deb [0m]
[[0;32m o.k. [0m] Installing u-boot [[0;33m linux-u-boot-next-orangepiplus [0m]
[[0;32m .... [0m] Installing [[0;33m linux-u-boot-next-orangepiplus_5.41_armhf.deb [0m]
[[0;32m .... [0m] Installing [[0;33m linux-dtb-next-sunxi_5.41_armhf.deb [0m]
[[0;32m .... [0m] Installing [[0;33m linux-xenial-root-next-orangepiplus_5.41_armhf.deb [0m]
/home/alexander/build/lib/distributions.sh: line 145: chroot: command not found
/home/alexander/build/lib/distributions.sh: line 170: chroot: command not found
cp: cannot stat '/home/alexander/build/.tmp/rootfs-next-orangepiplus-xenial-no/etc/armbian-release': No such file or directory
[[0;32m o.k. [0m] Installing extra applications and drivers 
[[0;32m .... [0m] Installing [[0;33m armbian-config_5.41_all.deb [0m]
[[0;32m .... [0m] Installing [[0;33m armbian-firmware_5.41_all.deb [0m]
[[0;32m .... [0m] Installing [[0;33m armbian-tools-xenial_5.41_armhf.deb [0m]
[[0;32m .... [0m] Installing additional packages [[0;33m EXTERNAL_NEW [0m]
/home/alexander/build/lib/chroot-buildpackages.sh: line 327: chroot: command not found
[[0;32m o.k. [0m] Calling image customization script [[0;33m customize-image.sh [0m]
/home/alexander/build/lib/image-helpers.sh: line 114: chroot: command not found
/home/alexander/build/lib/distributions.sh: line 242: chroot: command not found
/home/alexander/build/lib/distributions.sh: line 243: chroot: command not found
[[0;32m o.k. [0m] Preparing image file for rootfs [[0;33m orangepiplus xenial [0m]
[[0;32m o.k. [0m] Current rootfs size [[0;33m 839 MiB [0m]
[[0;32m o.k. [0m] Creating blank image for rootfs [[0;33m 1312 MiB [0m]
[[0;32m o.k. [0m] Creating partitions [[0;33m root: ext4 [0m]
/home/alexander/build/lib/debootstrap-ng.sh: line 346: parted: command not found
/home/alexander/build/lib/debootstrap-ng.sh: line 352: parted: command not found
/home/alexander/build/lib/debootstrap-ng.sh: line 364: losetup: command not found
[[0;31m error [0m] ERROR in function prepare_partitions [[0;33m debootstrap-ng.sh:365 [0m]
[[0;31m error [0m] Unable to find free loop device 
[[0;32m o.k. [0m] Process terminated 
[[0;31m error [0m] ERROR in function unmount_on_exit [[0;33m image-helpers.sh:59 [0m]
[[0;31m error [0m] debootstrap-ng was interrupted 
[[0;32m o.k. [0m] Process terminated 
mv: cannot stat '/home/alexander/build/output/images/*.img': No such file or directory
gzip: *.img: No such file or directory
mv: cannot stat '/var/www/html/build_*': No such file or directory
cp: cannot stat '/home/alexander/build/output/images/build_*/*.gz': No such file or directory
removed directory '/home/alexander/build/output/images/build_18-02-2018'

I also included the modified script i used.

Is there a way to fix this problem?

logfile.log

abs.sh

Link to comment
Share on other sites

51 minutes ago, zador.blood.stained said:

Possibly $PATH does not include all necessary directories when you start the script from cron. You can try logging the value of $PATH to a file and comparing it when the script is executed from a user shell and from cron.

this is how i call the compile.sh in my script

/home/alexander/build/compile.sh KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=orangepiplus2e BRANCH=next RELEASE=xenial BUILD_DESKTOP=no FORCE_USE_RAMDISK=yes USE_CCACHE=yes

so i use full path to execute compile.sh

or do i have to tell where those files like distributions.sh are to?

Link to comment
Share on other sites

how can i check this? 

Normaly google helps me, but with this i cant realy find what to do.

its the first time i am using crontab so dont know mutch about it, but i am learning about it this way.

this is how my crontab looks like at this moment:

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
50 11 * * * /home/alexander/abs.sh > /home/alexander/logfile.log 2>&1

and this is how my /etc/environment looks like:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Edit:

i forgot to mention that crontab runs as root, this was the only way i could get compile.sh to work when it gets called from my abs.sh script.

Link to comment
Share on other sites

3 hours ago, zador.blood.stained said:

As I already said, log $PATH from your script to a file (or to stdout, and check syslog)

thanks for your help:beer:,

I hope this was what you mean.

 

So after more searching the internet to get the log data needed i got it to work.

 

This is what i did:

 

First i used: sudo echo $PATH ,that gave me this:

/home/alexander/bin:/home/alexander/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

This i placed in crontab witch now looks like this:

...(removed to keep post small)...

# For more information see the manual pages of crontab(5) and cron(8)
PATH=/home/alexander/bin:/home/alexander/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
# m h  dom mon dow   command
0 0 * * * /home/alexander/abs.sh > /home/alexander/logfile.log 2>&1

Now it builds the image like it does when you start it manualy.

For testing i only let it build one image, (comented all lines for the other images)

Next test wil start at midnight, this time with all lines uncommented so hopefuly tomorrow morning it has build all images.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines