Reputation:
I am new to RPM Package enhancement/development and working on post-install script.
I want to achieve the symbolic links creation on execution of post-install script but stuck on a issue.
The script execution is working fine for symbolic link creation but for Upgrade part when I check the Symbolic links in "$RPM_pckg_home/bin" they not getting created though the commands are executed successfully.
Original_bin_path=/a/b/c
RPM_pckg_home=/d/e/f
if [[ "$1" -eq 1 ]]; then # 1 for install
cd $RPM_pckg_home/bin
for cmd in `ls Original_bin_path` ; do
ln -s $Original_bin_path/${cmd} ${cmd}
done
elif [[ "$1" -eq 2 ]]; then # 2 for Upgrade
cd $RPM_pckg_home/bin
for cmd in `ls Original_bin_path` ; do
rm ${cmd}
ln -s $Original_bin_path/${cmd} ${cmd}
done
fi
Could you please suggest where would be the issue.
Upvotes: 0
Views: 45
Reputation: 530970
Aside from the possible typo, this is how you should write your loop:
if [[ "$1" -eq 1 ]]; then # 1 for install
for cmd in "$Original_bin_path"/* ; do
ln -s "${cmd}" "$RPM_pckg_home/bin"
done
elif [[ "$1" -eq 2 ]]; then # 2 for Upgrade
for cmd in "$Original_bin_path"/*; do
rm "${cmd}"
ln -s "${cmd}" "$RPM_pckg_home/bin"
done
fi
Instead of iterating over the output of ls
, just iterate over the files that match the glob, and modify your rm
and ln
commands to accommodate the change in the value of $cmd
.
Upvotes: 2