Linux from scratch, Glibc-2.16 make error - linux

I've been closely following commands from 'Linux from scratch' book version 7.2, and as usual everything was fine until i've reached chapter 6.9, and the problem is when I try to install glibc by 'make' command it throws following error at me.
/bin/sh: command substitution: line 3: syntax error near unexpected token `)'
/bin/sh: command substitution: line 3: `/tools/lib/gcc/i686-pc-linux-gnu/4.7.1/../../../../i686-pc-linux-gnu/bin/ar t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//')'
make[1]: *** [/sources/glibc-build/linkobj/libc_pic.a] Error 1
make[1]: Leaving directory `/sources/glibc-2.16.0'
make: *** [all] Error 2
So I did some research and surprisingly I wasn't alone with this type of problem but unfortunately I couldn't find good solution (Every thread had a different one). So here are the thing I know so far about this problem.
Bash (4.2.36(1)-release) clearly can't handle brackets especially this type of syntax '$()'
It may have something to do with bash version
other commands which use () don't work as well
And because this is my first time when I went down so deep into linux I honestly have no idea what I'm doing and what to do. So I'd really appreciate your help.
Also i've read somewhere that I can remove all $() from make process but I'm not sure how to do it
I'm using Ubuntu 12.10 to compile LFS and yes I have checked with their script and all dependicies are satisfied. And to help here's env output and simple echo check
TERM=xterm
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
PWD=/sources/glibc-build
PS1=\u:\w\$
SHLVL=1
HOME=/root
_=/tools/bin/env
OLDPWD=/bin
root:/sources/glibc-build# echo $(test)
bash: command substitution: line 38: syntax error near unexpected token `)'
bash: command substitution: line 38: `test)'
root:/sources/glibc-build# echo $test
test
Source:
http://www.linuxfromscratch.org/lfs/view/stable/index.html

Ok so in order to repair this problem i had to rebuild whole LFS system again but this time with as mentioned above bison and yacc installed on my host machine, so if you experience similar problem to mine just simply execute following command and that should do the trick.
sudo apt-get update && apt-get install bison*

Related

bizarre "permission denied" from make [duplicate]

I'm experiencing some weird permission denied errors that I have no idea where could be coming from.
$ go run .
Hello from go
$ make run
go run .
make: go: Permission denied
make: *** [Makefile:2: run] Error 127
$ make run2
echo "Make says hello" ; go run .
Make says hello
Hello from go
$ cat Makefile
run:
go run .
run2:
echo "Make says hello" ; go run .
$ cat main.go
package main
import "fmt"
func main() {
fmt.Println("Hello from go")
}
My terminal is bash running on Ubuntu 22.04.
What is the difference between my run target and running go directly that can cause a permission denied error?
What's the difference between run and run2 that allow it to work in one but not in the other?
EDIT: Running make with -d / --trace
$ make -d run
<...snip...>
No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'run'.
File 'run' does not exist.
Finished prerequisites of target file 'run'.
Must remake target 'run'.
go run .
make: go: Permission denied
make: *** [Makefile:2: run] Error 127
$ make --trace run
Makefile:2: target 'run' does not exist
go run .
make: go: Permission denied
make: *** [Makefile:2: run] Error 127
$ make --trace run2
Makefile:5: target 'run2' does not exist
echo "Make says hello"; go run .
Make says hello
Hello from go
This is due to a bug in GNU make (actually it's a bug in gnulib). It means that you have a directory named go, in some directory on your PATH (before the actual directory containing the go executable).
So if you have a directory /usr/bin/go/. and you have /usr/bin on your PATH, you'll see this issue.
You should check your PATH and make sure to remove any directories that contain such subdirectories. If you can't remove that directory from your PATH (it's unusual to need directories containing subdirectories on your PATH but I guess it's possible) and you can't rename the go directory to something else, you'll have to ensure that GNU make invokes a shell, by adding a special character. Just ; is good enough:
run:
go run . ;
The issue you're experiencing is likely due to different environment between your shell and shell executed by Makefile. If for example you have a shell alias for go this alias is not visible to Makefile or if you have a custom path in you're shell rc file it's not visible to Makefile. It's hard to guess where the difference might be.
You might want to try debug the issue by trying following in your Makefile:
echo $(PATH)
command -v go
and run the same commands in your shell and compare results.
Note that the default shell for Makefile is /bin/sh whereas you probably have bash or zsh.
Here's some handy defaults to configure your Makefile build:
LANG=en_US.UTF-8
SHELL=/bin/bash
.SHELLFLAGS=--norc --noprofile -e -u -o pipefail -c

"bash xfce4.sh" gives syntax error near unexpected token `<'

When i try to run bash xfce4.sh, it gives me the error:
xfce4.sh: line 1: syntax error near unexpected token <'
xfce4.sh: line 1: <html><head><title>Loading...</title></head><body><script type='text/javascript'>window.location.replace('https://kali.sh/xfce4.sh?ch=1&js=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJKb2tlbiIsImV4cCI6MTY2NjkxMzIzMCwiaWF0IjoxNjY2OTA2MDMwLCJpc3MiOiJKb2tlbiIsImpzIjoxLCJqdGkiOiIyc2gwa2QwZW4xdWdicTlvaGMwdDRwb2EiLCJuYmYiOjE2NjY5MDYwMzAsInRzIjoxNjY2OTA2MDMwNzgyMDIxfQ.tN_1ZFHTKGGPtECn_V_PNJhsE8II0fcxWjYnZhB9evc&sid=1de40110-563e-11ed-ba81-f9449723c437');</script></body></html>'
I have tried to install dos2unix and converted xfce4.sh to Unix format, but still gave the same problem.
You're trying to run an HTML file as a bash script.
After you download the correct file, you also need to make it executable:
chmod +x xfce4.sh
Then execute it; you can also execute a script with:
./xfce4.sh
Assuming your current directory is the same as the script's directory.

Bash: Unexpected "(" when none is present

I'm just trying to run a simple bash script and it's just not working. The entirety of the script is this:
#!/bin/bash
/home/pi/akr2.exe
Just those two lines but when I try to run it:
sh: 1: Syntax error: "(" unexpected
sh: 1: Syntax error: "(" unexpected
There are no parentheses. How is this possible?
Note: I get the same error message whether I run the script with ./script.sh or bash script.sh
I suspect you've compiled akr2.exe on Windows, downloaded it to a Raspberry Pi and try to run it.
Linux on ARM definitely cannot run a binary compiled for Windows on x86.
When Linux tryies to run it, does not find nor the ELF magic numbers for Linux binaries, nor a shebang for a script, at the beginning, so it attempts to run it with /bin/sh. But it's not a shell script, just a binary blob, so sh gives you a syntax error and exits.

nodejs active on boot with nvm $HOME/nvm/nvm.sh

I installed node with nvm it works fine, but every new session i need to do source $HOME/nvm/nvm.sh to get node active
How can I do to be active on boot so there is no need to type source $HOME/nvm/nvm.sh in every sssh session
I try to add this command source $HOME/nvm/nvm.sh to /etc/rc.local but I get the following error
> /etc/init.d/node_start.sh: 13: root/nvm/nvm.sh: Bad substitution
> /etc/init.d/node_start.sh: 78: root/nvm/nvm.sh: [[: not found
> /etc/init.d/node_start.sh: 78: root/nvm/nvm.sh: [[: not found
> /etc/init.d/node_start.sh: 129: root/nvm/nvm.sh: [[: not found
> /etc/rc.local: 14: /etc/rc.local: source: not found
But if i done that command on shell works normally
Any help is welcome
Regards
You should add the line below to the end of ~/.bashrc file:
[[ -s /home/$USER/.nvm/nvm.sh ]] && . /home/$USER/.nvm/nvm.sh
The init script is running as root, not your user. If you want to source your own nvm.sh, you shouldn't use $HOME, but rather just use the absolute path like /home/vitor/nvm/nvm.sh. Also the init script is probably running under dash so you should not use the [[ construct. Just use [ instead as described in this dash as /bin/sh article
So I went and read the nvm.sh source code from https://github.com/creationix/nvm/blob/master/nvm.sh
I don't think that is compatible with dash. So I suggest you leave nvm.sh elsewhere in the filesystem and in your init script just do
exec /bin/bash /root/nvm/nvm.sh
Starting node_start.sh with #!/bin/bash may also be sufficient.
You may also want to subscribe to issue 168 on github for nvm where others hit this error.
I expect your init script starts with #!/bin/sh when it needs to start with #!/bin/bash. Of course, there may be many good reasons not to write init scripts in Bash...

Please Help me "binary operator expected in cygwin"

I am trying to Run Shell script in Cygwin but I am getting Following error msgs:
app.sh: line 215: clear: command not found
[: scripts/Test: binary operator expected.
The folder scripts/Test ID Not found...
Can Any one suggest. What is the problem Do i need to re install Cygwin again.
Because Same Script Running fine in the Linux Envirnment.
Thanks in Advance.....
the script is probably using '#!/bin/sh' but expects the behaviour of /bin/bash. Try executing the script as: /bin/bash shell_script.sh
debugging tools include executing the script with the -x option, i.e. bash -x shell_script.sh. The problem from the outset looks like an unset variable that is being checked using the unprotected form:
if [ $x = ]
the problem is that if $x is unset, then you end up with an empty token, which causes the script to fail.
for the explicit 'clear' command not found, the cygwin implementation of that is to call 'tput clear' if you replace the 'clear' call with 'tput clear' then it should work.

Resources