Deleteing files after adding to tar - archive

Currently I'm working on my bash script which does backup mysql data, the only problem I got is the parameter of tar which was working on the debian, but its not working on FreeBSD.
Yes, I have read this:
Deleting files after adding to tar archive
And the answer is the solution I was always using on debian - I mean the --remove-files parameter.
Executing the following command on FreeBSD:
tar --remove-files -jcPf $DIR/$Y/$M/$D/mysql-$HOUR.tar.bz2 *.sql
Throws the following error:
tar: Option --remove-files is not supported
I havent found anything similar to the --remove-files param. while reading the man tar, so what is the solution?

Does it have to be tar option? Most probably --remove-files is gnu extension (or whatever), so you'd probably be able to just install this 'extended' version of tar on FreeBSD and use it.
If you cannot/don't want to, I think this would do:
tar -jvcPf $DIR/$Y/$M/$D/mysql-$HOUR.tar.bz2 *.sql | xargs rm
BTW, I think the '-' can (and should) be omitted from the tar options...

Related

Where magic database for filetypes

Where one can download or obtain source of magic database for libmagic (a file command). I have compiled version in /usr/share/misc/magic.mgc but can not find original source file. (Ideally I would like to know where on the Internet is original, NOT system/distribution-specific format of such file.)
I was unable to find it ever after hours of googling.
Thanks
In the sources for the file command (github; ftp). Specifically, in the "magic" subdirectory. There is not a single source file; the database is compiled from multiple sources.
("libmagic" is part of the file package).
The file utility has a GitHub repository at https://github.com/file/file and a homepage at http://www.darwinsys.com/file/
I imagine that any distribution using these sources do so in a modified form. It might even be that the local file utility and the associated libmagic library has diverged significantly from the above sources.
On OpenBSD systems, the libmagic library is available as a port. It will pull the sources from an FTP site associated with the GitHub repository above.
In Ubuntu, you can get exact source code for libmagic (with patches, if any) with the following command:
apt-get source libmagic-dev
It will download the source to the current directory.
If you didn't know the package name, you could use apt-file to find out:
apt-file search libmagic.so
You might need to install apt-file using
sudo apt-get install apt-file
sudo apt-file update

Installing gcc manually redhat

I am working on a system on which I am a non-root user.
While trying to install gcc 5.1 in a custom directory as the present shared version of gcc isn't working for postgresql installation, I started out by
wget gcc 5.1.
After unzipping the folder, ran the commands below:
cd /seq/genome_portal/lib
mkdir bld
mkdir gcc
cd bld
/seq/genome_portal/lib/gcc-5.1/configure --prefix=/seq/genome_portal/lib/gcc
However config.log still shows this error:
/../../redhat_6_x86_64/pkgs/gcc_4.9.0/libexec/gcc/x86_64-redhat-linux/4.9.0/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
The prerequisites that come after
./contrib/download_prerequisites
are gmp,mpfr and mpc. I started with gmp and ended up in the same error as above. I somehow need to tell these programs that I do not want to use the existing gcc.
But I get the same error as mentioned before. Any advice as to how I can proceed to install it?
Building a compiler is much more complicated that building a straightforward utility; just running configure is not enough.
Primarily, you need to read the instructions; they are provided in the GCC source directory in the INSTALL subdirectory. They are in HTML so point your browser at it.
I know you didn't do this yet because the step on configuration makes very clear you should be using an out-of-source configuration; e.g., something like:
mkdir ../bld
cd ../bld
../gcc-5.1/configure ...
rather than running ./configure.
Regarding the missing dependencies, there's a "prerequisites" section in the docs. To get MPFR and other helpful things you can run:
cd gcc-5.1
./contrib/download_prerequisites
ETA: This should work:
rm -rf newgcc
mkdir newgcc
cd newgcc
tar xzf gcc-5.1.tar.gz
cd gcc-5.1
./contrib/download_prerequisites
mkdir ../bld
cd ../bld
../gcc-5.1/configure <configopts>
make -j8
make install
(or whatever -j you prefer).

Where is my "stdio.h" in Mac?

I know that Mac OS X is a Unix-based system. And I heard that C standard library such as stdio.h, is located in /usr/local/include or /usr/include. But there is not any kind of library in this directory. I use Terminal to search this directory and I also use command like find ./ -iname "stdio.h", but nothing comes out. However, strangely enough, gcc -test.c -o test command works out. How did it happen? I want to know where my C library is located.
p.s I also use Xcode, too. Is it related with this application? help me!
And I have AWS EC2 linux server, and it has both libraries that i refereed above.
If you have Xcode but have not installed the optional Command Line Tools package then the standard includes and libraries may not be found in the usual place. Try:
$ find /Applications/Xcode.app -name stdio.h
and you'll probably see something like:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h
However you might want to install the Command Line Tools package if you plan on doing any non-Xcode (i.e. command line) programming. You will then see the usual headers and libraries in /usr/include and /usr/lib.
If you don't have Command Line Tools installed you can run:
xcode-select --install
A dialogue box opens for you to accept the license agreement and so on.
(This was missing from the above responses.)
create/update a symlink for /usr/include to have the libs detected:
sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /usr/include
The above path can be found by searching for stdio.h
find /Applications/Xcode.app -path '*/usr/include/stdio.h'
I have to do this with every XCode/MacOS SDK update, Faced this today with the XCode 7 upgrade.
Once the command line tools are installed, they cannot be re-installed with xcode-select, so the path may not be updated with a Mac AppStore upgrade.
Uninstalling & Reinstalling XCode and then running xcode-select --install might update the path, but is an overkill.
Some posts also mention xcode-select --switch /Application/Xcode.app, but I didn't have much luck with it.
The root reason is missing the /usr/include folder, installing command-line tools sometimes will not automatically add it.
Install the package at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
In my laptop it appears in many locations like /usr/include/stdio.h and /usr/include/sys/stdio.h and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h.
If you already built your locate database, you can use
locate stdio.h
If you haven't already, build it. The locate command is awesome!
Due to Apple's new System Integrity Protection (SIP), you will run into this error when attempting the solution of creating/updating a symlink to /usr/include
ln: /usr/include: Operation not permitted
Instead of disabling SIP, the better way to do it is to create symlinks in /usr/local/include instead, e.g.
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
This works for people who have already installed CommandLineTools and was unable to find stdio.h inside /usr/include
In the folder
Applications/Xcode/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
or similar.
I have installed "CommandLineTools", and the "stdio.h" file exist in both Xcode and CommandLineTools diretory.
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
This is my path for C/C++ library in M1 Mac 2022
/Library/Developer/CommandLineTools/usr/include/c++/v1

Issue Statically Compiling Thrift 0.9.0 on Centos 6.5

I'm working to compile the Thrift 0.9.0 binary statically in a CentOS VM. I get the issue that the libthrift.a binary is not being created. I am using a vagrant box to run centos:
https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box
Once I ssh to the vagrant box I run the following commands:
wget https://archive.apache.org/dist/thrift/0.9.0/thrift-0.9.0.tar.gz
tar -zxvf thrift-0.9.0.tar.gz
cd thrift-0.9.0
./configure --enable-static
make
This will run but I ran a find command (sudo find / -name "*.a") on the system to see if there was any ".a" files made and the only file that was made was "libparse.a" which doesn't seem right. From my understanding it should be "libthrift.a".
Searching through the config.log file it says that it does want to build the static libraries:
configure:11944: checking whether to build static libraries
configure:11948: result: yes
Looking at more locations in the log file that has the keyword "static" reveals potential places that may be errors.
configure:9028: checking if gcc static flag -static works
configure:9056: result: no
configure:13915: checking if g++ static flag -static works
configure:13943: result: no
lt_cv_prog_compiler_static_works=no
lt_cv_prog_compiler_static_works_CXX=no
The full log file is here: http://www.filehosting.org/file/details/449460/staticThriftErrorLog.rtf
Any help is appreciated
I was able to generate the libthrift.a file. After running the command for the extra dependancies mentioned in my comment I forgot to run the make command. So after doing the make command I found the libthrift.a file in "thrift-0.9.0/lib/cpp/.libs/". Interestingly enough, even after fixing the dependencies, config.log still had the same potential problem areas regarding the gcc/g++ static flag and static compiler.
Specifically the dependency command is as follows:
sudo yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel.x86_64
Edit: After getting advice on the Jira ticket, it turns out the specific vagrant box I was using was causing the errors. Using the VM he linked I was able to successfully build Thrift using the provided instructions. (Jira ticket https://issues.apache.org/jira/browse/THRIFT-2559)

I need my Debian rules file to simply copy files to it's target

I have a large project where we have the following files:
A few 3rd party pre-compiled binaries
Our own in-house binaries
collection of Ruby scripts
A sizable Ruby on Rails project
This product will be installed on appliance hardware that my employer has already selected, using Ubuntu Linux (Lucid) as the target OS, with our goal of distributing the archive as a Debian package to ease installation and upgrades. Additionally, we have a number of ERB templates that we need to "fill-in" with appropriate values on a per-customer basis, so the use of the postinst script will be particularly handy for our purposes.
As a side note, the Debian packages will be stored on a server repository that we manage in-house.
At this stage, I have used dh_make to create the Debian directory and related files (e.g., rules, control, etc.), but the rules file that is generated seems like overkill for my purposes.
Based on this description, all I really need the "rules" file to do is simply copy files from a source directory (or within an archive) to the target directories shown below:
/opt/company_product/3rd_party_binaries/bin
/opt/company_product/3rd_party_binaries/etc
/opt/company_product/in_hourse_binaries/bin
/opt/company_product/in_hourse_binaries/etc
/opt/company_product/ruby
/opt/company_product/rails_project
/opt/company_product/etc
/opt/company_product/shared/logs
/opt/company_product/shared/tmp
/opt/company_product/shared/license
...and so on.
I've read the Debian Policy Manual and several How-To's which indicate that you should not alter the rules file to use mkdir to create directories and there is generally a dh_ app (e.g., dh_installdirs, et al) that can suit your needs for nearly any installation purposes. The man pages for these dh_ related apps are cursory at best, and I am an "example" kind of guy.
That said, I'm a little lost on what the best approach is to getting my rules file to install my various pre-compiled binaries and Ruby/Rails text files to the desired locations.
Here's my initial rules file. It's pretty much a standard boilerplate rules file that dh_make creates. My thinking is that I should comment out all sections except for the install and then find the appropriate command(s) to make directories, copy files, etc. within that section.
Any advice or suggestions are greatly appreciated.
#!/usr/bin/make -f
package = testapp
CC = gcc
CFLAGS = -g -Wall
ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O2
endif
#export DH_VERBOSE=1
clean:
dh_testdir
dh_clean
rm -f build
install: build
dh_clean
dh_installdirs
echo "Place the Install Script here"
cp $(CURDIR)/testapp-2.0.tar.gz $(CURDIR)/debian/$(package)/opt/testapp-2.0
echo "Finished copying folders"
build:
touch build
binary-indep: install
# There are no architecture-independent files to be uploaded
# generated by this package. If there were any they would be
# made here.
binary-arch: install
dh_testdir -a
dh_testroot -a
dh_installdocs -a
dh_installchangelogs -a
dh_strip -a
dh_compress -a
dh_fixperms -a
dh_installdeb -a
dh_shlibdeps -a
dh_gencontrol -a
dh_md5sums -a
dh_builddeb -a
binary: binary-indep binary-arch
.PHONY: binary binary-arch binary-indep clean checkroot
Although you've already got your own answer, I'll point out a couple of things.
You seem to be doing this in a very complicated manner. If you simply need to copy files into certain directories, write a debian/mypackagename.install with the following format:
path/to/file/relative/to/source/root path/to/install/relative/to/system/root
(do not prepend / before /usr, or /opt, or whatever your target directory is. Read man dh_install for more information)
Then your debian/rules can be:
#!/usr/bin/make -f
%:
dh $#
If you have some sort of makefile, etc in your source root, then append this to the above rules file:
override_dh_auto_build:
override_dh_auto_install:
Don't forget put 7 in debian/compat.
Also, you shouldn't install files into /opt/ or /usr/local/, etc. Those are meant for files not installed by Debian packages. Debian recommends installing in /usr/share/yourcompany/. As juzzlin points out below, the Ubuntu Software Center may have different requirements.
More specifically, your mypackage.install file should look like this:
src/bin/* usr/bin
src/etc/* etc/
You can install cdbs and change the rules file like this
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
binary-install/package_name::
mkdir debian/$(cdbs_curpkg)/destination_path
cp path_of_your_files debian/$(cdbs_curpkg)/destination_path

Resources