|
| 1 | +#!/bin/bash |
| 2 | +#set -x |
| 3 | +#trap read debug |
| 4 | +# Creating an IGELOS CP |
| 5 | +## Development machine Ubuntu (OS11 = 22.04; OS12 = 20.04) |
| 6 | +#https://www.pfu.ricoh.com/global/scanners/fi/dl/ubuntu-fi-8040.html |
| 7 | +#pfufs-ubuntu_2.8.1_amd64.deb |
| 8 | +CP="fujitsu" |
| 9 | +ZIP_LOC="https://github.com/IGEL-Community/IGEL-Custom-Partitions/raw/master/CP_Packages/Apps" |
| 10 | +ZIP_FILE="Fujitsu_Scanner" |
| 11 | +FIX_MIME="FALSE" |
| 12 | +CLEAN="FALSE" |
| 13 | +OS11_CLEAN="11.10.210" |
| 14 | +OS12_CLEAN="12.6.0" |
| 15 | +USERHOME_FOLDERS="FALSE" |
| 16 | +USERHOME_FOLDERS_DIRS=("") |
| 17 | +APPARMOR="FALSE" |
| 18 | +GETVERSION_FILE="$HOME/Downloads/pfufs-ubuntu_*_amd64.deb" |
| 19 | +MISSING_LIBS_OS11="" |
| 20 | +MISSING_LIBS_OS12="" |
| 21 | + |
| 22 | +VERSION_ID=$(grep "^VERSION_ID" /etc/os-release | cut -d "\"" -f 2) |
| 23 | + |
| 24 | +if [ "${VERSION_ID}" = "22.04" ]; then |
| 25 | + MISSING_LIBS="${MISSING_LIBS_OS11}" |
| 26 | + IGELOS_ID="OS11" |
| 27 | +elif [ "${VERSION_ID}" = "20.04" ]; then |
| 28 | + MISSING_LIBS="${MISSING_LIBS_OS12}" |
| 29 | + IGELOS_ID="OS12" |
| 30 | +else |
| 31 | + echo "Not a valid Ubuntu OS release. OS11 needs 22.04 (bionic) and OS12 needs 20.04 (focal)." |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | +if ! compgen -G "${GETVERSION_FILE}" > /dev/null; then |
| 36 | + echo "***********" |
| 37 | + echo "Obtain Linux SDK driver ${GETVERSION_FILE}, save into $HOME/Downloads and re-run this script " |
| 38 | + echo "https://www.pfu.ricoh.com/global/scanners/fi/dl/ubuntu-fi-8040.html" |
| 39 | + echo "***********" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +sudo apt install unzip -y |
| 44 | + |
| 45 | +mkdir build_tar |
| 46 | +cd build_tar |
| 47 | + |
| 48 | +for lib in $MISSING_LIBS; do |
| 49 | + apt-get download $lib |
| 50 | +done |
| 51 | + |
| 52 | +cp ${GETVERSION_FILE} . |
| 53 | + |
| 54 | +mkdir -p custom/${CP} |
| 55 | + |
| 56 | +find . -name "*.deb" | while read LINE |
| 57 | +do |
| 58 | + dpkg -x "${LINE}" custom/${CP} |
| 59 | +done |
| 60 | + |
| 61 | +if [ "${FIX_MIME}" = "TRUE" ]; then |
| 62 | + mv custom/${CP}/usr/share/applications/ custom/${CP}/usr/share/applications.mime |
| 63 | +fi |
| 64 | + |
| 65 | +if [ "${USERHOME_FOLDERS}" = "TRUE" ]; then |
| 66 | + for folder in "${USERHOME_FOLDERS_DIRS[@]}"; do |
| 67 | + mkdir -p "$folder" |
| 68 | + done |
| 69 | +fi |
| 70 | + |
| 71 | +if [ "${CLEAN}" = "TRUE" ]; then |
| 72 | + echo "+++++++======= STARTING CLEAN of USR =======+++++++" |
| 73 | + wget https://raw.githubusercontent.com/IGEL-Community/IGEL-Custom-Partitions/master/utils/igelos_usr/clean_cp_usr_lib.sh |
| 74 | + chmod a+x clean_cp_usr_lib.sh |
| 75 | + wget https://raw.githubusercontent.com/IGEL-Community/IGEL-Custom-Partitions/master/utils/igelos_usr/clean_cp_usr_share.sh |
| 76 | + chmod a+x clean_cp_usr_share.sh |
| 77 | + if [ "${IGELOS_ID}" = "OS11" ]; then |
| 78 | + ./clean_cp_usr_lib.sh ${OS11_CLEAN}_usr_lib.txt custom/${CP}/usr/lib |
| 79 | + ./clean_cp_usr_share.sh ${OS11_CLEAN}_usr_share.txt custom/${CP}/usr/share |
| 80 | + else |
| 81 | + ./clean_cp_usr_lib.sh ${OS12_CLEAN}_usr_lib.txt custom/${CP}/usr/lib |
| 82 | + ./clean_cp_usr_share.sh ${OS12_CLEAN}_usr_share.txt custom/${CP}/usr/share |
| 83 | + fi |
| 84 | + echo "+++++++======= DONE CLEAN of USR =======+++++++" |
| 85 | +fi |
| 86 | + |
| 87 | +wget ${ZIP_LOC}/${ZIP_FILE}.zip |
| 88 | + |
| 89 | +unzip ${ZIP_FILE}.zip -d custom |
| 90 | + |
| 91 | +if [ "${APPARMOR}" = "TRUE" ]; then |
| 92 | + mkdir -p custom/${CP}/config/bin |
| 93 | + mkdir -p custom/${CP}/lib/systemd/system |
| 94 | + mv custom/target/build/${CP}_cp_apparmor_reload custom/${CP}/config/bin |
| 95 | + mv custom/target/build/igel-${CP}-cp-apparmor-reload.service custom/${CP}/lib/systemd/system/ |
| 96 | +fi |
| 97 | +mv custom/target/build/${CP}-cp-init-script.sh custom |
| 98 | + |
| 99 | +cd custom |
| 100 | + |
| 101 | +# edit inf file for version number |
| 102 | +mkdir getversion |
| 103 | +cd getversion |
| 104 | +ar -x ${GETVERSION_FILE} |
| 105 | +tar xf control.tar.* |
| 106 | +VERSION=$(grep Version control | cut -d " " -f 2) |
| 107 | +#echo "Version is: " ${VERSION} |
| 108 | +mv postinst ../fujitsu_igel_postinst.sh |
| 109 | +cd .. |
| 110 | +sed -i "/^version=/c version=\"${VERSION}\"" target/${CP}.inf |
| 111 | +#echo "${CP}.inf file is:" |
| 112 | +#cat target/${CP}.inf |
| 113 | + |
| 114 | +# new build process into zip file |
| 115 | +tar cvjf target/${CP}.tar.bz2 ${CP} ${CP}-cp-init-script.sh ${CP}_igel_postinst.sh |
| 116 | +zip -g ../${ZIP_FILE}.zip target/${CP}.tar.bz2 target/${CP}.inf |
| 117 | +zip -d ../${ZIP_FILE}.zip "target/build/*" "target/igel/*" "target/target/*" |
| 118 | +mv ../${ZIP_FILE}.zip ../../${ZIP_FILE}-${VERSION}_${IGELOS_ID}_igel01.zip |
| 119 | + |
| 120 | +cd ../.. |
| 121 | +rm -rf build_tar |
0 commit comments