Reputation: 825
I want to automate one repeated task which I do regularly. That is creating rpm's for different architectures. To compile the code and create the rpm I need to set the project env. after setting the env I will create the rpm for the current architecture and again I should build rpms for other architecture by setting the env again.
I am trying to automate this process. The problem is once the env is set it I will be new shell so my script is not visible in the sub shell. How to automate this ??
This is what i tried.
cd $project_dir
setenv.sh x86 #creates new sub shell
make clean
make rpm
cp *rpm ~/
exit #exit from the sub shell
setenv.sh x86_64 #creates new shell
make clean
make rpm
cp *.rpm ~/
exit
after setting the env to x86 , next commands are not getting executed.
Upvotes: 4
Views: 3620
Reputation: 785098
You can force 2 parts to execute in sub-shells like this:
cd "$project_dir"
(. setenv.sh x86
make clean
make rpm
cp *rpm ~/)
(. setenv.sh x86_64
make clean
make rpm
cp *.rpm ~/)
Upvotes: 6