[FR] Make the patches folder/files work like the configuration folders/files

interfasys

Verified User
Joined
Oct 31, 2003
Messages
1,824
Location
Switzerland
It's great to be able to customise configuration files with the custom folder, but the same concept could be applied to patches.
CB should use any patches it finds in our custom folders

It could look like this, which is the way DA does thing:
Code:
patches
patches/apache2
patches/apache2/fixthis.patch
patches/custom
patches/custom/apache2
patches/custom/apache2/myfixthis.patch
patches/custom/apache2/myoptim.patch
or it could use another folder called custompatches.
 
That sounds good, but do you know that there is already a way to apply your custom patches every time with a new build?
 
That sounds good, but do you know that there is already a way to apply your custom patches every time with a new build?
I've just checked doApache2() and all I see are hard-coded patches

Code:
echo "Extracting ${FILE}...";
	tar xzf ${FILE} --no-same-owner
	
	if [ "${APACHE_OPT}" = "2.4" ]; then
		FILE2=${CWD}/apr-${APR_VER}.tar.gz
		checkFile ${FILE2};
		echo "Extracting ${FILE2}...";
		tar xzf ${FILE2} --no-same-owner -C ${CWD}/httpd-${APACHE2_VER}/srclib
		if [ -d ${CWD}/httpd-${APACHE2_VER}/srclib/apr ]; then
			rm -rf ${CWD}/httpd-${APACHE2_VER}/srclib/apr
		fi
		mv -f ${CWD}/httpd-${APACHE2_VER}/srclib/apr-${APR_VER} ${CWD}/httpd-${APACHE2_VER}/srclib/apr
		
		FILE3=${CWD}/apr-util-${APR_UTIL_VER}.tar.gz
		checkFile ${FILE3};
		echo "Extracting ${FILE3}...";
		tar xzf ${FILE3} --no-same-owner -C ${CWD}/httpd-${APACHE2_VER}/srclib
		if [ -d ${CWD}/httpd-${APACHE2_VER}/srclib/apr-util ]; then
			rm -rf ${CWD}/httpd-${APACHE2_VER}/srclib/apr-util
		fi
		mv -f ${CWD}/httpd-${APACHE2_VER}/srclib/apr-util-${APR_UTIL_VER} ${CWD}/httpd-${APACHE2_VER}/srclib/apr-util
	fi

	if [ "$HARDEN_SYMLINK_PATCH" = "yes" ]; then
		if [ "${APACHE_OPT}" = "2.4" ]; then
			PATCH_NAME=harden-symlinks-2.4.patch
			getFile ${PATCH_NAME} ${PATCH_NAME}
		else
			PATCH_NAME=harden-symlinks.patch.${APACHE2_VER}
			getFile ${PATCH_NAME} harden-symlinks-patch
		fi
		
[COLOR="#FF0000"]		if [ -s ${PATCH_NAME} ]; then
			echo "Patching apache for hardened symlinks patch...";
			if [ "${APACHE_OPT}" = "2.4" ]; then
				cd httpd-${APACHE2_VER}
				patch -p0 < ../${PATCH_NAME}
				cd ..
			else	
				patch -p0 < ${PATCH_NAME}
			fi
		else
			echo "Cannot find ${PATCH_NAME} to for hardened symlinks patch.";
		fi[/COLOR]
	fi

	cd httpd-${APACHE2_VER}
	
[COLOR="#FF0000"]	echo "Patching apache to support sockets in fcgid proxy...";
	if [ ! -s ../patches/apache_proxy_socket.patch ]; then
		echo "Error with patches/apache_proxy_socket.patch. File is missing or empty";
	else
		patch -p1 < ../patches/apache_proxy_socket.patch
	fi

	echo "Patching apache to fix / decoding...";
	if [ ! -s ../patches/apache_proxy_socket.patch ]; then
		echo "Error with patches/apache_proxy_socket_slash_encoding.patch. File is missing or empty";
	else
		patch -p1 < ../patches/apache_proxy_socket_slash_encoding.patch
	fi

	if [ "${CLINUX_OPT}" = "no" ]; then
		echo "Patching apache to suexec safedir path...";
		if [ ! -s ../patches/suexec-safe.patch ]; then
			echo "Error with patches/suexec-safe.patch. File is missing or empty";
		else
			patch -p1 < ../patches/suexec-safe.patch
		fi
	fi
	
	if [ "${CLINUX_OPT}" = "yes" ]; then
		patch -p1 < ../apr-2.4-httpd.1.patch
		patch -p1 < ../suexec_safe_bin.patch
	fi[/COLOR]
	setFDSETSIZE

	#configure
 
Yes, but you can apply your own ones (additional) with no problems automatically :)
 
Is there some documentation somewhere? I usually just add my patches to the code, but was hoping for an easier way.
 
Is there some documentation somewhere? I usually just add my patches to the code, but was hoping for an easier way.
I have not documented that anywhere, but there were a few posts of mine about that. For example, if you'd like to patch apache with your own patch:
Code:
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp -p configure/ap2/configure.apache custom/ap2/configure.apache
Now edit custom/ap2/configure.apache and add the following before "./configure":
Code:
patch -p1 < /path/to/your/patch_file.patch
That's it :) Every time you build apache, your own patch will get applied.
 
I have not documented that anywhere, but there were a few posts of mine about that. For example, if you'd like to patch apache with your own patch:
Code:
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp -p configure/ap2/configure.apache custom/ap2/configure.apache
Now edit custom/ap2/configure.apache and add the following before "./configure":
Code:
patch -p1 < /path/to/your/patch_file.patch
That's it :) Every time you build apache, your own patch will get applied.
Ah, of course... I had forgotten that the configuration was, in fact, a script. That's a clever way to do it :).
I still think a for-each-patch loop in a function could make things easier, but I reckon that custom patches is probably something that less than 1% of the CB users are implementing...
 
I have not documented that anywhere, but there were a few posts of mine about that. For example, if you'd like to patch apache with your own patch:
Code:
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp -p configure/ap2/configure.apache custom/ap2/configure.apache
Now edit custom/ap2/configure.apache and add the following before "./configure":
Code:
patch -p1 < /path/to/your/patch_file.patch
That's it :) Every time you build apache, your own patch will get applied.

maybe I am misunderstanding the process (very high chance of it) but would this allow me to not have to manually recompile stuff like mod_flvx (since there were changes to allow working on apache 2.4.x) when an apache update or install is done?
while its only a moment to do and I only have to deal with that one item if I am understanding it right I could see this being huge timesaver for larger operators.
 
maybe I am misunderstanding the process (very high chance of it) but would this allow me to not have to manually recompile stuff like mod_flvx (since there were changes to allow working on apache 2.4.x) when an apache update or install is done?
while its only a moment to do and I only have to deal with that one item if I am understanding it right I could see this being huge timesaver for larger operators.
AFAIK, modules have to be compiled afterwards. You'de be better off wrapping CB into your own script

Code:
Optimized CFLAGS

./build apache

mod_something_sub{

}

exit;
You could even call scripts to recompile all PHP and all Apache modules extensions instead of defining everything in that file.
 
Back
Top