#!/bin/bash # This is Chromium with Russian GOST cryptographic algorithms support # build script of xzm module for Porteus # Version 2023-05-08 # Copyright 2023 Blaze admin at ublaze.ru # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Root check if [ `whoami` != "root" ]; then echo -e "\nOnly root can run this.\n" exit 1 fi PRGNAM=${PRGNAM:-chromium-gost} VERSION=$(lynx -head -dump "https://github.com/deemru/chromium-gost/releases/latest" | grep Location | grep -o "[0-9].*$") SOURCE=$(echo https://github.com/deemru/Chromium-Gost/releases/download/$VERSION/$PRGNAM-$VERSION-linux-amd64.rpm) BOLD=${BOLD:-"\e[1m"} CYAN=${CYAN:-"\e[96m"} GREEN=${GREEN:-"\e[92m"} RED=${RED:-"\e[31m"} RESET=${RESET:-"\e[0m"} CWD=$(pwd) TMPDIR=/tmp/portch PKG=$TMPDIR/package-$PRGNAM PKGINFO=$PKG/var/lib/pkgtools/packages OUTPUT=${OUTPUT:-/tmp} ARCH=$( uname -m ) cleanup(){ [ -d $TMPDIR ] && rm -rf $TMPDIR [ -d $PKG ] && rm -rf $PKG exit } # Check if Chromium-Gost installed in the system if [[ -f "/usr/bin/chromium-gost-stable" ]]; then MYVER=${MYVER:-`/usr/bin/chromium-gost-stable --product-version`} echo -e " ${BOLD}Checking if Chromium-Gost is installed ...${RESET}" echo -e "[${GREEN}${BOLD}OK${RESET}] Chromium-Gost is installed" echo -e "[${GREEN}${BOLD}OK${RESET}] Chromium-Gost version: ${GREEN}${BOLD}${MYVER}${RESET}\n" fi if [ "$MYVER" == "$VERSION" ]; then echo -e "You already have the latest ${GREEN}${BOLD}$MYVER${RESET} version of $PRGNAM" sleep 5 && exit 0 else read -p "$(echo -e Would you like to build $PRGNAM ${GREEN}${BOLD}$VERSION${RESET} xzm module? [y/n])" -n 1 -r -s && echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "We continue the execution of the $0 script" &>/dev/null else exit 0 fi fi rm -rf $PKG mkdir -p $TMPDIR $PKG $OUTPUT cd $PKG # Download Chromium-Gost echo -e "\nDownloading ${CYAN}${BOLD}${PRGNAM}-${VERSION}${RESET}" wget -q --show-progress "$SOURCE" for i in `find . -type f | fgrep .rpm | sort`; do rpm2cpio $i | cpio -idmv &>/dev/null; done rm -f *.rpm && rm -rf $PKG/usr/share/man && rm -rf $PKG/etc # Move icons mkdir -p $PKG/usr/share/icons/hicolor/{24x24,32x32,48x48,64x64,128x128,256x256}/apps rm -f $PKG/opt/chromium-gost/product_logo_16.png rm -f $PKG/opt/chromium-gost/product_logo_32.{png,xpm} mv -f $PKG/opt/chromium-gost/product_logo_24.png $PKG/usr/share/icons/hicolor/24x24/apps/chromium-gost.png # Note. About cp -a 48x48 to 32x32 cp -a $PKG/opt/chromium-gost/product_logo_48.png $PKG/usr/share/icons/hicolor/32x32/apps/chromium-gost.png mv -f $PKG/opt/chromium-gost/product_logo_48.png $PKG/usr/share/icons/hicolor/48x48/apps/chromium-gost.png mv -f $PKG/opt/chromium-gost/product_logo_64.png $PKG/usr/share/icons/hicolor/64x64/apps/chromium-gost.png mv -f $PKG/opt/chromium-gost/product_logo_128.png $PKG/usr/share/icons/hicolor/128x128/apps/chromium-gost.png mv -f $PKG/opt/chromium-gost/product_logo_256.png $PKG/usr/share/icons/hicolor/256x256/apps/chromium-gost.png # Old tweaks #ln -sf /usr/lib64/libEGL.so $PKG/opt/chromium-gost/libEGL.so #ln -sf /usr/lib64/libGLESv2.so $PKG/opt/chromium-gost/libGLESv2.so #cp -a $PKG/opt/chromium-gost/{libEGL.so,libGLESv2.so} $PKG/opt/chromium-gost/swiftshader # Choose locales echo -e "\nChoose a locale from the list:\n" echo '1) af | 12) en-US | 23) hr | 34) ms | 45) sv | 2) am | 13) es-419 | 24) hu | 35) nb | 46) sw | 3) ar | 14) es | 25) id | 36) nl | 47) ta | 4) bg | 15) et | 26) it | 37) pl | 48) te | 5) bn | 16) fa | 27) ja | 38) pt-BR | 49) th | 6) ca | 17) fi | 28) kn | 39) pt-PT | 50) tr | 7) cs | 18) fil | 29) ko | 40) ro | 51) uk | 8) da | 19) fr | 30) lt | 41) ru | 52) ur | 9) de | 20) gu | 31) lv | 42) sk | 53) vi | 10) el | 21) he | 32) ml | 43) sl | 54) zh-CN | 11) en-GB | 22) hi | 33) mr | 44) sr | 55) zh-TW |' | column -ts $'\|' read -p "$(echo -e "\n${BOLD}All other locales will be removed.${RESET}\n\n#? ")" if [[ $REPLY = 1 ]]; then CGLANG=af for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'af.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 2 ]]; then CGLANG=am for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'am.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 3 ]]; then CGLANG=ar for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ar.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 4 ]]; then CGLANG=bg for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'bg.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 5 ]]; then CGLANG=bn for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'bn.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 6 ]]; then CGLANG=ca for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ca.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 7 ]]; then CGLANG=cs for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'cs.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 8 ]]; then CGLANG=da for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'da.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 9 ]]; then CGLANG=de for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'de.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 10 ]]; then CGLANG=el for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'el.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 11 ]]; then CGLANG=en-GB for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'en-GB.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 12 ]]; then CGLANG=en-US for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'en-US.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 13 ]]; then CGLANG=es-419 for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'es-419.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 14 ]]; then CGLANG=es for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'es.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 15 ]]; then CGLANG=et for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'et.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 16 ]]; then CGLANG=fa for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'fa.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 17 ]]; then CGLANG=fi for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'fi.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 18 ]]; then CGLANG=fil for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'fil.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 19 ]]; then CGLANG=fr for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'fr.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 20 ]]; then CGLANG=gu for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'gu.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 21 ]]; then CGLANG=he for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'he.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 22 ]]; then CGLANG=hi for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'hi.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 23 ]]; then CGLANG=hr for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'hr.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 24 ]]; then CGLANG=hu for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'hu.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 25 ]]; then CGLANG=id for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'id.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 26 ]]; then CGLANG=it for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'it.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 27 ]]; then CGLANG=ja for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ja.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 28 ]]; then CGLANG=kn for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'kn.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 29 ]]; then CGLANG=ko for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ko.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 30 ]]; then CGLANG=lt for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'lt.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 31 ]]; then CGLANG=lv for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'lv.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 32 ]]; then CGLANG=ml for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ml.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 33 ]]; then CGLANG=mr for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'mr.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 34 ]]; then CGLANG=ms for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ms.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 35 ]]; then CGLANG=nb for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'nb.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 36 ]]; then CGLANG=nl for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'nl.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 37 ]]; then CGLANG=pl for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'pl.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 38 ]]; then CGLANG=pt-BR for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'pt-BR.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 39 ]]; then CGLANG=pt-PT for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'pt-PT.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 40 ]]; then CGLANG=ro for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ro.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 41 ]]; then CGLANG=ru for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ru.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 42 ]]; then CGLANG=sk for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'sk.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 43 ]]; then CGLANG=sl for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'sl.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 44 ]]; then CGLANG=sr for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'sr.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 45 ]]; then CGLANG=sv for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'sv.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 46 ]]; then CGLANG=sw for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'sw.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 47 ]]; then CGLANG=ta for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ta.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 48 ]]; then CGLANG=te for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'te.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 49 ]]; then CGLANG=th for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'th.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 50 ]]; then CGLANG=tr for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'tr.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 51 ]]; then CGLANG=uk for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'uk.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 52 ]]; then CGLANG=ur for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'ur.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 53 ]]; then CGLANG=vi for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'vi.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 54 ]]; then CGLANG=zh-CN for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'zh-CN.pak'`; do rm -f $i &>/dev/null; done elif [[ $REPLY = 55 ]]; then CGLANG=zh-TW for i in `find $PKG/opt/chromium-gost/locales -type f ! -name 'zh-TW.pak'`; do rm -f $i &>/dev/null; done fi # Remove MimeType. For example pdf files are open in the Chromium-Gost sed -i '/MimeType/d' $PKG/usr/share/applications/chromium-gost.desktop ### fake Slackware type package info: super dumb version mkdir -p $PKGINFO echo "PACKAGE NAME: $PRGNAM-$VERSION-$ARCH" > $PKGINFO/$PRGNAM-$VERSION-$ARCH cat >> $PKGINFO/$PRGNAM-$VERSION-$ARCH << EOM PACKAGE DESCRIPTION: chromium-gost: chromium-gost (Open Source version of Chrome Web Browser) chromium-gost: chromium-gost: Chromium-Gost is the open-source project behind Chromium, chromium-gost: with GOST cryptographic algorithms support. chromium-gost: chromium-gost: This package contains the un-googled version. chromium-gost: chromium-gost: chromium-gost: chromium-gost: chromium-gost home: https://github.com/deemru/Chromium-Gost chromium-gost: FILE LIST: EOM find * | grep -v var >> $PKGINFO/$PRGNAM-$VERSION-$ARCH dir2xzm $PKG $OUTPUT/$PRGNAM-$VERSION-$ARCH-$CGLANG.xzm # Check on Chromium-Gost xzm file exists in /tmp if [ -f "$OUTPUT/$PRGNAM-$VERSION-x86_64-${CGLANG}.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}$OUTPUT/$PRGNAM-$VERSION-$ARCH-$CGLANG.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}\n" else echo -e "\n${RED}${BOLD}Failed. Your $PRGNAM module is not built.${RESET}\n" fi cleanup