Porting mysqldump-secure (port maintainer?)

Hi guys,

I am trying to fully port mysqldump-secure over to FreeBSD.
It is already at the state that the script itself is 100% fully working (POSIX shell without any bashism: #!/bin/sh).

I have one request as well as one error and one problem.


1. The request
I would like to get this as a port so I can use it via pkg or preferable via /usr/ports with make install.
However I have absolutely no idea about creating ports.

Maybe someone here wants to take over the port maintenance for that packet.
If so, either write it here or contact me with PM.
Full support will be given on any problems as well as full credit for that.



2. The problem

The problem I have is with tput and colored terminal output.
It works with OSX and Linux so far, but under FreeBSD I am not getting any colors.

The command I am using is as follows:
Code:
# If having a tty (console) use colors
if [ -t 1 ]; then
    CLR_OK="$(tput setf 2 2>/dev/null || tput setaf 2 2>/dev/null)"
    CLR_FATAL="$(tput setf 4 2>/dev/null || tput setaf 1 2>/dev/null)"
    CLR_ERROR="$(tput setf 4 2>/dev/null || tput setaf 1 2>/dev/null)"
    CLR_WARNING="$(tput setf 6 2>/dev/null || tput setaf 3 2>/dev/null)"
    CLR_DEBUG="$(tput setf 0 2>/dev/null || tput setaf 248 2>/dev/null)"
    CLR_TRACE="$(tput setf 0 2>/dev/null || tput setaf 242 2>/dev/null)"
    CLR_RESET="$(tput sgr0 2>/dev/null)"
# Dump terminal (e.g.: via cron)
else
    CLR_OK=""
    CLR_FATAL=""
    CLR_ERROR=""
    CLR_WARNING=""
    CLR_DEBUG=""
    CLR_TRACE=""
    CLR_RESET=""
fi

Any idea what is wrong here?



3. The error

Second, the error is that the Makefile is not working as it does under Linux or OSX.

I am getting the following errors:
Code:
make: "/root/repo/mysqldump-secure/Makefile" line 15: Unassociated shell command "ifneq ("$(wildcard configure.in)","")"
make: "/root/repo/mysqldump-secure/Makefile" line 16: Unassociated shell command "CONFIGURED = 1"
make: "/root/repo/mysqldump-secure/Makefile" line 17: Unassociated shell command "include configure.in"
make: "/root/repo/mysqldump-secure/Makefile" line 18: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 20: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 23: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 25: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 27: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 30: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 32: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 33: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 35: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 36: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 38: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 39: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 41: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 46: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 47: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 48: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 78: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 80: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 82: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 83: warning: duplicate script for target "ifeq" ignored
make: "/root/repo/mysqldump-secure/Makefile" line 79: warning: using previous script for "ifeq" defined here
make: "/root/repo/mysqldump-secure/Makefile" line 84: Need an operator
make: "/root/repo/mysqldump-secure/Makefile" line 125: Missing dependency operator
make: "/root/repo/mysqldump-secure/Makefile" line 126: warning: duplicate script for target "ifeq" ignored
make: "/root/repo/mysqldump-secure/Makefile" line 79: warning: using previous script for "ifeq" defined here
make: "/root/repo/mysqldump-secure/Makefile" line 126: warning: duplicate script for target "(0,0)" ignored
make: "/root/repo/mysqldump-secure/Makefile" line 79: warning: using previous script for "(0,0)" defined here
make: "/root/repo/mysqldump-secure/Makefile" line 127: Need an operator
make: Fatal errors encountered -- cannot continue
make: stopped in /root/repo/mysqldump-secure


Unfortunately I have no idea, why this is not working under FreeBSD as it works flawlessly under OSX (and as far as I know they share most binaries...or?)

The Makefile itself can be found here:

https://github.com/cytopia/mysqldump-secure/blob/master/Makefile

Thanks for the time
 
There are many ports in FreeBSD that simply need devel/gmake where the effort to patch for FreeBSD make(1) exceeds reasonable efforts.

Some upstream won't accept patches since they decided to got with the gmake(1) and stick with it. Since you apparently are the upstream maintainer, you are in a better position to fix things. *cough* :)

I'd first try with devel/gmake and get it working, and if you see a possibility to patch the makefiles without too much effort, go ahead.
 
They are sort of compatible with extremely simplistic Makefiles that make no use of any advanced features of either one but in any real porting effort you should just use devel/gmake for the Makefiles from the Linux land.
 
I don't want to pull in devel/gmake on FreeBSD just for the installation process... already put in too much effort to keep dependencies as low as possible
There are differences between build, run and library dependencies. In this case gmake would be a build dependency, i.e. it's only needed to build the port. People installing the package will not get it as a dependency.
 
There are differences between build, run and library dependencies. In this case gmake would be a build dependency, i.e. it's only needed to build the port. People installing the package will not get it as a dependency.

Note that there was a major change couple of years ago in how build dependencies were handled by the packages. Before the change your system was littered with build only dependencies if you installed packages because no one had cared to clean up the ports to include only the proper run time dependencies.
 
Ok thanks a lot for all the info. I will then probably stick to gmake.

Any idea why tput does not change the terminal color at all?
 
I have created a rough first draft of the port for mysqldump-secure. The submission is here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208032

Hopefully others will test it and/or have it committed to the ports tree.

Side note to cytopia: The configure script checks to see if the install directory exists and, if it does not, the configure script fails. However, the Makefile creates the installation directory in the next step of the installation. My suggestion would be to remove the check for the target directory in the configure script as installing to a new location will cause configure to fail.
 
NewGuy Thanks for the submission.
Also nice catch. I have removed the directory check in HEAD.

Just as a note: you have added v0.15 and I have released v0.16 just before opening the thread. But I guess that can be changed afterwards
 
The port should be easy to update. When I put it together I was following the install instructions on the project's website which said 0.15 is the latest stable release.
 
NewGuy
Could you please explain the process about the submission to me (Or point me to some documentation where I can read up on it).

a.) It is on the mailing list now. What are the next required steps.
b.) You have attached a shar archive. What is this about and how did you create that

Is there some more easy to read howto than the porters handbook out there?
 
SirDice that made things clear.

I also saw the following in the shar submission:
Code:
XUSE_MYSQL=yes

Does this mean it pull in mysql or will it just check locally for a mysql[d] binary?
 
USE_MYSQL will check to see if MySQL is installed. If not, the port pulls in MySQL as a dependency. By default, it currently uses MySQL 5.6 as the default version to install/use.
 
USE_MYSQL will check to see if MySQL is installed. If not, the port pulls in MySQL as a dependency. By default, it currently uses MySQL 5.6 as the default version to install/use.
What happens if MariaDB is installed for example. (I know on some systems you cannot install both, but somehow the tools cannot specify that either or is sufficient).
 
If MariaDB is installed (and at the appropriate version number) then the ports system will accept MariaDB in place of MySQL. So long as the /usr/local/bin/mysql binary is in place, the port considers the dependency met.
 
Hi everybody,

I have tried to fix the tput issue by using color codes instead:
Code:
# If having a tty (console) use colors
if [ -t 1 ]; then
    CLR_FATAL="\033[0;31m"        # Red
    CLR_ERROR="\033[0;31m"        # Red
    CLR_WARNING="\033[0;33m"    # Yellow
    CLR_INFO=""
    CLR_OK="\033[0;32m"            # Green
    CLR_DEBUG="\033[0;37m"        # Gray
    CLR_TRACE="\033[0;37m"        # Gray
    CLR_RESET="\033[m"            # Normal
# Dump terminal (e.g.: via cron)
else
    CLR_FATAL=""
    CLR_ERROR=""
    CLR_WARNING=""
    CLR_INFO=""
    CLR_OK=""
    CLR_DEBUG=""
    CLR_TRACE=""
    CLR_RESET=""
fi

But now the output shows the color codes instead of the color itself:

Code:
\033[0;37m[TRACE] (RUN): MySQL connection test successful.
\033[0;37m[DEBUG] (SRV): MySQL server connection: Localhost via UNIX socket
\033[0;37m[DEBUG] (SRV): MySQL server connection: Not using SSL (plain).
\033[0;37m[DEBUG] (SRV): MySQL server rep type:   master
\033[0;37m[DEBUG] (SRV): MySQL server version:    5.6.22 Source distribution
\033[0;37m[DEBUG] (SRV): MySQL server hostname:   devel-jail.local.lan:3306

The color codes work under Linux (tested CentOS and Debian) as well as under OSX and even on Travis-CI (except for gray). Anything I am missing here?

The part of the code ( /bin/sh) looks like this:

Code:
        IFS='
        '
        for _line in ${_string}; do
            printf "%s%s${_suffix}\n" "${_prefix}" "${_line}" # stdout
        done
        unset IFS

${_prefix} contains the color code and the verbosity info e.g.: \033[0;37m[DEBUG].

${_suffix} contains the resetting color code and ${_line} is the actual message.
 
OK, got it working.

Somehow on FreeBSD the color codes for printf must be within the first argument.
So it works like this.
Code:
printf "${_prefix}%s${_suffix}\n" "${_line}" # stdout


Anyway, I have another question regarding the default log directory:

As I figured out already, ports always install to /usr/local and have their configuration in /usr/local/etc instead of /etc as Linux does.
Is this also true for logfiles?
Do they go to /usr/local/var/log or do they go to /var/log?
 
Back
Top