Skip to content

Commit

Permalink
On Linux when creating mysql.cfg file set file permissions, so mysql …
Browse files Browse the repository at this point in the history
…would not complain

On all platforms if mycql.cfg file existed - do not remove it allowing for customization
  • Loading branch information
rupor-github committed Jul 2, 2017
1 parent a456755 commit dfbbbc6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
7 changes: 6 additions & 1 deletion build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ YELLOW=''
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
ARCH_INSTALLS="${ARCH_INSTALLS:-win32 win64 linux}"

if not command -v cmake >/dev/null 2>&1; then
print_error "No cmake found - please, install"
exit 1
fi

for _mingw in ${ARCH_INSTALLS}; do

case ${_mingw} in
Expand Down Expand Up @@ -83,7 +88,7 @@ for _mingw in ${ARCH_INSTALLS}; do

(
if [ -z ${_msystem} ]; then
[ -f lib2inpx-${_arch}.xz ] && rm lib2inpx-${_arch}.xz
[ -f lib2inpx-${_arch}-glibc_${_glibc}.tar.xz ] && rm lib2inpx-${_arch}-glibc_${_glibc}.tar.xz

tar --directory ${_dist} --create --xz --file lib2inpx-${_arch}-glibc_${_glibc}.tar.xz .
else
Expand Down
12 changes: 11 additions & 1 deletion get-maria.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ver_major=10.1
ver_minor=24

declare -A checkmap

from_url="https://downloads.mariadb.org/interstitial"

ARCH_INSTALLS="${ARCH_INSTALLS:-win32 win64 linux}"
Expand All @@ -14,18 +16,21 @@ for _mingw in ${ARCH_INSTALLS}; do
file=mariadb-${ver_major}.${ver_minor}-${arch}.zip
prefix=i686
packagedir=${arch}-packages
checkmap[${arch}]="3f28aaece4cb00d57fb643873ca4a4b29546cf5852d956094517b36ba8eafba3"
;;
win64)
arch=winx64
file=mariadb-${ver_major}.${ver_minor}-${arch}.zip
prefix=x86_64
packagedir=${arch}-packages
checkmap[${arch}]="cca8b38e640508cd8fa3ba28c872ccc79497d6a74164a1ae9cdd04aaef9ef6cd"
;;
linux)
arch=$(uname -m)
file=mariadb-${ver_major}.${ver_minor}-linux-glibc_214-${arch}.tar.gz
prefix=
packagedir=bintar-linux-glibc_214-${arch}
checkmap[${arch}]="04491b686a83ba994122f5609adb9f86cb5af6275f87bfa4ee6010e2e28db465"
;;
*)
echo "Unsupported environment!"
Expand All @@ -39,6 +44,11 @@ for _mingw in ${ARCH_INSTALLS}; do
else
echo "Have ${file} locally."
fi
sum=`sha256sum ${file} | awk '{ print $1; }'`
if [ ${checkmap[${arch}]} != ${sum} ]; then
echo "Bad checksum for ${file}: ${checkmap[${arch}]} != ${sum}"
exit 1
fi

if [ x"${_mingw}" == x"linux" ]; then
[ -d mariadb-${ver_major}.${ver_minor}-linux-glibc_214-${arch} ] && rm -rf mariadb-${ver_major}.${ver_minor}-linux-glibc_214-${arch}
Expand All @@ -53,7 +63,7 @@ for _mingw in ${ARCH_INSTALLS}; do
cd mariadb-${ver_major}.${ver_minor}-${arch}
cd lib
for dll in *.dll; do
echo "Creating MINGW import library for ${dll}"
echo "Creating Windows export library for ${dll}"
gendef -a ${dll}
dlltool -d ${dll%.*}.def -l ${dll}.a -k
rm ${dll%.*}.def
Expand Down
22 changes: 17 additions & 5 deletions lib2inpx/lib2inpx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <direct.h>
#else
#include <sys/io.h>
#include <sys/stat.h>
#endif
#include <stdio.h>
#include <fcntl.h>
Expand Down Expand Up @@ -69,6 +70,8 @@ static bool g_ignore_dump_date = false;
static bool g_clean_when_done = false;
static bool g_verbose = false;

static bool g_mysql_cfg_created = false;

enum checking_type { eFileExt = 0, eFileType, eIgnore };
static checking_type g_strict = eFileExt;

Expand Down Expand Up @@ -131,10 +134,10 @@ static const char* dummy = "dummy:"
"\r\n";

#ifdef MARIADB_BASE_VERSION
static const char* options_pattern[] = {"%s", "--defaults-file=%sdata/mysql.ini", "--language=%s/language", "--datadir=%sdata", "--skip-grant-tables", "--innodb_data_home_dir=%sdata/dbtmp_%s",
static const char* options_pattern[] = {"%s", "--defaults-file=%sdata/mysql.cfg", "--language=%s/language", "--datadir=%sdata", "--skip-grant-tables", "--innodb_data_home_dir=%sdata/dbtmp_%s",
"--innodb_log_group_home_dir=%sdata/dbtmp_%s", "--innodb_tmpdir=%sdata/dbtmp_%s", "--log_warnings=2", NULL};
#else
static const char* options_pattern[] = {"%s", "--defaults-file=%sdata/mysql.ini", "--language=%s/language", "--datadir=%sdata", "--skip-grant-tables", "--innodb_data_home_dir=%s/data/dbtmp_%s",
static const char* options_pattern[] = {"%s", "--defaults-file=%sdata/mysql.cfg", "--language=%s/language", "--datadir=%sdata", "--skip-grant-tables", "--innodb_data_home_dir=%s/data/dbtmp_%s",
"--innodb_log_group_home_dir=%sdata/dbtmp_%s", "--innodb_tmpdir=%sdata/dbtmp_%s", "--log_syslog=0", NULL};
#endif

Expand Down Expand Up @@ -305,7 +308,7 @@ void prepare_mysql(const char* path, const string& dbname)
fs::create_directories(config.c_str());
}

config = string(path) + "/data/mysql.ini";
config = string(path) + "/data/mysql.cfg";
if (0 != access(config.c_str(), 6)) {
ofstream out(config.c_str());

Expand All @@ -316,7 +319,14 @@ void prepare_mysql(const char* path, const string& dbname)
} else {
throw runtime_error(tmp_str("Unable to open file \"%s\"", config.c_str()));
}
g_mysql_cfg_created = true;
}

#ifndef _WIN32
if (g_mysql_cfg_created) {
chmod(config.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
}
#endif

config = string(path) + "/data/dbtmp_" + dbname;
if (0 != access(config.c_str(), 6)) {
Expand Down Expand Up @@ -1699,8 +1709,10 @@ int main(int argc, char* argv[])
string file_to_del = data_dir + "/auto.cnf";
fs::remove(file_to_del);

file_to_del.assign(data_dir + "/mysql.ini");
fs::remove(file_to_del);
if (g_mysql_cfg_created) {
file_to_del.assign(data_dir + "/mysql.cfg");
fs::remove(file_to_del);
}

#ifdef MARIADB_BASE_VERSION
file_to_del.assign(data_dir + "/aria_log.00000001");
Expand Down

0 comments on commit dfbbbc6

Please sign in to comment.