How to change %install section in spec file? - rpmbuild

I tried to build binaries in RHEL6 using rpmbuild command.It throws file not found error during rpmbuild command execution. But In RHEL5 the same rpmbuild command is working fine.
RHEL5 execution result:
*Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.77266
umask 022
cd /usr/src/redhat/BUILD
LANG=C
export LANG
unset DISPLAY*
RHEL6 execution result:
*Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.BeMhyH
umask 022
cd //rpmbuild/BUILD
'[' //rpmbuild/BUILDROOT/ '!=' / ']'
rm -rf //rpmbuild/BUILDROOT/
++ dirname //rpmbuild/BUILDROOT/
mkdir -p //rpmbuild/BUILDROOT
mkdir //rpmbuild/BUILDROOT/
LANG=C
export LANG
unset DISPLAY
/usr/lib/rpm/check-buildroot*
I am not able to find any %install changes between the spec files. Any one please help me to understand what am i doing wrong?
Thanks in Advance..!

The only problem that is clear from the snippets provided is that $HOME is not defined in your rpmbuild environment. $HOME/rpmbuild is the default build root for 'rpmbuild' in RHEL6, instead of /usr/src/redhat as in RHEL5.
Things to consider:
Is there an '~/.rpmmacros' file that is altering the rpmbuild
directives.
The temporary %install script will not be deleted on
error-exit. Inspecting it directly might tell you more about why it failed.
Ex:
[user#host rpmbuild]$ rpmbuild -bb nano
<snip>
+ exit 1
error: Bad exit status from /var/tmp/rpm-tmp.2uw1tZ (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.2uw1tZ (%install)
[user#host rpmbuild]$ cat /var/tmp/rpm-tmp.2uw1tZ
#!/bin/sh
RPM_SOURCE_DIR="/home/user/rpmbuild/SOURCES"
RPM_BUILD_DIR="/home/user/rpmbuild/BUILD"
...

Older recommendations were to nuke the target buildroot as the first step of %install. To help force a separation between the %build and %install steps, newer versions of rpmbuild strictly enforce it by doing it for you for the first step, as shown in what you pasted in.
I am assuming that your %build stage is putting one or more files into the target buildroot area, which it shouldn't be doing. It should all be in the build area only.

Related

Why my zsh completion is not sourcing it?

I try to setup my zsh-completions. I also use oh-my-zsh .
A lot of shell commands provide a some_command completion zsh
and they often suggest sourcing it directly in .zshrc like so:
source <(kubeone completion zsh)
source <(tilt completion zsh)
source <(civo completion zsh)
I can't get it working. Only when I output the command into a file echo "$(kubeone completion zsh)" > ~/.dotfiles/completions/_kubeone.
(That ~/.dotfiles/completions/-path is in my fpath):
fpath=(/usr/local/share/zsh-completions $fpath)
fpath=(~/.dotfiles/completions $fpath)
But that approach is not that neat. I wanna make the use of adding
source $(my_command completion zsh) to my .zsh_rc file.
Interestingly SOME commands are working with that approach: like: source <(kompose completion zsh) but source <(kubeone completion zsh) wont???
Here is an excerpt from my ~/.zshrc:
#!/bin/sh
[ -f ~/.dotfiles/fubectl.source ] && source ~/.dotfiles/fubectl.source
export ZSH_THEME="powerlevel10k/powerlevel10k"
export DOTFILES=$HOME/.dotfiles
export ZSH=$DOTFILES/oh-my-zsh
BUNDLED_COMMANDS=(rubocop)
UNBUNDLED_COMMANDS=(berks foreman mailcatcher rails ruby spin rubocop)
plugins=(zsh-completions zsh-autosuggestions docker fzf bundler brew cask capistrano codeclimate coffee dotenv gem git github grunt helm heroku history iterm2 minikube node redis-cli redis-cli rails rake rake-fast ruby rbenv textmate macos pod zeus terraform)
source $ZSH/oh-my-zsh.sh
complete -o nospace -C /usr/local/bin/terraform terraform
# load autocomplete
fpath=(/usr/local/share/zsh-completions $fpath)
fpath=(~/.dotfiles/completions $fpath)
autoload -U compinit && compinit
source <(kompose completion zsh) # WORKS
source <(kubeone completion zsh) # DONT WORK
(kompose a→tab WORKS)
kubeone a→tab returns only my folder structure
❯ kubeone completion zsh
Application\ Support/ MAMP/ VirtualBox\ VMs/ oh-my-zsh
Applications/ Movies/ Wine\ Files/ output.json
Coding/ Music/ builds/
...
..
.
but should return:
❯ kubeone apply
apply -- Reconcile the cluster
completion -- Generates completion scripts for bash and zsh
config -- Commands for working with the KubeOneCluster configuration manifests
document -- Generates documentation
help -- Help about any command
install -- Install Kubernetes
...
..
.
What I tried so far:
after opening terminal rm ~/.zcompdump*, then tried command, then reopened terminal and tried command again.
autoload -Uz compinit && compinit -i with different arguments
I think there is some misconfiguration or maybe a brew formula is disturbing?
Here is the complete output of my brew list command, as well my complete .zshrc file: https://gist.github.com/exocode/79c9acfad9828b73d05d2abfa39f1724

Where is `zsh:command not found: important` coming from

I recently updated ZSH and now I'm seeing a zsh:command not found: important output whenever I do any command in the terminal.
❯ ls
...(lists all files)
zsh: command not found: important
❯ echo $PATH | tr ':' '\n'
/usr/local/opt/postgresql#10/bin
/Users/skube/.nvm/versions/node/v10.18.1/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
zsh: command not found: important
Where the heck is important?
It was something silly. I was in a git branch that had been erroneously named with a quoted important.
❯ git br
* Some-`important`-work
master
Interestingly, I could switch to this branch within VSCode, but not in Terminal. Also, in Terminal the branch displayed without important in the branch name, unit it was revealed as #lurker suggested with echo $PS1.

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set after chmod 755

What i tried is this:
https://stackoverflow.com/a/29903645/4983983
I executed this:
n=$(which node); \
n=${n%/bin/node}; \
chmod -R 755 $n/bin/*; \
sudo cp -r $n/{bin,lib,share} /usr/local
but now i can not execute for example sudo su command, i get following error:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
I am not sure how can i redo it ?
EDIT:
Regarding #Bodo answer:
sudo rpm --setperms mkdir
sudo rpm --setugids mkdir
cd /opt
mkdir test13121
mkdir: cannot create directory ‘test13121’: Permission denied
BUT:
sudo chown root:root /usr/bin/mkdir && sudo chmod 4755 /usr/bin/mkdir
mkdir test912121
The difficulty is to find out the normal permissions of the files you have changed.
You can try to reset the file permissions based on the information in the package management.
See e.g. https://www.cyberciti.biz/tips/reset-rhel-centos-fedora-package-file-permission.html
Citation from this page:
Reset the permissions of the all installed RPM packages
You need to use combination of rpm and a shell for loop command as follows:
for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done
I suggest to read the linked page completely and try this for a single package first.
I guess you can somehow ask rpm to find the package name that contains e.g. /usr/bin/sudo. and try if the commands work for a single package.
Edit: If the setuid or setgid bits are not correct, you can try to change the order of the commands and use --setugids before --setperms. (In some cases chown resets setuid or setgid bits; don't know if this applies to the rpm commands.)
There are sources in the internet that propose to combine --setugids and--setperms in one command or to use option -a instead of a loop like
rpm -a --setperms
Read the documentation. (I don't have an RPM based system where I could test the commands.)

Luarocks error on ubuntu

I am trying to run Neuraltalk2 on Ubuntu. But I am getting an error as follows:
parag#parag:~/torch$ sudo luarocks install nn
[sudo] password for parag:
Error: No results matching query were found.
I followed the following steps uptill now:
sudo curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
sudo git clone https://github.com/torch/distro.git ~/torch --recursive
sudo cd ~/torch;
sudo ./install.sh
sudo source ~/.bashrc
Please help!
Try running this all without sudo. The last line, especially, sudo source ~/.bashrc does not work because source is meant to operate on the shell you are currently running. If you run it with sudo, it will load .bashrc into the temporary subshell created by sudo (in practice having no effect).
Your error message indicates that luarocks was installed correctly, but it failed to find the rock. Make sure the name of the rock is correct, try searching it with the luarocks search command, and check your configuration running luarocks with no arguments (it will display the name of your config files in use, helping you to troubleshoot the issue).

Installing Pear, what did I do by entering these commands on my terminal

I'm trying to figure out how to install Pear on my Mac (10.6.6).
Not understanding what they're telling me at pear.php.net, I got some code from http://clickontyler.com/blog/2008/01/how-to-install-pear-in-mac-os-x-leopard/
First, I entered curl http://pear.php.net/go-pear > go-pear.php in my terminal.
It resulted in this output
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 88004 100 88004 0 0 47537 0 0:00:01 0:00:01 --:--:-- 59744
What does that all mean? Am I on the right track?
Next, I entered sudo php -q go-pear.php
and it gave me the long output below. In short I have no idea where I am in the installation process. However, I'm pretty sure that I'm not where I'm supposed to be at following the tutorial at http://clickontyler.com/blog/2008/01/how-to-install-pear-in-mac-os-x-leopard/
because the tutorial tells me to select all the default choices, and I don't see any options to select.
The next line of code is asking me to modify the php.ini files and it requires a password so I'm worried about doing it...Can anyone tell me if I'm on the right track?
sudo cp /etc/php.ini.default /etc/php.ini
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -- [args...]
php [options] -a
-a Run interactively
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse and execute <file>.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r <code> Run PHP <code> without using script tags <?..?>
-B <begin_code> Run PHP <begin_code> before processing input lines
-R <code> Run PHP <code> for every input line
-F <file> Parse and execute <file> for every input line
-E <end_code> Run PHP <end_code> after processing all input lines
-H Hide any passed arguments from external tools.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin
--ini Show configuration file names
--rf <name> Show information about function <name>.
--rc <name> Show information about class <name>.
--re <name> Show information about extension <name>.
--ri <name> Show configuration for extension <name>.
php does not have an argument -q. Its also mentioned in go-pear.php (http://pear.php.net/go-pear) itself, but I dont know, what it wants to tell me. However, try
sudo php go-pear.php
and then follow the instructions.
Update:
-q was used, to start the interpreter in "quiet" mode. It seems, that this option does not exists anymore, because php always starts "quiet", but it should not cause an error, anyway. Now make sure you are in the same directory as the file go-pear.php before you call php go-pear.php.
The first part shows that you successfully downloaded the file to go-pear.php.
The second part is showing that -q isn't a valid option. The third part is asking for the root password, since you're doing 'sudo'.
I used this, though I wasn't installing on Mac:
Getting and installing the PEAR package manager

Resources