How to upgrade rpm package using bash script? - linux

I want to install the specific rpm packages using bash script. But I am getting error.
I am using the below code :
#!/bin/bash
systemctl stop edb-as-10.service
server_status=$(systemctl status edb-as-10.service|awk '{print $1,$2,$3}'|grep Active|cut -d ":" -f2|cut -d " " -f2|tr -d " ")
echo "$server_status"
if [ "$server_status" == inactive ]; then
echo "You can proceed with upgrading the Potgresql server"
rpm –Uvh --nodeps edb-as10-server-pltcl-10.9.17-1.rhel7.x86_64.rpm
systemctl start edb-as-10.service else
echo " Failed to do Upgrading"
fi
I'm getting this error :
RPM version 4.11.3 Copyright (C) 1998-2002 - Red Hat, Inc. This
program may be freely redistributed under the terms of the GNU GPL
Usage: rpm [-aKfgpqVcdLilsiv?] [-a|--all] [-f|--file] [-g|--group]
[-p|--package] [--pkgid] [--hdrid] [--triggeredby] [--whatrequires]
[--whatprovides]
[--nomanifest] [-c|--configfiles] [-d|--docfiles] [-L|--licensefiles] [--dump] [-l|--list] [--queryformat=QUERYFORMAT]
[-s|--state] [--nofiledigest]
[--nofiles] [--nodeps] [--noscript] [--allfiles] [--allmatches] [--badreloc] [-e|--erase +] [--excludedocs]
[--excludepath=] [--force]
[-F|--freshen +] [-h|--hash] [--ignorearch] [--ignoreos] [--ignoresize] [-i|--install] [--justdb] [--nodeps]
[--nofiledigest]
[--nocontexts] [--noorder] [--noscripts] [--notriggers] [--nocollections] [--oldpackage] [--percent] [--prefix=]
[--relocate==]
[--replacefiles] [--replacepkgs] [--test] [-U|--upgrade +] [--reinstall=+] [-D|--define 'MACRO
EXPR'] [--undefine=MACRO]
[-E|--eval 'EXPR'] [--macros=] [--noplugins] [--nodigest] [--nosignature] [--rcfile=] [-r|--root ROOT]
[--dbpath=DIRECTORY]
[--querytags] [--showrc] [--quiet] [-v|--verbose] [--version] [-?|--help] [--usage] [--scripts] [--setperms] [--setugids]
[--conflicts] [--obsoletes]
[--provides] [--requires] [--info] [--changelog] [--xml] [--triggers] [--last] [--dupes] [--filesbypkg] [--fileclass]
[--filecolor] [--fscontext]
[--fileprovide] [--filerequire] [--filecaps]
But when I run the command
rpm –Uvh --nodeps edb-as10-server-pltcl-10.9.17-1.rhel7.x86_64.rpm
on terminal its working but when it placed in script its not working.

Related

Check duplicate disk LABEL before mounting it to the system in bash script

is there a way to check if there is duplicate disk LABEL before mounting it to the system?
i need to make sure that if the user have two external drives, if the two of them have the same label, prompt to the user a warning and asking it to remove the duplicated disk.
my code is in the early stages:
if mountpoint -q "${JOB_MOUNT_DIR}"; then
echo " ${JOB_MOUNT_HD_LABEL} já está montado e está pronto para uso"
else
echo "O dispositivo ""${JOB_MOUNT_HD_LABEL}"" não está montado no diretório ""${JOB_MOUNT_DIR}"""
echo "Deseja montar o diretório?"
echo -n "Qual sua opção? [s/n]: "
read -r "opcao"
if [ "$opcao" == "s" ]; then
mkdir -p "${JOB_MOUNT_DIR}/${JOB_MOUNT_HD_LABEL}"
mount -L "${JOB_MOUNT_HD_LABEL}" "${JOB_MOUNT_DIR}/${JOB_MOUNT_HD_LABEL}"
exit 0
else
echo "Disco não irá ser montado"
exit 0
fi
fi
exit 0
some parts are in pt-br i think that will not be a problem
first it checks if that the disk is already mounted, if not it asks to mount, then there is the problem to know which of the two disk with the same LABEL is to mount
You can use:
lsblk -o name,label
NAME LABEL
mmcblk0
└─mmcblk0p1 eMMC
Or you can use:
blkid
/dev/nvme0n1p1: UUID="36D7-B890" TYPE="vfat" PARTUUID="8614534f-01"
/dev/nvme0n1p5: UUID="65885781-bd9b-4c62-afb0-4a82a0e5759e" TYPE="ext4" PARTUUID="8614534f-05"
/dev/mmcblk0p1: LABEL="eMMC" UUID="79ff33b4-2add-4f2f-844e-d7d242c18578" TYPE="ext4" PARTUUID="d4b36674-ab5f-4f15-bb83-313cce242fe4"
You may need to prefix above commands with sudo
If the above commands get your labels correctly, you can pipe the output roughly as follows to list duplicates:
lsblk -o label | sort | uniq -d

Yocto build could not invoke dnf . command && no Match for the argument : recipe-name

I tried to build my custom recipe for the project which contains programs for sensors. All the task and library making is taken care of by CMakeLists.txt it also has python dependencies. I added all the required dependencies within my recipe and tried to build it using the "bitbake soofierecp" command execution got successful. Whereas while attempting to install it with the local.conf using "IMAGE_INSTALL += soofierecp" it is giving an error as listed below:
Error is:
ERROR: soofie-img-1.0-r0 do_rootfs: Could not invoke dnf. Command '/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs/etc/yum.repos.d --installroot=/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs --setopt=logdir=/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/temp --repofrompath=oe-repo,/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/oe-rootfs-repo --nogpgcheck install i2c-tools packagegroup-base-extended packagegroup-core-boot packagegroup-core-ssh-dropbear psplash python3 python3-dev python3-pip python3-requests run-postinsts soofierecp usbutils locale-base-en-us locale-base-en-gb' returned 1:
DNF version: 4.12.0
cachedir: /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs/var/cache/dnf
Added oe-repo repo from /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/oe-rootfs-repo
User-Agent: falling back to 'libdnf': could not detect OS or basearch
repo: using cache for: oe-repo
oe-repo: using metadata from Thu 26 May 2022 05:31:19 AM UTC.
Last metadata expiration check: 0:00:01 ago on Thu 26 May 2022 05:31:20 AM UTC.
No match for argument: soofierecp
Error: Unable to find a match: soofierecp
ERROR: Logfile of failure stored in: /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/temp/log.do_rootfs.1379711
ERROR: Task (/home/anvation/nitish/workspace/meta-soofie/recipes-example/images/soofie-img.bb:do_rootfs) failed with exit code '1'
NOTE: Tasks Summary: Attempted 4873 tasks of which 4872 didn't need to be rerun and 1 failed. "added the meta-layer in bblayer.conf file"
Recipe is:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
S = "${WORKDIR}"
PR = "r0"
DEPENDS = "openssl python3-six-native python3-pytest-runner-native"
SRC_URI = "\
file://src/ \
file://third_party/pybind11/ \
file://third_party/CLI11/ \
file://third_party/c-periphery/ \
file://CMakeLists.txt \
"
do_configure() {
cmake ../
}
RDEPENDS_${PN} = "python-requests python-six"
inherit pkgconfig cmake python3native
EXTRA_OEMAKE = ""
ALLOW_EMPTY_${PN}="1"
FILES_${PN} = "${bindir}/*"
DEPENDS += "udev"
Please help me to reach for the solution
I really appreciate any help you can provide.
I got the above code working with the suggestion and help
Thank you so much
The updated recipe is:
'
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
S = "${WORKDIR}"
PR = "r0"
SRC_URI = "\
file://src/ \
file://third_party/pybind11/ \
file://third_party/CLI11/ \
file://third_party/c-periphery/ \
file://CMakeLists.txt \
"
inherit cmake pkgconfig python3native
DEPENDS += "openssl python3-six-native python3-pytest-runner-native"
EXTRA_OECMAKE = ""
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/build/datagen ${D}${bindir}
}
DEPENDS += "udev"
FILES_${PN} += "${D}${bindir}/"
ALLOW_EMPTY_${PN} = "1"
'

What does geeko#buildhost signify in linux version?

On a linux server when checking the Linux version I see the following "geeko#buildhost"
Version: Linux version 4.12.14-95.54-default (geeko#buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Thu Jun 4 12:49:28 UTC 2020 (892ef1f)
What does this signify? does it have something to do with who built the os packages?
It is simply an identifier showing the user and host names where the kernel is compiled. The former is the result of executing whoami and the latter is the result of running uname -n. You can see how it is put together in init/version.c:
const char linux_banner[] =
"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "#"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
The variables are set by scripts/mkcompile_h:
if test -z "$KBUILD_BUILD_USER"; then
LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
else
LINUX_COMPILE_BY=$KBUILD_BUILD_USER
fi
if test -z "$KBUILD_BUILD_HOST"; then
LINUX_COMPILE_HOST=`uname -n`
else
LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
fi

Cannot update Yocto Bitbake Recipe for Bzip2 from 1.0.6 to 1.0.7 for CVE-2019-12900 for Nvidia Jetson Nano

On Ubuntu 18.04 I am trying to build a Yocto SD Card Image for the Nvidia Jetson Nano using the "meta-tegra" layer. I ran into the recent bzip2 issue that requires the latest bzip2 ( 1.0.7 ) to fix as detailed in these forum posts:
https://devtalk.nvidia.com/default/topic/1056301/b/t/post/5355418/
https://devtalk.nvidia.com/default/topic/1056381/jetson-agx-xavier/jetpack-4-2-xavier-install-failed/1
I found the latest bzip2 source here:
https://www.sourceware.org/bzip2/downloads.html
I tried playing with ${WORKDIR}, ${S}, do_compile_append, and do_install_append, however I keep getting errors related to the wrong source directory. I basically took the OE Bzip2 1.0.6 recipe and change the version source and checksums.
Please help me fix this build issue with yocto - thanks!
Bitbake Failure:
Initialising tasks: 100% |##########################################################################| Time: 0:00:00
Sstate summary: Wanted 382 Found 0 Missed 382 Current 45 (0% match, 10% complete)
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: bzip2-native-1.0.7-r5 do_compile: oe_runmake failed
ERROR: bzip2-native-1.0.7-r5 do_compile: Function failed: do_compile (log file is located at /home/ubuntu/Desktop/mts-jetson-yocto/build/tmp/work/x86_64-linux/bzip2-native/1.0.7-r5/temp/log.do_compile.115964)
ERROR: Logfile of failure stored in: /home/ubuntu/Desktop/mts-jetson-yocto/build/tmp/work/x86_64-linux/bzip2-native/1.0.7-r5/temp/log.do_compile.115964
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 128
| make: *** No targets specified and no makefile found. Stop.
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /home/ubuntu/Desktop/mts-jetson-yocto/build/tmp/work/x86_64-linux/bzip2-native/1.0.7-r5/temp/log.do_compile.115964)
ERROR: Task (virtual:native:/home/ubuntu/Desktop/mts-jetson-yocto/layers/meta-mts/recipes-extended/bzip2/bzip2_1.0.7.bb:do_compile) failed with exit code '1'
Second Keyboard Interrupt, stopping...
Summary: 1 task failed:
virtual:native:/home/ubuntu/Desktop/mts-jetson-yocto/layers/meta-mts/recipes-extended/bzip2/bzip2_1.0.7.bb:do_compile
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
Current Broken Bitbake recipe:
SECTION = "console/utils"
LICENSE = "bzip2"
LIC_FILES_CHKSUM = "file://LICENSE;beginline=4;endline=37;md5=39406315f540c69bd05b1531daedd2ae"
PR = "r5"
SRC_URI = "https://www.sourceware.org/pub/bzip2/bzip2-1.0.7.tar.gz \
"
#WORKDIR = "${WORKDIR}/bzip-1.0.7"
#WORKDIR = "${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}/bzip2-1.0.7"
#S = "${WORKDIR}/bzip2-1.0.7"
#do_compile_prepend() {
# cd ../
#}
#do_install_prepend() {
# cd ../
#}
SRC_URI[md5sum] = "1a6a61cc867be4f3d6549037a09bf13e"
SRC_URI[sha256sum] = "e768a87c5b1a79511499beb41500bcc4caf203726fff46a6f5f9ad27fe08ab2b"
UPSTREAM_CHECK_URI = "https://www.sourceware.org/bzip2/"
UPSTREAM_VERSION_UNKNOWN = "1"
PACKAGES =+ "libbz2"
CFLAGS_append = " -fPIC -fpic -Winline -fno-strength-reduce -D_FILE_OFFSET_BITS=64"
inherit autotools update-alternatives ptest relative_symlinks
ALTERNATIVE_PRIORITY = "100"
ALTERNATIVE_${PN} = "bunzip2 bzcat bzip2"
#install binaries to bzip2-native under sysroot for replacement-native
EXTRA_OECONF_append_class-native = " --bindir=${STAGING_BINDIR_NATIVE}/${PN}"
do_install_ptest () {
sed -i -e "s|^Makefile:|_Makefile:|" ${D}${PTEST_PATH}/Makefile
}
FILES_libbz2 = "${libdir}/lib*${SOLIBS}"
PROVIDES_append_class-native = " bzip2-replacement-native"
BBCLASSEXTEND = "native nativesdk"
#addtask fix_path before do_compile
Two ideas:
Just apply the patch for the security issue, much easier. This patch is already on the oe-core list.
Take the upgrade patch that is also on the list

Rebar ./bin/sp restart report {'cannot load',asn1rt_nif,get_files} and can not start

Environment
Mac OS X 10.10.5
Erlang/OTP: 17.5
rebar 2.6.0 17 20150818_094957 git 2.6.0-16-g3239e74-dirty
It is an example of application from the book Programming Erlang. I have git push to github
Steps to reproduce the error
build
$ git clone https://github.com/mingchaoyan/sellaprime.git
...
$ cd sellaprime
$ rebar prepare-deps
...
$ rebar compile
...
release
$ mkdir rel
$ cd rel
$ rebar create-node nodeid=sp
...
edit reltool.config as follow
```
%% -*- mode: erlang -*-
%% ex: ft=erlang
{sys, [
{lib_dirs, []},
{erts, [{mod_cond, derived}, {app_file, strip}]},
{app_file, strip},
{rel, "sp", "1.0.0",
[
kernel,
stdlib,
sasl,
goldrush,
lager,
sp
]},
{rel, "start_clean", "",
[
kernel,
stdlib
]},
{boot_rel, "sp"},
{profile, embedded},
{incl_cond, derived},
{excl_archive_filters, [".*"]}, %% Do not archive built libs
{excl_sys_filters, ["^bin/(?!start_clean.boot)",
"^erts.*/bin/(dialyzer|typer)",
"^erts.*/(doc|info|include|lib|man|src)"]},
{excl_app_filters, ["\.gitignore"]},
{app, goldrush, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/goldrush"}]},
{app, lager, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/lager"}]},
{app, sp, [{mod_cond, app}, {incl_cond, include}, {lib_dir, ".."}]}
]}.
{target_dir, "sp"}.
{overlay, [
{mkdir, "log/sasl"},
{copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
{copy, "files/nodetool", "releases/\{\{rel_vsn\}\}/nodetool"},
{copy, "sp/bin/start_clean.boot",
"\{\{erts_vsn\}\}/bin/start_clean.boot"},
{copy, "files/sp", "bin/sp"},
{copy, "files/sp.cmd", "bin/sp.cmd"},
{copy, "files/start_erl.cmd", "bin/start_erl.cmd"},
{copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
{copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
]}.
```
then
$ rebar generate
...
start
$ cd sp
$ ./bin/sp start
$ ./bin/sp getpid
...
$ ./bin/sp attach
start an another erlang shell
erl -name 'other#127.0.0.1' -noinput -noshell -eval "rpc:call('sp#127.0.0.1', init, restart, [])" -setcookie sp
then the first erlang shell will report
sp#127.0.0.1)1> {"init terminating in do_boot",{'cannot load',asn1rt_nif,get_files}}
How this happened?
And why asn1rt will be released, actually I didn't config it in reltool.config
Thank you!
You can find an answer in this old rebar issue: you need to prevent the boot script from loading the crypto module. To do this, edit the sp/bin/sp script and remove -mode embedded from the CMD variable setting, changing this:
CMD="$BINDIR/erlexec $SLIM_ARGS -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH"
to this:
CMD="$BINDIR/erlexec $SLIM_ARGS -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -config $CONFIG_PATH -args_file $VMARGS_PATH"

Resources