From b77f7dbc70471c5003c5ab0303bf5e750eb43c23 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Wed, 13 Jul 2022 00:09:22 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20add=20testiso=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lddd.sh | 55 ++++++++++++++++++++ testiso.sh | 127 ++++++++++++++++++++++++++++++++++++++++++++++ util-iso-mount.sh | 9 ++-- util-iso.sh | 5 +- 4 files changed, 190 insertions(+), 6 deletions(-) create mode 100755 lddd.sh create mode 100755 testiso.sh diff --git a/lddd.sh b/lddd.sh new file mode 100755 index 0000000..c58eb0c --- /dev/null +++ b/lddd.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +src_dir=$(pwd) +[[ -r ${src_dir}/util-msg.sh ]] && source ${src_dir}/util-msg.sh + +ifs=$IFS +IFS="${IFS}:" + +libdirs="/lib /usr/lib /usr/local/lib $(cat /etc/ld.so.conf.d/*)" +extras= + +TMPDIR=$(mktemp -d --tmpdir lddd-script.XXXX) + +msg 'Go out and drink some tea, this will take a while :) ...' +# Check ELF binaries in the PATH and specified dir trees. +for tree in $PATH $libdirs $extras; do + msg2 "DIR $tree" + + # Get list of files in tree. + files=$(find $tree -type f ! -name '*.a' ! -name '*.la' ! -name '*.py*' ! -name '*.txt' ! -name '*.h' ! -name '*.ttf' ! \ + -name '*.rb' ! -name '*.ko' ! -name '*.pc' ! -name '*.enc' ! -name '*.cf' ! -name '*.def' ! -name '*.rules' ! -name \ + '*.cmi' ! -name '*.mli' ! -name '*.ml' ! -name '*.cma' ! -name '*.cmx' ! -name '*.cmxa' ! -name '*.pod' ! -name '*.pm' \ + ! -name '*.pl' ! -name '*.al' ! -name '*.tcl' ! -name '*.bs' ! -name '*.o' ! -name '*.png' ! -name '*.gif' ! -name '*.cmo' \ + ! -name '*.cgi' ! -name '*.defs' ! -name '*.conf' ! -name '*_LOCALE' ! -name 'Compose' ! -name '*_OBJS' ! -name '*.msg' ! \ + -name '*.mcopclass' ! -name '*.mcoptype') + IFS=$ifs + for i in $files; do + if (( $(file $i | grep -c 'ELF') != 0 )); then + # Is an ELF binary. + if (( $(ldd $i 2>/dev/null | grep -c 'not found') != 0 )); then + # Missing lib. + echo "$i:" >> $TMPDIR/raw.txt + ldd $i 2>/dev/null | grep 'not found' >> $TMPDIR/raw.txt + fi + fi + done +done +grep '^/' $TMPDIR/raw.txt | sed -e 's/://g' >> $TMPDIR/affected-files.txt +# invoke pacman +for i in $(cat $TMPDIR/affected-files.txt); do + pacman -Qo $i | awk '{print $4,$5}' >> $TMPDIR/pacman.txt +done +# clean list +sort -u $TMPDIR/pacman.txt >> $TMPDIR/possible-rebuilds.txt + +msg "Files saved to $TMPDIR" diff --git a/testiso.sh b/testiso.sh new file mode 100755 index 0000000..37666c3 --- /dev/null +++ b/testiso.sh @@ -0,0 +1,127 @@ +#!/bin/bash +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +src_dir=$(pwd) +[[ -r ${src_dir}/util-msg.sh ]] && source ${src_dir}/util-msg.sh +import ${src_dir}/util.sh + +# setting of the general parameters +work_dir="${src_dir}/build" +outFolder="${src_dir}/out" + +if [ $# -eq 0 ]; then + msg "No " + msg2 "Usage: testiso " + exit 1 +fi + +vdi_size=10240 # 10GB size + +#Check if already exist virtual disk and in case create it +if [[ -e ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox ]]; then + msg "CachyOS Virtual Machine Found" +else + msg "We create a new VirtualBox Machine called CachyOS" + msg2 "We create a new Virtual Disk Image ( vdi ) with ${vdi_size}GB" + VBoxManage createmedium disk --filename ~/VirtualBox\ VMs/CachyOS/CachyOS.vdi --size ${vdi_size} --format VDI --variant Fixed + + UUID=$(VBoxManage showhdinfo ~/VirtualBox\ VMs/CachyOS/CachyOS.vdi | awk 'NR == 1 {print $2}') #uuid of vdi disk + gui_lang=$(awk -F'[.=]' '/LANG/ {print $2}' /etc/locale.conf) + + echo ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +' > ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox + + sed -i "s/UUID/$UUID/g" ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox + sed -i "s/gui_lang/$gui_lang/g" ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox + + VBoxManage registervm ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox #register the cachyos vbox machine +fi + + +VBoxManage storageattach CachyOS --storagectl IDE --port 1 --device 0 --medium emptydrive #empty the dvd drive +sleep 1 + +iso_dir=$(find ${outFolder} -type d -iname "$1") + +iso=${iso_dir} + +if [[ -e $(ls ${iso}/*.iso) ]]; then + iso_name=$(ls ${iso}/*.iso) +else msg "No ISO to load present" + exit 1 +fi + +VBoxManage storageattach CachyOS --storagectl IDE --port 1 --device 0 --type dvddrive --medium $iso_name #attach dvd cachyos iso + +sleep 1 + +msg2 "Run Vbox CachyOS with ${iso_name}" + +sleep 2 + +VBoxManage startvm CachyOS #run vbox machine + diff --git a/util-iso-mount.sh b/util-iso-mount.sh index eeea362..68b57b9 100755 --- a/util-iso-mount.sh +++ b/util-iso-mount.sh @@ -12,20 +12,21 @@ umount_img() { if [[ -n ${IMG_ACTIVE_MOUNTS[@]} ]]; then info "umount: [%s]" "${IMG_ACTIVE_MOUNTS[@]}" - umount "${IMG_ACTIVE_MOUNTS[@]}" + sudo umount "${IMG_ACTIVE_MOUNTS[@]}" unset IMG_ACTIVE_MOUNTS rm -r "$1" fi } check_umount() { - if mountpoint -q "$1" - then - umount -l "$1" + if mountpoint -q "$1"; then + sudo umount -l "$1" fi } umount_fs(){ + FS_ACTIVE_MOUNTS=() + if [[ -n ${FS_ACTIVE_MOUNTS[@]} ]]; then info "overlayfs umount: [%s]" "${FS_ACTIVE_MOUNTS[@]}" #umount "${FS_ACTIVE_MOUNTS[@]}" diff --git a/util-iso.sh b/util-iso.sh index 4828f71..e2a4918 100755 --- a/util-iso.sh +++ b/util-iso.sh @@ -101,9 +101,10 @@ run_build() { msg "Start [Build ISO]" - [ -d $outFolder ] || mkdir $outFolder + [ -d "$outFolder/$_profile" ] || mkdir -p "$outFolder/$_profile" cd ${work_dir}/archiso/ - sudo mkarchiso -v -w ${work_dir} -o $outFolder ${work_dir}/archiso/ + sudo mkarchiso -v -w ${work_dir} -o "$outFolder/$_profile" ${work_dir}/archiso/ + sudo chown $USER $outFolder cp ${work_dir}/iso/arch/pkglist.x86_64.txt $outFolder/$(gen_iso_fn).pkgs.txt mv $outFolder/"cachyos-$(date +%Y.%m.%d)-x86_64.iso" $outFolder/${iso_file}