Source RPM Can't Find Files - redhat

I'm trying to build an RPM of a node.js project I'm working on. The project's code is entirely contained in one directory and its subdirectories. Here's part of my build script:
Put everything in the SOURCES directory, except the node_modules
echo "Copying sources..."
cd $DIR/dashboard
tar -zcf $DIR/rpmbuild/SOURCES/project-$VERSION.tgz . --exclude=node_modules > /dev/null
cd $DIR
# Create the spec file
touch $DIR/rpmbuild/SPECS/specfile
# write to it
cat >$DIR/rpmbuild/SPECS/specfile <<EOL
Summary: [Summary]
Name: [Name]
Version: $VERSION
Release: 1
License: GPL
Group: Applications/WebApp
Source: [Name]-$VERSION.tgz
Vendor: None
Requires: nodejs
%description
[Description]
%prep
echo "in prep"
echo $(ls -al)
%setup -c
npm install
yes | ./compile_all.sh
mv app/index.html app/index_big.html
mv app/index_small.html app/index.html
%build
echo "Nothing to build!"
%install
mkdir -p /opt/project
mv -r ./ /opt/project
ln -s /opt/project/server_start /usr/local/bin
ln -s /opt/project/server_stop /usr/local/bin
%files
$DIR/rpmbuild/SOURCES
$DIR/rpmbuild/SPECS
EOL
HOME=`pwd` rpmbuild -bs $DIR/rpmbuild/SPECS/specfile
The compile_all.sh script just minifies the html, css, and javascript and concatenates them. index_small.html uses the smaller versions. $DIR points to the location of the script, which is one directory above the project code.
The script does indeed generate the source rpm. I've looked at it using mc, and inside CONTENTS.cpio there's the specfile and the tgz archive of the source code. However, trying to install doesn't work. With rpm -Vp project.rpm, I can see that it lists the specfile and the tgz archive as missing. With verbose mode enabled, I see something similar to:
Directories not explicitly included in package:
/home/USERNAME/rpmbuild/SPECS/
/home/USERNAME/rpmbuild/SOURCES`
My rpmbuild directory isn't in my home directory, it's in the same directory as the build script. This leads to my actual question: how can I point rpmbuild at the correct location?

Related

How to install Robomongo from tar.gz file as a program in Ubuntu 15.10

Nowadays robomongo developers releasing the new versions of robomongo as tar.gz not in .deb packages that was easy for double click installations. But that option is no longer available. So how to install it as a program in Ubuntu. I have tried extracting the package and install but failed.
admin#admin-lenovo:~$ cd Downloads/
admin#admin-lenovo:~/Downloads$ tar -xzf robomongo-0.9.0-rc4-linux-x86_64-8c830b6.tar.gz
admin#admin-lenovo:~/Downloads$ cd robomongo-0.9.0-rc4-linux-x86_64-8c830b6/
admin#admin-lenovo:~/Downloads/robomongo-0.9.0-rc4-linux-x86_64-8c830b6$ ./configure
bash: ./configure: No such file or directory
Also .make and ./install failed as no files found. How to install it as a program?
Robomongo is now Robo 3T. Following are the updated steps:
Download the tar file from robomongo site. The current file is robo3t-1.1.1-linux-x86_64-c93c6b0.tar.gz, but yours could be different.
Open up the terminal, switch to download directory and run the following commands:
$ tar -xvzf robo3t-1.1.1-linux-x86_64-c93c6b0.tar.gz
$ sudo mkdir /usr/local/bin/robomongo
$ sudo mv robo3t-1.1.1-linux-x86_64-c93c6b0/* /usr/local/bin/robomongo
$ cd /usr/local/bin/robomongo/bin
$ sudo chmod +x robo3t
$ sudo gedit ~/.bashrc
Add the following line to the end of .bashrc file:
alias robomongo='/usr/local/bin/robomongo/bin/robo3t'
Save and close the file. Now reload it using the following command:
$ source ~/.bashrc
Then you can run robomongo from your terminal and it will work:
$ robomongo
You can also put the robomongo into /usr/bin like I do:
tar xf robomongo-0.9.0-rc8-linux-x86_64-c113244.tar.gz
sudo mv robomongo-0.9.0-rc8-linux-x86_64-c113244/ /usr/bin/robomongo
export PATH=/usr/bin/robomongo/bin:$PATH
If you are using fish shell, you need to change the last line to:
set PATH $PATH /usr/bin/robomongo/bin
Now you can start it with command:
robomongo
Pulled this from my dotfiles. It's ugly but it works... and it's a bit more verbose so it should be understandable to most:
# Pull down and install Robomongo by copying files
cd /tmp
wget https://download.robomongo.org/0.9.0/linux/robomongo-0.9.0-linux-x86_64-0786489.tar.gz
tar xf robomongo-0.9.0-linux-x86_64-0786489.tar.gz
sudo mv ./robomongo-0.9.0-linux-x86_64-0786489 /opt/robomongo
cd /usr/sbin
sudo ln -s /opt/robomongo/bin/robomongo
# Grab image to use for icon
cd /opt/robomongo
wget http://mongodb-tools.com/img/robomongo.png
# Create desktop entry
touch /tmp/robomongo.txt
echo "[Desktop Entry]" >> /tmp/robomongo.txt
echo "Encoding=UTF-8" >> /tmp/robomongo.txt
echo "Name=Robomongo" >> /tmp/robomongo.txt
echo "Comment=Launch Robomongo" >> /tmp/robomongo.txt
echo "Icon=/opt/robomongo/robomongo.png" >> /tmp/robomongo.txt
echo "Exec=/usr/sbin/robomono" >> /tmp/robomongo.txt
echo "Terminal=false" >> /tmp/robomongo.txt
echo "Type=Application" >> /tmp/robomongo.txt
echo "Categories=Developer;" >> /tmp/robomongo.txt
echo "StartupNotify=true" >> /tmp/robomongo.txt
mv /tmp/robomongo.txt ~/.local/share/applications/robomongo.desktop
1. First Download the version from the official Robomongo website bellow:
Download Robomongo From Official website using this link
2.Then extract the downloaded tar.gz file in your downloads folder.
3. Copy and paste the extracted folder into your opt folder
/opt
NB: If you don't have permission to paste in this folder use the bellow command in terminal to access the folder.
$ sudo chmod -R 777 /opt
4. Open the opt/robomongo/bin folder and launch Robomongo by clicking the executable icon.
opt/robomongo/bin
5. Simply Create a database and right click on the Robomongo icon and select the lock to launcher option. This will create a shortcut t launch the Robomongo application at any time you need.
You can first extract the package:
cd ~/Downloads
tar -xzf robo3t-x.x.x-linux-x86_64-xxxxxxx.tar.gz
You can rename the folder to something simpler
mv robo3t-x.x.x-linux-x86_64-xxxxxxx robo3t
Dowload any images with format .png [click here][1]
(For whatever reason, the Robo3T package itself does not contain any png file for the icon)
Save the image like robo3t.png and move this image to folder robo3t and then, instead of dumping the whole thing in /usr you can transfer this directory to /opt directory and symlink the binary file to /usr/bin or /usr/local/bin. This makes for a better way of organising your applications, and keeping such add-on packages is what /opt is for.
So first move the directory
sudo mv robo3t /opt
and then symlink it like so
sudo ln -s /opt/robo3t/bin/robo3t /usr/bin/robo3t
then you can create an Unity desktop file for your launcher
nano ~/.local/share/applications/robo3t.desktop
and finally; paste the next code in the file newly created
[Desktop Entry]
Encoding=UTF-8
Name=Robo 3T
Exec=robo3t
Icon=/opt/robo3t/robo3t.png
Terminal=false
Type=Application
Categories=Development;
And Happy coding!
Currently there is no installer for robomongo-0.9.0-rc4. you can create a desktop shortcut to robomongo-0.9.0-rc4-linux-x86_64-8c830b6/bin/robomongo file and use it just like any other Ubuntu app. Take a look at this tutorial https://askubuntu.com/a/142197/71544
Wathc this Video
How to install robomongo on ubuntu 16.4
OR
Follow Below Steps
Open Terminal and run the below command
wget https://download.robomongo.org/0.9.0/linux/robomongo-0.9.0-linux-x86_64-0786489.tar.gz
Extract the tar.gz file to enter below command
tar -xvzf robomongo-0.9.0-linux-x86_64-0786489.tar.gz
create a dir /usr/local/bin dir name directory name robomongo and move it to extract file into robomongo directory
sudo mkdir /usr/local/bin/robomongo
sudo mv robomongo-0.9.0-linux-x86_64-0786489/* /usr/local/bin/robomongo
run command only if robomongo isn't executable file
cd /usr/local/bin/robomongo/bin
sudo chmod +x robomongo
./robomongo
Don't worry about how to install Robo-3T on your Linux machine, follow these simple steps:
Download script from Robo3T-Installation-With-Desktop Entry
Open terminal in directory where above file is downloaded and run below command
sudo chmod +x ./Robo3T-Installation-Menu.sh
Then type below command and hit enter
./Robo3T-Installation-Menu.sh
Just wait to complete it, once completed enjoy RoboMongo. Search in menu with name "Robo 3T".
Well, I do not know if it might still help, but one efficient way to install Robomongo from tar.gz file is the following:
Go to https://robomongo.org/download to grab the tar.gz file,
After download,
cd Downloads/*
and then type in the terminal:
$ sudo tar xzf robo3t-1.3.1-linux-x86_64-7419c406.tar.gz -C /opt/
Make sure your file has been unzipped in the /opt directory by checking:
$ ls -lh /opt/
Next, install it by doing:
$ sudo /opt/robo3t-1.3.1-linux-x86_64-7419c406/bin/robo3t
The installation wizard pops up and accept the terms and continue installation. Then Enjoy
NB: You will not see the robot3t icon in the start menu. So to start robot3t, always
/opt/robo3t-1.3.1-linux-x86_64-7419c406/bin/robo3t to launch robo3T.
Hope it helps ;)

rpmbuild no such file or directory

I'm just learning making rpm packages for some custom builds of software that gets compiled from source (some legacy stuff needs this, so I'm trying to learn, as some packages can't use the latest versions), but hitting an error (I'm doing this in Vagrant, and also as root, but typically I'm trying not to use root as I'm aware it has potential for damage, its just this example seems to need some root changes).
sudo rpmbuild -ba testspec.spec --define "_topdir /tmp/"
So far it looks to be using the directory I expected, /tmp/rpmbuild
make[2]: Entering directory `/tmp/rpmbuild/BUILD/exim-4.80.1/build-Linux-x86_64/pdkim'
make[2]: `pdkim.a' is up to date.
make[2]: Leaving directory `/tmp/rpmbu
But then I see these errors...
/usr/lib/rpm/brp-compress: line 8: cd: /tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64: No such file or directory
+ /usr/lib/rpm/brp-strip
find: `/tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-static-archive
find: `/tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-comment-note
So it now seems to be looking in /tmp/BUILDROOT
I'm new to rpmbuild, and don't quite understand some of the process.
My test spec file is at...
%define myversion exim-4.80.1
##%define mybase %{getenv:HOME}
%define mybase /tmp
%define _topdir %{mybase}/rpmbuild
%define _tmppath %{mybase}/rpmbuild/tmp
%define name custom-exim
%define release 1
%define version 4.80.1
%define buildroot %{_topdir}/%{name}-%{version}-root
BuildRoot: %{buildroot}
Summary: %{name}
Name: %{name}
Version: %{version}
Release: %{release}
Source0: ftp://exim.noris.de/exim/exim4/old/exim-4.80.1.tar.gz
License: GPLv1+
Group: Language
AutoReq: no
AutoProv: no
Requires: db4-devel pcre-devel libdb-devel libXt-devel libXaw-devel
%description
Custom Exim Build
%prep
#Do the following manually before building rpm
#mkdir -p /tmp/rpmbuild/BUILD /tmp/rpmbuild/SPECS /tmp/rpmbuild/SOURCES /tmp/rpmbuild/BUILDROOT /tmp/rpmbuild/RPMS /tmp/rpmbuild/SRPMS
#wget ftp://exim.noris.de/exim/exim4/old/exim-4.80.1.tar.gz -O /tmp/rpmbuild/SOURCES/exim-4.80.1.tar.gz
%setup -q -n %{myversion}
grep exim /etc/passwd || useradd -c "Exim" -d /var/spool/exim -m -s /bin/bash exim
%build
# exim needs to config changes before compiling, may do these first and repackage
cp %{mybase}/rpmbuild/BUILD/%{myversion}/src/EDITME %{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile
cp %{mybase}/rpmbuild/BUILD/%{myversion}/exim_monitor/EDITME %{mybase}/rpmbuild/BUILD/%{myversion}/Local/eximon.conf
sed -i -e 's/EXIM_USER=$/EXIM_USER=exim/g' "%{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile"
sed -i -e 's/LOOKUP_DNSDB=yes/#LOOKUP_DNSDB=yes/g' "%{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile"
make
%install
rm -rf $RPM_BUILD_ROOT
#%{__mkdir_p} '%{buildroot}%{_sbindir}'
make install
%clean
rm -rf $RPM_BUILD_ROOT
%post
%postun
%files
Why is it using /tmp/BUILDROOT literally, instead of /tmp/rpmbuild, and are there other obvious things I'm doing wrong ? I've looked at a lot of other tutorials on rpmbuild, but aren't very clear on best practices or what happens during each phase.
Since the buildroot parm is not passed to rpmbuild, the default path is being used by your spec file:
BuildRoot: %{buildroot}
Try adding the buildroot parm... Add buildroot /tmp/rpmbuild to --define
Or if using a makefile:
BUILD_TMP=/tmp/rpmbuild
TOP_DIR=/tmp
rpmbuild -bb
--buildroot $(BUILD_TMP)
--topdir $(TOP_DIR)
$(SPEC_DIR)/testspec.spec
In my case rpm-build was missing.
So sudo yum install rpm-build solved the problem. Or if you use puppet:
package { 'rpm-build':
ensure => latest,
}

rpm build fails to make build root dir

I am working on making an rpm for a small program used within our enterprise. The %build section of the rpm process works. I'm having trouble with the install section. I've referenced this article response and I believe I am properly referring to the target location with respect to %{_buildroot}.
The program I'm making is to be installed as a system service. So, after the rpm actually is generated for this step, I've got to add the next step in my installation process which is to include the script that is installed to the init.d location and run that install. One step at a time though.
The build errors are as follows (omitting everything but %install):
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.eUDaCK
+ umask 022
+ cd /home/packager/rpmbuild/BUILD
+ '[' /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 '!=' / ']'
+ rm -rf /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
++ dirname /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ mkdir -p /home/packager/rpmbuild/BUILDROOT
+ mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ cd o2arbitord-1.0
+ LANG=C
+ export LANG
+ unset DISPLAY
+ install -m 555 /home/packager/rpmbuild/BUILD/o2arbitord-1.0/o2arbitord /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin
install: cannot create regular file `/home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.eUDaCK (%install)
Now, my rpmbuild directory does not have the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin. While I know that's part of the problem, the rpmbuild process isn't making the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 either. What I don't understand about that one is: why? Looking at the script output above you can clearly see the line: mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64. So, why isn't the directory made?
How does the line BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) from whatever the definition of %{_buildroot} is? I thought that was the definition, but it appears to be something different.
For reference, my spec file
Name: o2arbitord
Version: 1.0
Release: 1%{?dist}
Summary: a daemon
Group: Applications/System
License: GPL
URL: http://My.site
Source0: %{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: x86_64
BuildRequires: libusb1-devel
#Requires:
%description
%prep
%setup -q
%build
make -f o2arbitord.mk
%install
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/usr/sbin/o2arbitord
%changelog
You are attempting to install a file into a directory that doesn't exist (yet).
RPM only creates the %{buildroot} for you automatically. Anything under that you need to create yourself.
So when you run
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
where %{buildroot}%{_sbindir} expands to /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin RPM has only created /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 for you already.
You need to create the /usr/sbin part of that path and then copy the file into it.
You can do that with either
%{__mkdir_p} '%{buildroot}%{_sbindir}'
or
%{__install} -d '%{buildroot}%{_sbindir}'
Where
$ rpm -E '__mkdir_p = %{__mkdir_p}'
__mkdir_p = /bin/mkdir -p
$ rpm -E '__install = %{__install}'
__install = /usr/bin/install

RPM %files absolute path issue

I am relatively new to creating RPM packages. I am using Fedora 19 OS , I am not able to make RPM pick %files from absolute path. Please advice on the same
Name: SampleRpm
Version: 1
License: none
Release: 5.6
buildroot: /root/rpmbuild
prefix: /root/rpmbuild
Summary: Sample
Group: Applications/Sample
%prep
rm -r /home/siva/rpmbuild/SOURCES/
%build
cd /home/siva/repos/centina/sa
ant clean make-private dist
cp /home/siva/repos/centina/sa/dist/Sample.zip /root/rpmbuild/SOURCES
%install
cp /home/siva/repos/centina/sa/dist/Sample.zip /root/setup
cd /root/setup
unzip Sample.zip
chmod +x setup.sh
./setup.sh -o
%description
empty
%files
/root/rpmbuild/SOURCES
i get the following error
error: File not found: /root/rpmbuild/BUILDROOT/SampleRpm-1-5.6.x86_64/root/rpmbuild/SOURCES
Thanks in advance
%files is where the final files will be. I would recommend finding an RPM primer online - there are many that walk you right thru step by step.

How to set the rpmbuild destination folder

I noticed rpmbuild (-bb and --buildroot options) creates the .rpm in different locations depending of what OS are you using:
GNU/Linux Ubuntu <= 9.04: /usr/src/rpm/...
GNU/Linux Ubuntu >= 9.10: /home/rpmbuild/...
GNU/Linux Fedora: /usr/src/redhat/...
So how can I set manually the destination folder for all OS?
Replying myself, adding:
%define _rpmdir /outputdir
to .spec file.
You may want to use the command argument --define : For example, this will send the rpm files into the current directory.
rpmbuild anything.spec --bb --define "_rpmdir $(pwd)"
This will send the rpmsto output dir
rpmbuild anything.spec --bb --define "_rpmdir /outputdir"
Or perhaps something more complicated such as Custom gradle task for rpmbuild .
For me the solution was to set _topdir to a subdirectory called rpmbuild inside my project. I also set a few macros, to control the .rpm path:
rpm:
rpmbuild -bb package.spec -D "_topdir $(shell pwd)/rpmbuild" -D "SRC $(shell pwd)" -D "NAME $(NAME)" -D "ARCH $(ARCH)" -D "VERSION $(VERSION)" -D "RELEASE $(RELEASE)"
mv rpmbuild/RPMS/$(ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(ARCH).rpm ./
rm -rf rpmbuild
Then I use make to generate the .rpm file and move it. I prefer rpmbuild to operate inside its directory.
make rpm
package.spec is using these macros, e.g.
Name: %{NAME_PACKAGE}
Setting up the rpmbuild environment in /home/ http://www.linuxquestions.org/questions/linux-software-2/need-rpm-package-for-php-version-5-2-7-and-up-on-redhat-5-1-a-766486/#13
Actually it is not recommended to use /usr/src/**. I.e. by using /home/[name]/rpms/ you can work as unprivileged user. No su or sudo is required to build packages.
Just a tiny comment..
adding "%define _rpmdir /outputdir" to spec file is also support by rpmbuild in AIX OS