How to create mongodb package to install with apt-get on Ubuntu? - mongodb

I'm building MongoDb from the sources (https://github.com/mongodb/mongo.git) and now want to package it as a .deb package such that I can install it on other Ubuntu machines using apt-get. Building it on Ubuntu 12.04.4 x64 is not the problem, but I cannot figure out how to create a .deb package from it.
The 'debian' directory in the checkout from git contain .rules and .control files but what command(s) must I invoke to create a package for the mongodb-enterprise version? Since all control files seem to be present I'd assume it's a matter of just running a command, but I cannot find it in the documentation or on the mongodb website. Also read the documenatation that TeTeT mentioned in the comments, but then I'd need to start form scratch to create the package and all that is needed already seems to be part of the 'debian' directory... just can figure out how to use it to build the package.
I did try using the dh_builddeb command, but that reported that the .control files is not a debian format archive.
The 'debian' directory contains the following files:
root#buildmongo:/mongobuild/mongo# ls -l debian/
total 424
-rw-r--r-- 1 root root 4001 Jul 25 16:12 bsondump.1
-rw-r--r-- 1 root root 5077 Jul 25 16:12 changelog
-rw-r--r-- 1 root root 2 Jul 25 16:12 compat
-rw-r--r-- 1 root root 483 Jul 25 16:12 copyright
-rw-r--r-- 1 root root 33 Jul 25 16:12 dirs
-rw-r--r-- 1 root root 39 Jul 25 16:12 files
-rw-r--r-- 1 root root 8216 Jul 25 16:12 init.d
-rw-r--r-- 1 root root 891 Jul 25 16:12 lintian-overrides
-rw-r--r-- 1 root root 16595 Jul 25 16:12 mongo.1
-rw-r--r-- 1 root root 39099 Jul 25 16:12 mongod.1
-rw-r--r-- 1 root root 1693 Jul 25 16:12 mongod.conf
-rw-r--r-- 1 root root 1676 Jul 25 16:12 mongod.upstart
-rw-r--r-- 1 root root 154 Jul 25 16:12 mongodb-enterprise-server.docs
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-enterprise-server.postinst
-rw-r--r-- 1 root root 154 Jul 25 16:12 mongodb-enterprise-unstable-server.docs
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-enterprise-unstable-server.postinst
-rw-r--r-- 1 root root 14760 Jul 25 16:12 mongodb-enterprise-unstable.control
-rw-r--r-- 1 root root 4524 Jul 25 16:12 mongodb-enterprise-unstable.rules
-rw-r--r-- 1 root root 14845 Jul 25 16:12 mongodb-enterprise.control
-rw-r--r-- 1 root root 4226 Jul 25 16:12 mongodb-enterprise.rules
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-org-server.postinst
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-org-unstable-server.postinst
-rw-r--r-- 1 root root 14704 Jul 25 16:12 mongodb-org-unstable.control
-rw-r--r-- 1 root root 4345 Jul 25 16:12 mongodb-org-unstable.rules
-rw-r--r-- 1 root root 14839 Jul 25 16:12 mongodb-org.control
-rw-r--r-- 1 root root 4049 Jul 25 16:12 mongodb-org.rules
-rw-r--r-- 1 root root 16840 Jul 25 16:12 mongodump.1
-rw-r--r-- 1 root root 19099 Jul 25 16:12 mongoexport.1
-rw-r--r-- 1 root root 14153 Jul 25 16:12 mongofiles.1
-rw-r--r-- 1 root root 16065 Jul 25 16:12 mongoimport.1
-rw-r--r-- 1 root root 13347 Jul 25 16:12 mongooplog.1
-rw-r--r-- 1 root root 5825 Jul 25 16:12 mongoperf.1
-rw-r--r-- 1 root root 16644 Jul 25 16:12 mongorestore.1
-rw-r--r-- 1 root root 23535 Jul 25 16:12 mongos.1
-rw-r--r-- 1 root root 5388 Jul 25 16:12 mongosniff.1
-rw-r--r-- 1 root root 15941 Jul 25 16:12 mongostat.1
-rw-r--r-- 1 root root 12415 Jul 25 16:12 mongotop.1
-rw-r--r-- 1 root root 932 Jul 25 16:12 postrm
-rw-r--r-- 1 root root 692 Jul 25 16:12 preinst
-rw-r--r-- 1 root root 894 Jul 25 16:12 prerm
-rw-r--r-- 1 root root 329 Jul 25 16:12 watch
(I'm building MongoDb because I need SSL support and do not need a support contract with Mongo. If I understand it correct you can only use the enterprise version (supports SSL) downloaded from the mongodb site if you signup for a support contract. )
Regards,
Gero

Upstream packaging is rarely better than maintainer's one so I would get source package from Debian:
apt-get install devscripts
dget -ux http://http.debian.net/debian/pool/main/m/mongodb/mongodb_2.4.10-2.dsc
cd mongodb-2.4.10/
## install Build-Depends (extracted from "debian/control"):
sudo apt-get install debhelper dh-systemd libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libgoogle-perftools-dev libpcap-dev libpcre3-dev libreadline-dev libsnappy-dev libstemmer-dev libssl-dev libv8-dev python-pymongo scons
debuild -uc -b
I'm with Debian so I did not test the above procedure on Ubuntu (which I don't recommend).
If package did not build (due to lack of build dependencies etc.) then you may choose a different suite from the following page
https://packages.debian.org/search?searchon=sourcenames&keywords=mongodb
and try to fetch an older DSC file.
Good luck.

Related

How to create a symlink to point to latest rotating log file

I've my application log file which keeps rotating and it has a pattern like below
postgresql-yyyy-mm-dd_hhmmss.log
-rw-------. 1 root root 331 Jun 1 22:04 postgresql-2022-06-01_220333.log.gz
-rw-------. 1 root root 417 Jun 1 22:04 postgresql-2022-06-01_220430.log.gz
-rw-------. 1 root root 289 Jun 2 19:28 postgresql-2022-06-02_000000.log.gz
-rw-------. 1 root root 26802 Jun 2 19:50 postgresql-2022-06-02_192809.log.gz
-rw-------. 1 root root 8440 Jun 2 23:57 postgresql-2022-06-02_195044.log.gz
-rw-------. 1 root root 15016 Jun 3 11:22 postgresql-2022-06-03_000000.log.gz
-rw-------. 1 root root 291 Jun 3 11:24 postgresql-2022-06-03_112405.log.gz
-rw-------. 1 root root 336 Jun 3 11:25 postgresql-2022-06-03_112553.log.gz
-rw-------. 1 root root 397 Jun 3 11:27 postgresql-2022-06-03_112714.log.gz
-rw-------. 1 root root 358 Jun 3 11:29 postgresql-2022-06-03_112901.log.gz
-rw-------. 1 root root 493 Jun 3 11:30 postgresql-2022-06-03_113031.log.gz
-rw-------. 1 root root 418 Jun 3 11:34 postgresql-2022-06-03_113354.log.gz
-rw-------. 1 root root 419 Jun 3 11:39 postgresql-2022-06-03_113920.log.gz
-rw-------. 1 root root 416 Jun 3 11:44 postgresql-2022-06-03_114437.log.gz
-rw-------. 1 root root 417 Jun 3 11:49 postgresql-2022-06-03_114943.log.gz
-rw-------. 1 root root 419 Jun 3 11:55 postgresql-2022-06-03_115530.log.gz
-rw-------. 1 root root 16961 Jun 3 23:56 postgresql-2022-06-03_120047.log.gz
-rw-------. 1 root root 35470 Jun 4 23:56 postgresql-2022-06-04_000000.log.gz
-rw-------. 1 root root 406059 Jun 5 17:56 postgresql-2022-06-05_000000.log
I want to run a small script(unix/linux) such that it creates a symlink in this folder which always points to the latest(current) logfile automatically for e.g
postgres.LOG -> postgresql-2022-06-05_000000.log
This way I don't have to ls and find out what is the current log file before opening, instead just open postgres.LOG.
All rotated logfiles seem gzipped so the glob postgresql-*.log will expand to the logfile of interest:
ln -sf postgresql-*.log postgres.LOG
If you want the symbolic link to be changed automatically each time a new log file is created you need inotify.
Something like this
#! /bin/bash
log_dir=/your/log/dir
inotifywait -m -e create "$log_dir" | while read -r _dir event file
do
if [[ ! -h "$log_dir/$file" && "$file" =~ \.log$ ]]
then
ln -sf "$log_dir/$file" "$log_dir/postgres.LOG"
fi
done
The format of the filename makes sure that the newest file sorts as last using ls. So this should work:
ln -sf $(ls postgresql-*.log | tail -1) postgres.LOG

How do you use tar to unzip a file in a dockerfile when using FROM perl

I'm trying to make a Docker container for a perl script, CooVar, but seem to be running into issues because the tar command is not available.
Dockerfile
FROM perl:5.20
RUN mkdir /tmp/install
WORKDIR /tmp/install
# Install cpan modules
RUN cpanm install Cwd Getopt::Long POSIX File::Basename List::Util Bio::DB::Fasta Bio::Seq Bio::SeqUtils Bio::SeqIO Set::IntervalTree Set::IntSpan
# Download CooVar-v0.07
RUN wget -O /usr/local/bin/CooVar-0.07.tar.gz http://genome.sfu.ca/projects/coovar/CooVar-0.07.tar.gz
RUN tar xvf /usr/local/bin/CooVar-0.07.tar.gz
# Set WORKDIR to /data -- predefined mount location.
RUN mkdir /data
WORKDIR /data
# And clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/install
# Set Entrypoint
ENTRYPOINT ["perl", "/usr/local/bin/coovar-0.07/coovar.pl"]
Note: I think the use of an Entrypoint here is preventing me from exploring a Docker containers file system via docker exec -t -i mycontainer /bin/bash but that's not a big issue as i think I know the problem from the error below.
Error
When I run this from Snakemake I was including ls /usr/bin so I can see what was in the container (very new to Dockerand not sure the best way to develop/debug yet). You can see that the.tar.gzwas not unzipped so it looks liketar` is not working in this case.
drwxrwxr-x 2 root root 2137 Oct 10 12:36 .
drwxrwxr-x 10 root root 147 May 5 2016 ..
-rw-r--r-- 1 root root 176772 Nov 20 2012 CooVar-0.07.tar.gz
-rwxr-xr-x 1 root root 112680 May 5 2016 a2p
-rwxr-xr-x 1 root root 2861 Oct 10 12:35 bp_aacomp
-rwxr-xr-x 1 root root 3696 Oct 10 12:35 bp_bioflat_index
-rwxr-xr-x 1 root root 1605 Oct 10 12:35 bp_biogetseq
-rwxr-xr-x 1 root root 2803 Oct 10 12:35 bp_dbsplit
-rwxr-xr-x 1 root root 2866 Oct 10 12:35 bp_extract_feature_seq
-rwxr-xr-x 1 root root 4002 Oct 10 12:35 bp_fastam9_to_table
-rwxr-xr-x 1 root root 7385 Oct 10 12:35 bp_fetch
-rwxr-xr-x 1 root root 1809 Oct 10 12:35 bp_filter_search
-rwxr-xr-x 1 root root 15121 Oct 10 12:35 bp_find-blast-matches
-rwxr-xr-x 1 root root 3427 Oct 10 12:35 bp_gccalc
-rwxr-xr-x 1 root root 79742 Oct 10 12:35 bp_genbank2gff3
-rwxr-xr-x 1 root root 4617 Oct 10 12:35 bp_index
-rwxr-xr-x 1 root root 1877 Oct 10 12:35 bp_local_taxonomydb_query
-rwxr-xr-x 1 root root 3239 Oct 10 12:35 bp_make_mrna_protein
-rwxr-xr-x 1 root root 4898 Oct 10 12:35 bp_mask_by_search
-rwxr-xr-x 1 root root 3041 Oct 10 12:35 bp_mrtrans
-rwxr-xr-x 1 root root 4292 Oct 10 12:35 bp_mutate
-rwxr-xr-x 1 root root 927 Oct 10 12:35 bp_nexus2nh
-rwxr-xr-x 1 root root 3533 Oct 10 12:35 bp_nrdb
-rwxr-xr-x 1 root root 6331 Oct 10 12:35 bp_oligo_count
-rwxr-xr-x 1 root root 7317 Oct 10 12:35 bp_process_gadfly
-rwxr-xr-x 1 root root 3752 Oct 10 12:35 bp_process_sgd
-rwxr-xr-x 1 root root 24416 Oct 10 12:35 bp_revtrans-motif
-rwxr-xr-x 1 root root 4190 Oct 10 12:35 bp_search2alnblocks
-rwxr-xr-x 1 root root 12519 Oct 10 12:35 bp_search2gff
-rwxr-xr-x 1 root root 2455 Oct 10 12:35 bp_search2table
-rwxr-xr-x 1 root root 2739 Oct 10 12:35 bp_search2tribe
-rwxr-xr-x 1 root root 1779 Oct 10 12:35 bp_seq_length
-rwxr-xr-x 1 root root 2289 Oct 10 12:35 bp_seqconvert
-rwxr-xr-x 1 root root 3833 Oct 10 12:35 bp_seqcut
-rwxr-xr-x 1 root root 4595 Oct 10 12:35 bp_seqpart
-rwxr-xr-x 1 root root 2339 Oct 10 12:35 bp_seqret
-rwxr-xr-x 1 root root 1549 Oct 10 12:35 bp_seqretsplit
-rwxr-xr-x 1 root root 4291 Oct 10 12:35 bp_split_seq
-rwxr-xr-x 1 root root 5912 Oct 10 12:35 bp_sreformat
-rwxr-xr-x 1 root root 3243 Oct 10 12:35 bp_taxid4species
-rwxr-xr-x 1 root root 2940 Oct 10 12:35 bp_taxonomy2tree
-rwxr-xr-x 1 root root 1624 Oct 10 12:35 bp_translate_seq
-rwxr-xr-x 1 root root 1488 Oct 10 12:35 bp_tree2pag
-rwxr-xr-x 1 root root 7504 Oct 10 12:35 bp_unflatten_seq
-rwxr-xr-x 2 root root 36619 May 5 2016 c2ph
-rwxr-xr-x 1 root root 7144 Oct 10 12:33 config_data
-rwxr-xr-x 1 root root 12804 May 5 2016 corelist
-rwxr-xr-x 1 root root 5873 May 5 2016 cpan
-rwxr-xr-x 1 root root 303998 May 5 2016 cpanm
-rwxr-xr-x 1 root root 41760 Oct 10 12:24 enc2xs
Anyone know how I can fix this Dockerfile?

cannot create directory for 'local::lib'

I have installed local::lib from cpan. But the manually one more again to make bootstrap - perl Makefile.PL −−bootstrap. And although I have already a file lib.pm here /usr/share/perl5/local/lib.pm, it when trying to bootstrap it (with the command mentioned above) this error rises:
Loading internal logger. Log::Log4perl recommended for better logging
Attempting to create directory /home/shepherd/perl5
Unable to create /home/shepherd/perl5/lib/perl5/5.28.0: No such file or directory at /usr/share/perl5/local/lib.pm line 717.
So if I have installed the module, and have it may dir, why the bootstrap cannot create /home/shepherd/perl5/lib/perl5/5.28.0 ?
I have and own this files:
ls -l ~/perl5
drwxrwxr-x 2 root root 4096 Nov 18 23:03 bin
drwxrwxr-x 3 root root 4096 Oct 28 18:52 lib
drwxrwxr-x 4 root root 4096 Oct 28 18:52 man
ls -l ~/perl5/lib
drwxrwxr-x 25 root root 4096 Nov 21 08:56 perl5
ls -l ~perl5/lib/perl5
drwxrwxr-x 2 root root 4096 Nov 20 19:54 B
drwxrwxr-x 3 root root 4096 Nov 21 08:56 Business
drwxrwxr-x 3 root root 4096 Oct 28 19:08 Class
drwxrwxr-x 2 root root 4096 Nov 20 19:54 Config
drwxrwxr-x 3 root root 4096 Oct 28 19:09 Devel
drwxrwxr-x 2 root root 4096 Oct 28 19:08 Dist
drwxrwxr-x 3 root root 4096 Nov 20 19:54 File
drwxrwxr-x 2 root root 4096 Nov 20 19:54 Hook
-r--r--r-- 1 root root 42537 Feb 18 2018 Importer.pm
drwxrwxr-x 3 root root 4096 Oct 28 19:10 IPC
drwxrwxr-x 3 root root 4096 Nov 18 23:03 Log
drwxrwxr-x 3 root root 4096 Nov 20 20:48 Mac
drwxrwxr-x 3 root root 4096 Oct 28 19:09 MIME
drwxrwxr-x 3 root root 4096 Oct 28 18:52 Module
-r--r--r-- 1 root root 967 Sep 6 16:40 ok.pm
drwxrwxr-x 2 root root 4096 Nov 19 23:13 OLE
drwxrwxr-x 3 root root 4096 Oct 28 19:08 Perl
drwxrwxr-x 3 root root 4096 Oct 28 19:09 POD2
drwxrwxr-x 2 root root 4096 Oct 28 19:09 Scope
drwxrwxr-x 2 root root 4096 Nov 20 19:56 String
drwxrwxr-x 2 root root 4096 Nov 20 19:54 Task
drwxrwxr-x 3 root root 4096 Oct 28 19:09 Term
drwxrwxr-x 9 root root 4096 Nov 20 19:54 Test
drwxrwxr-x 10 root root 4096 Oct 28 19:09 Test2
-r--r--r-- 1 root root 6393 Sep 6 16:40 Test2.pm
drwxrwxr-x 7 root root 4096 Nov 20 19:55 x86_64-linux-gnu-thread-multi
local::lib misreports the error reason. In this particular case, the problem is that the user running the program (shepherd) doesn't have permission to write to /home/shepherd/perl5/lib/perl5 in order to create /home/shepherd/perl5/lib/perl5/5.28.0.
The user will need to be granted the ability to write to that directory. This should probably be done by changing the ownership of the files from root to shepherd.
chown -R shepherd:shepherd ~/perl5

Command 'scala' not found on Ubuntu 18.04

I downloaded scala,unpacked it and copied to /usr/local/share
After that,I edited ~/.bashrc
export SCALA_HOME=/usr/local/share/scala-2.12.8
export PATH=$PATH:$SCALA_HOME/bin
Anyway,it does not work.
scala -version
Command 'scala' not found, but can be installed with:
sudo apt install scala
I could go for apt install but I don't get it what is wrong.
/usr/local/share$ ll
total 48
drwxr-xr-x 12 root root 4096 јул 1 06:03 ./
drwxr-xr-x 14 root root 4096 јун 23 18:04 ../
drwxr-xr-x 2 root root 4096 апр 21 08:04 appdata/
drwxr-xr-x 2 root root 4096 јун 25 21:03 applications/
drwxr-xr-x 2 root root 4096 јул 25 2018 ca-certificates/
drwxrwsr-x 3 root staff 4096 јул 25 2018 emacs/
drwxrwsr-x 2 root staff 4096 јул 25 2018 fonts/
drwxr-xr-x 3 root root 4096 апр 19 08:44 lua/
drwxr-xr-x 2 root root 4096 јул 25 2018 man/
drwxrwxr-x 6 miki miki 4096 дец 4 2018 scala-2.12.8/
drwxrwsr-x 7 root staff 4096 мај 14 15:05 sgml/
drwxrwsr-x 6 root staff 4096 мај 14 15:05 xml/
Editing .bashrc won't affect an already open shell. You could explicitly source it (source ~/.bashrc) to have it take effect, or open a new shell to reload it.

sphinx search data files

below is sphinx's data directory, is it safe to delete the .tmp files after indexing? will searchd use them?
-rw-r--r-- 1 root root 24M Apr 27 21:34 myindex.spa
-rw-r--r-- 1 root root 929M Apr 27 21:35 myindex.spd
-rw-r--r-- 1 root root 409 Apr 27 21:35 myindex.sph
-rw-r--r-- 1 root root 50M Apr 27 21:35 myindex.spi
-rw-r--r-- 1 root root 0 Apr 27 21:34 myindex.spk
-rw------- 1 root root 0 May 2 08:57 myindex.spl
-rw-r--r-- 1 root root 0 Apr 27 21:33 myindex.spm
-rw-r--r-- 1 root root 782M Apr 27 21:35 myindex.spp
-rw-r--r-- 1 root root 17M Apr 27 21:35 myindex.sps
-rw-r--r-- 1 root root 2.9G May 2 04:09 myindex.tmp.spa
-rw-r--r-- 1 root root 82G May 2 13:03 myindex.tmp.spd
-rw-r--r-- 1 root root 949M May 2 13:02 myindex.tmp.spi
-rw-r--r-- 1 root root 0 May 2 04:09 myindex.tmp.spk
-rw-r--r-- 1 root root 0 Apr 30 11:33 myindex.tmp.spl
-rw-r--r-- 1 root root 0 May 2 04:07 myindex.tmp.spm
-rw-r--r-- 1 root root 106G May 2 13:03 myindex.tmp.spp
-rw-r--r-- 1 root root 2.1G May 2 04:07 myindex.tmp.sps
-rw-r--r-- 1 root root 0 Apr 30 11:34 myindex.tmp.tmp0
-rw-r--r-- 1 root root 247G May 2 04:07 myindex.tmp.tmp1
-rw-r--r-- 1 root root 2.8G May 2 04:07 myindex.tmp.tmp2
-rw-r--r-- 1 root root 0 May 2 04:09 myindex.tmp.tmp8
I'm pretty sure that the .tmp files are created while you're indexing with the --rotate option defined. If you look at the timestamp on them you can see they're newer than the current indexes being used.
Once the rotate has completed the tmp files will replace the existing ones and the existing ones deleted.