#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.1 # Package: opencv #=========================== # DB commit: d35a620850806ab581b32cb34d268a904c9c0a5f # APP commit: #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: opencv" echo "Release: 0.1" echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi #Creating log directory mkdir -p /var/log/ulfs-packages/opencv/ #Saving start timestamp date +%s > /var/log/ulfs-packages/opencv/start.time #Going to source directory... cd /sources #Saving downloading timestamp date +%s > /var/log/ulfs-packages/opencv/download.time #Downloading source package archive... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/o/opencv-3.4.2.zip.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/o/opencv-3.4.2.zip #Checking source package file existance if [ ! -f opencv-3.4.2.zip ]; then echo "Error: Can't find opencv-3.4.2.zip. Exiting!" exit fi #Checking source package file checksum if [ -f opencv-3.4.2.zip.md5sum ]; then MD5=`LANG=C md5sum -c opencv-3.4.2.zip.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of opencv-3.4.2.zip is wrong. Exiting!" exit fi fi #Downloadning add-ons... #Downloadning add-on "ippicv_2017u3_lnx_intel64_general_20180518.tgz"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/i/ippicv_2017u3_lnx_intel64_general_20180518.tgz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/i/ippicv_2017u3_lnx_intel64_general_20180518.tgz #Checking addon file existance if [ ! -f ippicv_2017u3_lnx_intel64_general_20180518.tgz ]; then echo "Error: Can't find ippicv_2017u3_lnx_intel64_general_20180518.tgz. Exiting!" exit fi #Checking add-on file checksum if [ -f ippicv_2017u3_lnx_intel64_general_20180518.tgz.md5sum ]; then MD5=`LANG=C md5sum -c ippicv_2017u3_lnx_intel64_general_20180518.tgz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of ippicv_2017u3_lnx_intel64_general_20180518.tgz is wrong. Exiting!" exit fi fi #Downloadning add-on "opencv_contrib-3.4.2.tar.gz"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/o/opencv_contrib-3.4.2.tar.gz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/o/opencv_contrib-3.4.2.tar.gz #Checking addon file existance if [ ! -f opencv_contrib-3.4.2.tar.gz ]; then echo "Error: Can't find opencv_contrib-3.4.2.tar.gz. Exiting!" exit fi #Checking add-on file checksum if [ -f opencv_contrib-3.4.2.tar.gz.md5sum ]; then MD5=`LANG=C md5sum -c opencv_contrib-3.4.2.tar.gz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of opencv_contrib-3.4.2.tar.gz is wrong. Exiting!" exit fi fi #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/opencv/cleanup.time rm -rfv /sources/opencv-3.4.2/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/opencv/unpack.time #Extracting source package with previously defined commands... unzip opencv-3.4.2.zip #Checking package directory size after unpack... du -s opencv-3.4.2 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/opencv/unpack.size #Going to source package directory... cd opencv-3.4.2 #Saving configuration timestamp date +%s > /var/log/ulfs-packages/opencv/configure.time #Sleep 1 second sleep 1 #Running configuration script... ipp_file=ippicv_2017u3_lnx_intel64_general_20180518.tgz && ipp_hash=\$(md5sum ../\$ipp_file | cut -d" " -f1) && ipp_dir=.cache/ippicv && mkdir -p \$ipp_dir && cp ../\$ipp_file \$ipp_dir/\$ipp_hash-\$ipp_file tar xf ../opencv_contrib-3.4.2.tar.gz #sed -i 's/CV_RGB/cv::Scalar/' src/filter/facebl0r/facebl0r.cpp mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_CXX11=ON \ -DBUILD_PERF_TESTS=OFF \ -DWITH_XINE=ON \ -DBUILD_TESTS=OFF \ -DENABLE_PRECOMPILED_HEADERS=OFF \ -DCMAKE_SKIP_RPATH=ON \ -DBUILD_WITH_DEBUG_INFO=OFF \ -Wno-dev .. #Saving build timestamp date +%s > /var/log/ulfs-packages/opencv/build.time #Running build script... make #Saving install timestamp date +%s > /var/log/ulfs-packages/opencv/install.time #Running install script... cat > ulfs_install.sh << EOIS make install && case \$(uname -m) in x86_64) ARCH=intel64 ;; *) ARCH=ia32 ;; esac && cp -v 3rdparty/ippicv/ippicv_lnx/lib/\$ARCH/libippicv.a /usr/lib && unset ARCH EOIS USER=`whoami` if [ "$USER" == "root" ] ; then cat ulfs_install.sh | bash 2>&1 | tee /var/log/ulfs-packages/opencv/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/opencv/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/opencv/finish.time #Checking package directory size after unpack... cd /sources du -s opencv-3.4.2 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/opencv/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/opencv/files.txt ]; then rm /var/log/ulfs-packages/opencv/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /sbin -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /usr -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /etc -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /opt -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /lib -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt find /var -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time \! -path "/var/log/ulfs-packages/opencv/*" >> /var/log/ulfs-packages/opencv/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time >> /var/log/ulfs-packages/opencv/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/opencv/configure.time \! -newer /var/log/ulfs-packages/opencv/finish.time \! -path "/var/log/ulfs-packages/opencv/*" >> /var/log/ulfs-packages/opencv/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/opencv else sudo touch /var/cache/ulfs-packages/opencv fi #Calculate delta size a=`cat /var/log/ulfs-packages/opencv/unpack.size` b=`cat /var/log/ulfs-packages/opencv/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/opencv/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/opencv/start.time` b=`cat /var/log/ulfs-packages/opencv/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/opencv/download.time` b=`cat /var/log/ulfs-packages/opencv/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/opencv/configure.time` b=`cat /var/log/ulfs-packages/opencv/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/opencv/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: opencv" echo "Release: 0.1" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script