rpmbuild | specfile | %post | to execute a command or script as part of rpm install - rpmbuild

How to execute some commands or scripts immediately after rpm installed and has to be run as part rpm install command.
I wrote a spec file to take back up of some files within directory and tar them.
When I install rpm tar would be copied on file system how ever I had to untar the ball manually to desired location.
RPM spec %post doesn't execute in rpmbuild
The above lost helped me understand we can include %post steps in spec file itself which would do that job and commands get execute as part of rpm install command itself.
The %post section runs when you install an RPM
Note that echo command included for test purpose are not executed.

For more information on %post in spec file please refer http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html#S2-RPM-INSIDE-BUILD-TIME-SCRIPTS

Related

Creating a portable version of R for Mac (and installing package from source for this version)

I am trying to create a completely portable version of R for Mac that I can send to users with no R on their system and they can essentially double click a command file and it launches a Shiny application. I'll need to be able to install packages including some built from source (and some from GitHub).
I am using the script from this GitHub repository (https://github.com/dirkschumacher/r-shiny-electron/blob/master/get-r-mac.sh) as a starting point (it's also pasted below), creating a version of R, but (A) I find that when I try to launch R it gives me an error not finding etc/ldpaths and (B) when I try to launch Rscript it runs my system version -- I run `Rscript -e 'print(R.version)' and it prints out 4.0 which is my system version of R rather than the version 3.5.1 which the shell script has downloaded and processed.
I've experimented with editing the "R" executable and altering R_HOME and R_HOME_DIR but it still runs into issues when I try to install packages to the 3.5.1 directory.
Can anyone provide some guidance?
(By the way docker is not an option, this needs to be as simple as possible end-users with limited technical skills. So having them install docker etc won't be an option)
#!/usr/bin/env bash
set -e
# Download and extract the main Mac Resources directory
# Requires xar and cpio, both installed in the Dockerfile
mkdir -p r-mac
curl -o r-mac/latest_r.pkg \
https://cloud.r-project.org/bin/macosx/R-3.5.1.pkg
cd r-mac
xar -xf latest_r.pkg
rm -r r-1.pkg Resources tcltk8.pkg texinfo5.pkg Distribution latest_r.pkg
cat r.pkg/Payload | gunzip -dc | cpio -i
mv R.framework/Versions/Current/Resources/* .
rm -r r.pkg R.framework
# Patch the main R script
sed -i.bak '/^R_HOME_DIR=/d' bin/R
sed -i.bak 's;/Library/Frameworks/R.framework/Resources;${R_HOME};g' \
bin/R
chmod +x bin/R
rm -f bin/R.bak
# Remove unneccessary files TODO: What else
rm -r doc tests
rm -r lib/*.dSYM
Happy to help you get this working for your shiny app. You can use this github repo for Electron wrapping R/Shiny... just clone, and replace the app.R (for your other packages you need to install them in the local R folder after cloning and then running R from the command line out of the R-Portable-Mac/bin folder...
Try it with the Hello World app.R that is included first
https://github.com/ColumbusCollaboratory/electron-quick-start
And, then installing your packages in the local R-Portable-Mac folder runtime. Included packages by default...
https://github.com/ColumbusCollaboratory/electron-quick-start/tree/master/R-Portable-Mac/library
Your packages will show up here after install.packages() from the command line using the local R-Mac-Portable runtime.
We have been working on a R Addin for this also...
https://github.com/ColumbusCollaboratory/photon
But, note the add-in is still a work in progress and doesn't work with compiled R packages; still have to go into the local R folder and runtime on the command line and install the packages directly into the local R folder libpath as discussed above.
Give it a try and let us know through Github issues if you have any questions and issues. And, if you've already posted out there, sorry we haven't responded as of yet. Would love to communicate through the photon Add-In for this to get it working with compiling packages (into the libPath)--if you have the time to help. Thanks!

makefile into debian package, copy files and directories recursively

I realized that with debian/rules
override_dh_auto_install:
dh_auto_install -- prefix=/usr
it's impossible to get a file copied into the directory structure of the debian package with the cp command, but with install yes. So I understood, or interpreted that only the install command is interpreted by the dpkg-buildpackage -us -uc -ui -i command to copy temporarilly the files into the .deb file before installing them during any dpkg -i process.
The problem is that when I want to copy many files and an entire directory structure, I'm unable to do it as mentionned in various places on the web with tricks like find command for ex.
So the problems I have now is how from a Makefile do I specify that I want that to be converted into real world of debian package??!!!
cp -r some/src/dir/from/current_dir /to/opt/myCompany/for/example/bin
ln -s /to/opt/myCompany/for/example/bin/ /usr/local/bin
Both are misinterpreted by the dpkg-buildpackage

Prep line in rpm spec causes duplicate directory inside rpm

I have this spec file for my open source shell scripting sdk https://github.com/icasimpan/shcf/blob/packagebuilds/packagebuilds/rpm/shcf.spec
I build it as follows:
rpmbuild --target noarch -bb shcf.spec
Now, this builds fine, however, the output rpm's content has duplicated path "shcf/shcf", like:
/opt/icasimpan/shcf/shcf/***
This is the prep area
%prep
echo "BUILDROOT = $RPM_BUILD_ROOT"
mkdir -p $RPM_BUILD_ROOT/opt/icasimpan/shcf
cd $RPM_BUILD_ROOT/opt/icasimpan/shcf
git clone --branch 0.3.1 https://github.com/icasimpan/shcf.git
exit
At first sight, it's obviously due to the clone done to "$RPM_BUILD_ROOT/opt/icasimpan/shcf". However, if I modify the clone line to say
git clone --branch 0.3.1 https://github.com/icasimpan/shcf.git .
rpm build will fail due to unpackaged files.
Is there anything I'm missing?
Thanks in advance.

How to execute sqlite test file?

I downloaded the sqlite3 source file (not amalgamation version)
There are test folder and many test files (journal1.test , pager1.test ... etc)
How to execute these test files?
Go to the SQLite's download page and download the Snapshop of the complete (raw) source tree on the Alternative Source Code Formats section.
Unzip it, cd into the folder and run:
sudo apt install tcl-dev zlib1g-dev
./configure
make test
You can run the quick test instead (less than 3 minutes):
make quicktest
Or just the tcl tests (aka veryquick):
make tcltest
On Mac
brew install tcl-tk
./configure --with-tcl=/usr/local/opt/tcl-tk/lib
make test

Rstudio-server on RHEL 6.5 pandoc error ifluatex.sty not found

OS: RHEL 6.5 x64
Rstudio-server Version 0.98.1062
R version 3.1.1 (2014-07-10)
knitr version 1.6
When attempting to knit an Rmarkdown file I get a failure during the pandoc stage of the compilation:
pandoc: Error producing PDF from TeX source.
! LaTeX Error: File 'ifluatex.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
Tried the (9-hour-long) full manual LiveTeX install, just to be sure, and luatex is now installed, but there is still no ifluatex.sty to be found. How do I tell RStudioServer/knitr/pandoc where the installation directory for that file is?
Many thanks to Homer White's blog for sending me in the right direction. I'm more or less posting his answer verbatim, with minor modifications for RHEL 6.5 and 2014 LiveTex.
Even the full manual install had not solved the problem. Following Homer's advice, I downloaded from the internet a copy of ifluatex.sty
You can get it either directly or via wget from the CTAN archive.
wget http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/ifluatex.dtx
tex ifluatex.dtx
Copy the resulting file into the shared folder for your LaTeX Distribution. In RHEL 6/CentOS for the 2014 LiveTex distribution installed via install-tl this was:
/usr/share/texmf/tex/generic/oberdiek
Easy, right? Next step was to get the framed package:
wget http://mirrors.ctan.org/macros/latex/contrib/framed.zip
unzip framed.zip
This should create a folder in the download location. Now copy the entire folder to the Shared LiveTeX folder for LaTeX:
/usr/share/texmf/tex/latex
Finally, let LiveTeX know it should update its library by running
texhash
PS: Note that I had root access. You might need it as well, of if you're a wheel user, prefix with sudo.
Here is quick'n'dirty rpm spec file for those who do not want to install non-packaged files to /usr.
Name: texlive-rstudio-addon-el6
Version: 0.1
Release: 1%{?dist}
Summary: addon stylesheets for Rstudio pandoc
Group: Publishing
License: LPPL1.3c+
URL: http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/
Source0: http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/ifluatex.dtx
Source1: http://mirrors.ctan.org/macros/latex/contrib/framed.zip
BuildRequires: texlive
BuildRequires: texlive-texmf
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
%description
Couple styles addons which are required by RStudio pandoc when processing Rmarkdown documents
%prep
%setup -q -c -T
cat %{SOURCE0} > ifluatex.dtx
unzip %{SOURCE1}
%build
%install
rm -rf %{buildroot} && mkdir -p %{buildroot}
tex ifluatex.dtx
mkdir -p %{buildroot}/%{_texmf_main}/tex/generic/oberdiek
mkdir -p %{buildroot}/%{_texmf_main}/tex/latex/
cp ifluatex.sty %{buildroot}/%{_texmf_main}/tex/generic/oberdiek
cp -a framed %{buildroot}/%{_texmf_main}/tex/latex/
%clean
rm -rf %{buildroot}
%post
[ -x %{_bindir}/texconfig-sys ] && %{_bindir}/texconfig-sys rehash 2> /dev/null
%files
%defattr(-,root,root)
%{_texmf_main}/tex/generic/oberdiek/ifluatex.sty
%{_texmf_main}/tex/latex/framed/*
%doc
%changelog
For my fix root was needed and ifluatex and frame file permissions needed to be updated.

Resources