rpmbuild - /usr/sbin Symlink not installing - symlink

I'm setting up a Redis RPM for a local, unnetworked box. I'm trying to create a symlink: /usr/sbin/redis-server -> /opt/redis/redis-server
However, when I do an rpm -Uvh redis-3.2.7-1.rpm, it installed fine to /opt/redis/redis-server but never creates the symlink. Here's the relevant part of my spec file:
%build
# Empty section.
%install
rm -rf %{buildroot}
rm -f /usr/sbin/redis-server
mkdir -p %{buildroot}
# in builddir
cp -a * %{buildroot}
ln -sf /opt/redis/redis-server /usr/sbin/redis-server
%clean
rm -rf %{buildroot}
%files
/opt/redis/*
/etc/init.d/redis

ln -sf /opt/redis/redis-server /usr/sbin/redis-server needs to be ln -sf /opt/redis/redis-server %{buildroot}/usr/sbin/redis-server and then /usr/sbin/redis-server needs to be added to the %files section. Also remove that rm in %install.
The fact that the ln did not fail tells me you really made the symlink, and you're building RPMs as root which is a spectacularly bad idea.
I'm assuming that the tarball expands with opt at the top level; if not your cp is incorrect as well.

Related

Building and Installing BZip2 with shared library dylib on MacOS

'Trying to build/install BZip2 on MacOS (10.13.4 - High Sierra), but all the instructions I've been able to find [including from the README] have me at the following:
wget -c https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
tar -zxf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
sudo make install PREFIX=/usr/local
This installs the package without the shared library file with .dylib extension in the ./lib directory. The included instructions in the package are for Linux environment.
How do I install the shared libraries?
It turns out that doing this requires an update to the Makefile.
The package [bzip2 v1.0.8] comes with a Makefile-libbz2_so file that is for creating shared library files for Linux. To do same for MacOS a seperate Makefile is required.
Below are the updated instructions which worked. Follow the link for Makefile-libbz2_dylib for contents of the Makefile.
# Download BZip2
wget -c https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
# Extract and enter directory
tar -zxf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
# create variable
export PREFIX="/usr/local"
# install - change PREFIX is required
sudo make install PREFIX=$PREFIX
# Make dynamic libraries for MACOS
wget -c https://gist.githubusercontent.com/obihill/3278c17bcee41c0c8b59a41ada8c0d35/raw/3bf890e2ad40d0af358e153395c228326f0b44d5/Makefile-libbz2_dylib
make -f Makefile-libbz2_dylib
# Do below only if your PREFIX is not /usr/local
# Create symlinks for bin
sudo ln -s $PREFIX/bin/bunzip2 /usr/local/bin/
sudo ln -s $PREFIX/bin/bzcat /usr/local/bin/
sudo ln -s $PREFIX/bin/bzcmp /usr/local/bin/
sudo ln -s $PREFIX/bin/bzdiff /usr/local/bin/
sudo ln -s $PREFIX/bin/bzegrep /usr/local/bin/
sudo ln -s $PREFIX/bin/bzfgrep /usr/local/bin/
sudo ln -s $PREFIX/bin/bzgrep /usr/local/bin/
sudo ln -s $PREFIX/bin/bzip2 /usr/local/bin/
sudo ln -s $PREFIX/bin/bzip2recover /usr/local/bin/
sudo ln -s $PREFIX/bin/bzless /usr/local/bin/
sudo ln -s $PREFIX/bin/bzmore /usr/local/bin/
# Create symlinks for lib
sudo ln -s $PREFIX/lib/libbz2.a /usr/local/lib/
sudo ln -s $PREFIX/lib/libbz2.dylib /usr/local/lib/
# Create symlinks for include
sudo ln -s $PREFIX/include/bzlib.h /usr/local/include/
If you don't have wget on your Mac, you can find instructions to set it up on this community post.
Inspiration for Makefile from here and here.

create symbolic link in bitbake recipe

I have a .bbappend recipe that I need to create a symbolic link in my system.
This is how it looks like now:
bernardo#bernardo-ThinkCentre-Edge72:~/yocto/genericx86-64-rocko-18.0.0/meta-datavision/recipes-devtools/oracle-java$ cat oracle-jse-jdk_1.7.0.bbappend
FILES_${PN} += "/lib64/ld-linux-x86-64.so.2"
do_install_append() {
install -d ${D}/lib64
ln -s ${D}/lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
}
However, only the directory /lib64 is created in the sysroot. The symlink /lib64/ld-linux-x86-64.so.2 is not being generated.
What changes should I make in my recipe in order to have this symlink correctly created?
The cleanest solution is to use the "-r" flag:
do_install_append() {
install -d ${D}/lib64
ln -s -r ${D}/lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
}
From the gnu ln man page:
-r, --relative create symbolic links relative to link location
Try to avoid usage of absolute paths:
do_install_append() {
install -d ${D}/lib64
cd ${D}/lib64
ln -s ../lib/ld-2.26.so ld-linux-x86-64.so.2
}
For Yocto 2.3 to 3.4:
do_install_append() {
install -d ${D}/lib64
lnr ${D}/lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
}
For Yocto 4.0+ (or if your host system has coreutils 8.16+):
do_install_append() {
install -d ${D}/lib64
ln --relative --symbolic ${D}/lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
}
Alternatively, you can also inherit relative_symlinks which will turn any absolute symlinks into relative ones, but this is less commonly used than lnr.
Cf:
Yocto 4.0 Migration Guide (Thanks to #parsley72 for the info!)
Yocto 2.3 Migration Guide
I had a look at how other recipes create links in the rootfs, and most seem to do it this way:
ln -sf /data/etc/bluetooth/main.conf ${D}/${sysconfdir}/bluetooth/main.conf
This command in the recipe will create the following link on the device:
/# ls -al /etc/bluetooth/main.conf
lrwxrwxrwx 1 root root 29 Sep 11 15:34 /etc/bluetooth/main.conf -> /data/etc/bluetooth/main.conf
You use the full, Yocto-generated path when creating the link, but you make it point to the "final" location in the rootfs.
This way you can use "absolute" paths and won't have to change the working directory in the recipe.
As of 2022-01-19 this seems to be the only way to get it to work (adapt to the filenames needed):
do_install() {
install -d ${D}${libdir}
install -m 0644 ${S}/libmine.so.0 ${D}${libdir}/
lnr ${D}${libdir}/libmine.so.0 ${D}${libdir}/libmine.so
}
FILES_${PN} += " \
${libdir}/libmine.so.0 \
${libdir}/libmine.so \
"
FILES_SOLIBSDEV = ""
INSANE_SKIP_${PN} += "dev-so"
You can do:
ln -s ../lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
or if you don't require the symbolic-link until after your target system has booted up (i.e. it's not a dependency of other packages you are building) you can also do:
ln -s /lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
ln doesn't care if your target is valid or exists when a symbolic-link is created. It will become valid after you boot your target-system (or somehow mount this filesystem to /). But indeed, relative links are recommended.
do_install_append () {
install -d 0755 ${D}/dir
install -d 0755 ${D}/dir/subdir
cd ${D}/dir/subdir
ln -sf /source_so_the_symbilic_link <name_of_the_symbolic_link>
}
FILES_${PN} += "/dir"

How to re-link files in iron.io?

I'm trying to upload the following files and linksto iron.io:
After downloading the files from iron.io that were originally uploaded, I can see that the links are turned into these files
How do I maintain the links so that they are not turned into files in the process of uploading to iron.io.
Ideally, I can run this bash script on iron.io to solve for this:
rm libicudata.so.50 && ln -s libicudata.so.50.1.2 libicudata.so.50
rm libicui18n.so.50 && ln -s libicui18n.so.50.1.2 libicui18n.so.50
rm libicuio.so.50 && ln -s libicuio.so.50.1.2 libicuio.so.50
rm libicule.so.50 && ln -s libicule.so.50.1.2 libicule.so.50
rm libiculx.so.50 && ln -s libiculx.so.50.1.2 libiculx.so.50
rm libicutu.so.50 && ln -s libicutu.so.50.1.2 libicutu.so.50
rm libicuuc.so.50 && ln -s libicuuc.so.50.1.2 libicuuc.so.50
For reference, this is my worker:
# set the runtime language. Python workers use "python"
runtime "python"
# exec is the file that will be executed:
exec "test.py"
stack 'selenium'
remote
file "iron.json"
file "test.py"
dir '/Library/dataextract/'
I upload this worker with the following bash script:
iron_worker upload test
You can't "upload" a symlink. It's a symbolic link, there's no way to "send" it anywhere. You can create a tarball and upload that instead.
cd /path/to/the/files && tar cvf libs.tar *
Then on the receiving server, untar the files:
cd /path/to/the/files && tar xvf libs.tar
Assuming the symlinks are relative and pointing to files in the same directory, they will probably be successfully preserved. If they are absolute, they may be pointing to the wrong location.

how to script folder deletion on MAC

I believe it should be straight forward but either I am having a bad day or I simply can't find what I am looking for.
Please help.
I need to run following commands in MAC Terminal in order to get rid of following entries:
sudo rm -Rf /Applications/Network\ Connect.app
sudo rm -Rf /Library/Frameworks/net.juniper.DSApplicationServices.framework
sudo rm -Rf /Library/Frameworks/net.juniper.DSCoreServices.framework
sudo rm -Rf /Library/Frameworks/net.juniper.DSNetworkDiagnostics.framework
sudo rm -Rf /Library/Internet\ Plug-ins/net.juniper.DSSafariExtensions.plugin
sudo rm -Rf /Library/Widgets/Network\ Connect.wdgt
sudo rm -Rf /usr/local/juniper
sudo rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.bom
sudo rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.plist
sudo rm -Rf ~/Library/Preferences/ncproxyd.plist
It does it's job but it's not exactly elegant. I was also thinking about providing this to my colleagues so I wanted to create some sort of .bat file for MAC.
I really spent about half day trying to figure it out but it doesn't work :(
Can somebody help me to create a .sh file or bash file which will do execute the commands above?
Create a script file, let's say it's called deletion.sh and add the lines: -
#!/bin/bash
rm -Rf /Applications/Network\ Connect.app
rm -Rf /Library/Frameworks/net.juniper.DSApplicationServices.framework
rm -Rf /Library/Frameworks/net.juniper.DSCoreServices.framework
rm -Rf /Library/Frameworks/net.juniper.DSNetworkDiagnostics.framework
rm -Rf /Library/Internet\ Plug-ins/net.juniper.DSSafariExtensions.plugin
rm -Rf /Library/Widgets/Network\ Connect.wdgt
rm -Rf /usr/local/juniper
rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.bom
rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.plist
rm -Rf ~/Library/Preferences/ncproxyd.plist
Then, in terminal you need to set the executable flag to the script: -
chmod +x deletion.sh
Note that the executable flag may be removed when the script is copied to another machine or network drive, so you may have to do that after copying.
Finally, you can call the script with sudo
sudo ./deletion.sh
If you want to create a batch file, you have one. That list of commands is your shell script. To execute it, just save hem into a file add the bash command to the front of that file's name:
$ bash commands_I_want_to_execute.txt
If you want to get fancy, you can put a shebang on the top and set the execution bit using chmod. That will make your script a real shell script.
However, in order for your shell script to be found, you need to either prefix it with a path, or put it in a directory that's included in your PATH. Here, I'll just prefix it:
$ chmod a+x commands_I_want_to_execute.txt # Suffix doesn't really matter. It's executable
$ ./commands_I_want_to_execute.txt # Now this will be executed
If you are really bothered by the suffix, change it with the mv command:
$ mv commands_I_want_to_execute.txt commands_I_want_to_execute.sh
NOTE: If you create a file with Text Edit, create it as a plain text file and not as a RTF file.

Script to install Flash Player through postinst

I have created a debian package. I need to check for the Adobe Flash Player while installing this .deb. If flash player is not installed then i need to install it also. On browsing i got to know that postinst file can be used for this purpose.
The postinst file is
#!/bin/bash
echo “Stopping any Firefox that might be running”
sudo killall -9 firefox
echo “Removing any other flash plugin previously installed:”
sudo apt-get remove -y –purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper
echo “Installing Flash Player 10″
#cd ~
sudo cp /home/libflashplayer.so /usr/lib/mozilla/plugins/
echo “Linking the libraries so Firefox and apps depending on XULRunner.”
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/xulrunner-addons/plugins/
# now doing some cleaning up:
sudo rm -rf libflashplayer.so
sudo rm -rf libflashplayer-10.0.32.18.linux-x86_64.so.tar.gz
But nothing is happening.
Can anyone help me to write the script to install flash player through script?
Looks like you got your $HOME path wrong:
sudo cp /home/libflashplayer.so /usr/lib/mozilla/plugins/
did you mean:
sudo cp $HOME/libflashplayer.so /usr/lib/mozilla/plugins/

Resources