Przeglądaj źródła

Use Mock chroot for RHEL build system (#3579)

* Add missing wget

* Use Mock chroot for RHEL build system

---------

Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
istiak101 2 lat temu
rodzic
commit
6989e217e9

+ 1 - 1
src/deb/nginx/control

@@ -1,7 +1,7 @@
 Source: hestia-nginx
 Package: hestia-nginx
 Priority: optional
-Version: 1.23.4
+Version: 1.24.0
 Section: admin
 Maintainer: HestiaCP <info@hestiacp.com>
 Homepage: https://www.hestiacp.com

+ 1 - 1
src/deb/php/control

@@ -1,7 +1,7 @@
 Source: hestia-php
 Package: hestia-php
 Priority: optional
-Version: 8.2.5
+Version: 8.2.6
 Section: admin
 Maintainer: HestaCP <info@hestiacp.com>
 Homepage: https://www.hestiacp.com

+ 218 - 215
src/hst_autocompile.sh

@@ -246,7 +246,7 @@ if [ "$dontinstalldeps" != 'true' ]; then
 	# Install needed software
 	if [ "$OSTYPE" = 'rhel' ]; then
 		# Set package dependencies for compiling
-		SOFTWARE='gcc gcc-c++ make libxml2-devel zlib-devel libzip-devel gmp-devel libcurl-devel gnutls-devel unzip openssl openssl-devel pkg-config sqlite-devel oniguruma-devel rpm-build wget tar git curl perl-IPC-Cmd perl-File-Copy-Recursive perl-FindBin perl-File-Compare'
+		SOFTWARE='wget tar git curl mock rpm-build rpmdevtools'
 
 		echo "Updating system DNF repositories..."
 		dnf install -y -q 'dnf-command(config-manager)'
@@ -257,9 +257,13 @@ if [ "$dontinstalldeps" != 'true' ]; then
 		dnf upgrade -y -q
 		echo "Installing dependencies for compilation..."
 		dnf install -y -q $SOFTWARE
+		rpmdev-setuptree
+		if [ ! -d "/var/lib/mock/rocky+epel-9-$(arch)-bootstrap" ]; then
+			mock -r rocky+epel-9-$(arch) --init
+		fi
 	else
 		# Set package dependencies for compiling
-		SOFTWARE='build-essential libxml2-dev libz-dev libzip-dev libgmp-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config libsqlite3-dev libonig-dev rpm lsb-release'
+		SOFTWARE='wget tar git curl build-essential libxml2-dev libz-dev libzip-dev libgmp-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config libsqlite3-dev libonig-dev rpm lsb-release'
 
 		echo "Updating system APT repositories..."
 		apt-get -qq update > /dev/null 2>&1
@@ -329,86 +333,86 @@ if [ "$NGINX_B" = true ]; then
 		echo "Cross compile not supported for hestia-nginx or hestia-php"
 		exit 1
 	fi
-	# Change to build directory
-	cd $BUILD_DIR
 
-	BUILD_DIR_HESTIANGINX=$BUILD_DIR/hestia-nginx_$NGINX_V
-	if [[ $NGINX_V =~ - ]]; then
-		BUILD_DIR_NGINX=$BUILD_DIR/nginx-$(echo $NGINX_V | cut -d"-" -f1)
-	else
-		BUILD_DIR_NGINX=$BUILD_DIR/nginx-$(echo $NGINX_V | cut -d"~" -f1)
-	fi
+	if [ "$BUILD_DEB" = true ]; then
+		# Change to build directory
+		cd $BUILD_DIR
 
-	if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIANGINX" ]; then
-		# Check if target directory exist
-		if [ -d "$BUILD_DIR_HESTIANGINX" ]; then
-			#mv $BUILD_DIR/hestia-nginx_$NGINX_V $BUILD_DIR/hestia-nginx_$NGINX_V-$(timestamp)
-			rm -r "$BUILD_DIR_HESTIANGINX"
+		BUILD_DIR_HESTIANGINX=$BUILD_DIR/hestia-nginx_$NGINX_V
+		if [[ $NGINX_V =~ - ]]; then
+			BUILD_DIR_NGINX=$BUILD_DIR/nginx-$(echo $NGINX_V | cut -d"-" -f1)
+		else
+			BUILD_DIR_NGINX=$BUILD_DIR/nginx-$(echo $NGINX_V | cut -d"~" -f1)
 		fi
 
-		# Create directory
-		mkdir -p $BUILD_DIR_HESTIANGINX
+		if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIANGINX" ]; then
+			# Check if target directory exist
+			if [ -d "$BUILD_DIR_HESTIANGINX" ]; then
+				#mv $BUILD_DIR/hestia-nginx_$NGINX_V $BUILD_DIR/hestia-nginx_$NGINX_V-$(timestamp)
+				rm -r "$BUILD_DIR_HESTIANGINX"
+			fi
 
-		# Download and unpack source files
-		download_file $NGINX '-' | tar xz
-		download_file $OPENSSL '-' | tar xz
-		download_file $PCRE '-' | tar xz
-		download_file $ZLIB '-' | tar xz
+			# Create directory
+			mkdir -p $BUILD_DIR_HESTIANGINX
+
+			# Download and unpack source files
+			download_file $NGINX '-' | tar xz
+			download_file $OPENSSL '-' | tar xz
+			download_file $PCRE '-' | tar xz
+			download_file $ZLIB '-' | tar xz
+
+			# Change to nginx directory
+			cd $BUILD_DIR_NGINX
+
+			# configure nginx
+			./configure --prefix=/usr/local/hestia/nginx \
+				--with-http_ssl_module \
+				--with-openssl=../openssl-$OPENSSL_V \
+				--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
+				--with-openssl-opt=no-nextprotoneg \
+				--with-openssl-opt=no-weak-ssl-ciphers \
+				--with-openssl-opt=no-ssl3 \
+				--with-pcre=../pcre2-$PCRE_V \
+				--with-pcre-jit \
+				--with-zlib=../zlib-$ZLIB_V
+		fi
 
 		# Change to nginx directory
 		cd $BUILD_DIR_NGINX
 
-		# configure nginx
-		./configure --prefix=/usr/local/hestia/nginx \
-			--with-http_ssl_module \
-			--with-openssl=../openssl-$OPENSSL_V \
-			--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
-			--with-openssl-opt=no-nextprotoneg \
-			--with-openssl-opt=no-weak-ssl-ciphers \
-			--with-openssl-opt=no-ssl3 \
-			--with-pcre=../pcre2-$PCRE_V \
-			--with-pcre-jit \
-			--with-zlib=../zlib-$ZLIB_V
-	fi
-
-	# Change to nginx directory
-	cd $BUILD_DIR_NGINX
-
-	# Check install directory and remove if exists
-	if [ -d "$BUILD_DIR$INSTALL_DIR" ]; then
-		rm -r "$BUILD_DIR$INSTALL_DIR"
-	fi
-
-	# Copy local hestia source files
-	if [ "$use_src_folder" == 'true' ] && [ -d $SRC_DIR ]; then
-		cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
-	fi
+		# Check install directory and remove if exists
+		if [ -d "$BUILD_DIR$INSTALL_DIR" ]; then
+			rm -r "$BUILD_DIR$INSTALL_DIR"
+		fi
 
-	# Create the files and install them
-	make -j $NUM_CPUS && make DESTDIR=$BUILD_DIR install
+		# Copy local hestia source files
+		if [ "$use_src_folder" == 'true' ] && [ -d $SRC_DIR ]; then
+			cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
+		fi
 
-	# Clear up unused files
-	if [ "$KEEPBUILD" != 'true' ]; then
-		rm -r $BUILD_DIR_NGINX $BUILD_DIR/openssl-$OPENSSL_V $BUILD_DIR/pcre2-$PCRE_V $BUILD_DIR/zlib-$ZLIB_V
-	fi
-	cd $BUILD_DIR_HESTIANGINX
+		# Create the files and install them
+		make -j $NUM_CPUS && make DESTDIR=$BUILD_DIR install
 
-	# Move nginx directory
-	mkdir -p $BUILD_DIR_HESTIANGINX/usr/local/hestia
-	rm -rf $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx
-	mv $BUILD_DIR/usr/local/hestia/nginx $BUILD_DIR_HESTIANGINX/usr/local/hestia/
+		# Clear up unused files
+		if [ "$KEEPBUILD" != 'true' ]; then
+			rm -r $BUILD_DIR_NGINX $BUILD_DIR/openssl-$OPENSSL_V $BUILD_DIR/pcre2-$PCRE_V $BUILD_DIR/zlib-$ZLIB_V
+		fi
+		cd $BUILD_DIR_HESTIANGINX
 
-	# Remove original nginx.conf (will use custom)
-	rm -f $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx/conf/nginx.conf
+		# Move nginx directory
+		mkdir -p $BUILD_DIR_HESTIANGINX/usr/local/hestia
+		rm -rf $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx
+		mv $BUILD_DIR/usr/local/hestia/nginx $BUILD_DIR_HESTIANGINX/usr/local/hestia/
 
-	# copy binary
-	cp $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx/sbin/nginx $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx/sbin/hestia-nginx
+		# Remove original nginx.conf (will use custom)
+		rm -f $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx/conf/nginx.conf
 
-	# change permission and build the package
-	cd $BUILD_DIR
-	chown -R root:root $BUILD_DIR_HESTIANGINX
+		# copy binary
+		mv $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx/sbin/nginx $BUILD_DIR_HESTIANGINX/usr/local/hestia/nginx/sbin/hestia-nginx
 
-	if [ "$BUILD_DEB" = true ]; then
+		# change permission and build the package
+		cd $BUILD_DIR
+		chown -R root:root $BUILD_DIR_HESTIANGINX
 		# Get Debian package files
 		mkdir -p $BUILD_DIR_HESTIANGINX/DEBIAN
 		get_branch_file 'src/deb/nginx/control' "$BUILD_DIR_HESTIANGINX/DEBIAN/control"
@@ -432,35 +436,34 @@ if [ "$NGINX_B" = true ]; then
 		# Build the package
 		echo Building Nginx DEB
 		dpkg-deb -Zxz --build $BUILD_DIR_HESTIANGINX $DEB_DIR
+
+		rm -r $BUILD_DIR/usr
+
+		if [ "$KEEPBUILD" != 'true' ]; then
+			# Clean up the source folder
+			rm -r hestia- nginx_$NGINX_V
+			rm -rf $BUILD_DIR/rpmbuild
+			if [ "$use_src_folder" == 'true' ] && [ -d $BUILD_DIR/hestiacp-$branch_dash ]; then
+				rm -r $BUILD_DIR/hestiacp-$branch_dash
+			fi
+		fi
 	fi
 
 	if [ "$BUILD_RPM" = true ]; then
 		# Get RHEL package files
-		get_branch_file 'src/rpm/nginx/hestia-nginx.spec' "${BUILD_DIR_HESTIANGINX}/hestia-nginx.spec"
-		sed -i "s/%HESTIA-NGINX-VERSION%/${NGINX_V}/g" "${BUILD_DIR_HESTIANGINX}/hestia-nginx.spec"
-		get_branch_file 'src/rpm/nginx/hestia-nginx.service' "${BUILD_DIR_HESTIANGINX}/hestia-nginx.service"
+		get_branch_file 'src/rpm/nginx/nginx.conf' "$HOME/rpmbuild/SOURCES/nginx.conf"
+		get_branch_file 'src/rpm/nginx/hestia-nginx.spec' "$HOME/rpmbuild/SPECS/hestia-nginx.spec"
+		get_branch_file 'src/rpm/nginx/hestia-nginx.service' "$HOME/rpmbuild/SOURCES/hestia-nginx.service"
 
-		# Custom config
-		get_branch_file 'src/rpm/nginx/nginx.conf' "${BUILD_DIR_HESTIANGINX}/usr/local/hestia/nginx/conf/nginx.conf"
+		# Download source files
+		download_file $NGINX "$HOME/rpmbuild/SOURCES/"
 
 		# Build the package
-		mkdir -p $BUILD_DIR/rpmbuild
 		echo Building Nginx RPM
-		rpmbuild -bb --define "sourcedir $BUILD_DIR_HESTIANGINX" --buildroot=$BUILD_DIR/rpmbuild/ ${BUILD_DIR_HESTIANGINX}/hestia-nginx.spec > ${BUILD_DIR_HESTIANGINX}.rpm.log
-		cp ~/rpmbuild/RPMS/$(arch)/hestia-nginx-*.rpm $RPM_DIR
-		rm ~/rpmbuild/RPMS/$(arch)/hestia-nginx-*.rpm
-		rm -rf $BUILD_DIR/rpmbuild
-	fi
-
-	rm -r $BUILD_DIR/usr
-
-	if [ "$KEEPBUILD" != 'true' ]; then
-		# Clean up the source folder
-		rm -r hestia-nginx_$NGINX_V
-		rm -rf $BUILD_DIR/rpmbuild
-		if [ "$use_src_folder" == 'true' ] && [ -d $BUILD_DIR/hestiacp-$branch_dash ]; then
-			rm -r $BUILD_DIR/hestiacp-$branch_dash
-		fi
+		rpmbuild -bs ~/rpmbuild/SPECS/hestia-nginx.spec
+		mock -r rocky+epel-9-$(arch) ~/rpmbuild/SRPMS/hestia-nginx-$NGINX_V-1.el9.src.rpm
+		cp /var/lib/mock/rocky+epel-9-$(arch)/result/*.rpm $RPM_DIR
+		rm -rf ~/rpmbuild/SPECS/* ~/rpmbuild/SOURCES/* ~/rpmbuild/SRPMS/*
 	fi
 fi
 
@@ -478,77 +481,74 @@ if [ "$PHP_B" = true ]; then
 
 	echo "Building hestia-php package..."
 
-	BUILD_DIR_HESTIAPHP=$BUILD_DIR/hestia-php_$PHP_V
-
-	BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V | cut -d"~" -f1)
+	if [ "$BUILD_DEB" = true ]; then
+		BUILD_DIR_HESTIAPHP=$BUILD_DIR/hestia-php_$PHP_V
 
-	if [[ $PHP_V =~ - ]]; then
-		BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V | cut -d"-" -f1)
-	else
 		BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V | cut -d"~" -f1)
-	fi
 
-	if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIAPHP" ]; then
-		# Check if target directory exist
-		if [ -d $BUILD_DIR_HESTIAPHP ]; then
-			rm -r $BUILD_DIR_HESTIAPHP
+		if [[ $PHP_V =~ - ]]; then
+			BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V | cut -d"-" -f1)
+		else
+			BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V | cut -d"~" -f1)
 		fi
 
-		# Create directory
-		mkdir -p $BUILD_DIR_HESTIAPHP
+		if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIAPHP" ]; then
+			# Check if target directory exist
+			if [ -d $BUILD_DIR_HESTIAPHP ]; then
+				rm -r $BUILD_DIR_HESTIAPHP
+			fi
 
-		# Download and unpack source files
-		cd $BUILD_DIR
-		download_file $PHP '-' | tar xz
+			# Create directory
+			mkdir -p $BUILD_DIR_HESTIAPHP
+
+			# Download and unpack source files
+			cd $BUILD_DIR
+			download_file $PHP '-' | tar xz
+
+			# Change to untarred php directory
+			cd $BUILD_DIR_PHP
+
+			# Configure PHP
+			./configure --prefix=/usr/local/hestia/php \
+				--with-libdir=lib/$(arch)-linux-gnu \
+				--enable-fpm --with-fpm-user=admin --with-fpm-group=admin \
+				--with-openssl \
+				--with-mysqli \
+				--with-gettext \
+				--with-curl \
+				--with-zip \
+				--with-gmp \
+				--enable-mbstring
+		fi
 
-		# Change to untarred php directory
 		cd $BUILD_DIR_PHP
 
-		# Configure PHP
-		./configure --prefix=/usr/local/hestia/php \
-			--enable-fpm \
-			--with-fpm-user=admin \
-			--with-fpm-group=admin \
-			--with-libdir=lib/$(arch)-linux-gnu \
-			--with-openssl \
-			--with-mysqli \
-			--with-gettext \
-			--with-curl \
-			--with-zip \
-			--with-gmp \
-			--enable-mbstring
-	fi
+		# Create the files and install them
+		make -j $NUM_CPUS && make INSTALL_ROOT=$BUILD_DIR install
 
-	cd $BUILD_DIR_PHP
-
-	# Create the files and install them
-	make -j $NUM_CPUS && make INSTALL_ROOT=$BUILD_DIR install
-
-	# Copy local hestia source files
-	if [ "$use_src_folder" == 'true' ] && [ -d $SRC_DIR ]; then
-		[ "$HESTIA_DEBUG" ] && echo DEBUG: cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
-		cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
-	fi
-	# Move php directory
-	[ "$HESTIA_DEBUG" ] && echo DEBUG: mkdir -p $BUILD_DIR_HESTIAPHP/usr/local/hestia
-	mkdir -p $BUILD_DIR_HESTIAPHP/usr/local/hestia
-
-	[ "$HESTIA_DEBUG" ] && echo DEBUG: rm -r $BUILD_DIR_HESTIAPHP/usr/local/hestia/php
-	if [ -d $BUILD_DIR_HESTIAPHP/usr/local/hestia/php ]; then
-		rm -r $BUILD_DIR_HESTIAPHP/usr/local/hestia/php
-	fi
+		# Copy local hestia source files
+		if [ "$use_src_folder" == 'true' ] && [ -d $SRC_DIR ]; then
+			[ "$HESTIA_DEBUG" ] && echo DEBUG: cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
+			cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
+		fi
+		# Move php directory
+		[ "$HESTIA_DEBUG" ] && echo DEBUG: mkdir -p $BUILD_DIR_HESTIAPHP/usr/local/hestia
+		mkdir -p $BUILD_DIR_HESTIAPHP/usr/local/hestia
 
-	[ "$HESTIA_DEBUG" ] && echo DEBUG: mv ${BUILD_DIR}/usr/local/hestia/php ${BUILD_DIR_HESTIAPHP}/usr/local/hestia/
-	mv ${BUILD_DIR}/usr/local/hestia/php ${BUILD_DIR_HESTIAPHP}/usr/local/hestia/
+		[ "$HESTIA_DEBUG" ] && echo DEBUG: rm -r $BUILD_DIR_HESTIAPHP/usr/local/hestia/php
+		if [ -d $BUILD_DIR_HESTIAPHP/usr/local/hestia/php ]; then
+			rm -r $BUILD_DIR_HESTIAPHP/usr/local/hestia/php
+		fi
 
-	# copy binary
-	[ "$HESTIA_DEBUG" ] && echo DEBUG: cp $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/php-fpm $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/hestia-php
-	cp $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/php-fpm $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/hestia-php
+		[ "$HESTIA_DEBUG" ] && echo DEBUG: mv ${BUILD_DIR}/usr/local/hestia/php ${BUILD_DIR_HESTIAPHP}/usr/local/hestia/
+		mv ${BUILD_DIR}/usr/local/hestia/php ${BUILD_DIR_HESTIAPHP}/usr/local/hestia/
 
-	# Change permissions and build the package
-	chown -R root:root $BUILD_DIR_HESTIAPHP
+		# copy binary
+		[ "$HESTIA_DEBUG" ] && echo DEBUG: cp $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/php-fpm $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/hestia-php
+		cp $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/php-fpm $BUILD_DIR_HESTIAPHP/usr/local/hestia/php/sbin/hestia-php
 
-	if [ "$BUILD_DEB" = true ]; then
+		# Change permissions and build the package
+		chown -R root:root $BUILD_DIR_HESTIAPHP
 		# Get Debian package files
 		[ "$HESTIA_DEBUG" ] && echo DEBUG: mkdir -p $BUILD_DIR_HESTIAPHP/DEBIAN
 		mkdir -p $BUILD_DIR_HESTIAPHP/DEBIAN
@@ -575,36 +575,35 @@ if [ "$PHP_B" = true ]; then
 		echo Building PHP DEB
 		[ "$HESTIA_DEBUG" ] && echo DEBUG: dpkg-deb -Zxz --build $BUILD_DIR_HESTIAPHP $DEB_DIR
 		dpkg-deb -Zxz --build $BUILD_DIR_HESTIAPHP $DEB_DIR
+
+		rm -r $BUILD_DIR/usr
+
+		# clear up the source folder
+		if [ "$KEEPBUILD" != 'true' ]; then
+			rm -r $BUILD_DIR/php-$(echo $PHP_V | cut -d"~" -f1)
+			rm -r $BUILD_DIR_HESTIAPHP
+			if [ "$use_src_folder" == 'true' ] && [ -d $BUILD_DIR/hestiacp-$branch_dash ]; then
+				rm -r $BUILD_DIR/hestiacp-$branch_dash
+			fi
+		fi
 	fi
 
 	if [ "$BUILD_RPM" = true ]; then
 		# Get RHEL package files
-		get_branch_file 'src/rpm/php/hestia-php.spec' "${BUILD_DIR_HESTIAPHP}/hestia-php.spec"
-		sed -i "s/%HESTIA-PHP-VERSION%/${PHP_V}/g" "${BUILD_DIR_HESTIAPHP}/hestia-php.spec"
-		get_branch_file 'src/rpm/php/hestia-php.service' "${BUILD_DIR_HESTIAPHP}/hestia-php.service"
+		get_branch_file 'src/rpm/php/php-fpm.conf' "$HOME/rpmbuild/SOURCES/php-fpm.conf"
+		get_branch_file 'src/rpm/php/php.ini' "$HOME/rpmbuild/SOURCES/php.ini"
+		get_branch_file 'src/rpm/php/hestia-php.spec' "$HOME/rpmbuild/SPECS/hestia-php.spec"
+		get_branch_file 'src/rpm/php/hestia-php.service' "$HOME/rpmbuild/SOURCES/hestia-php.service"
 
-		# Get custom config
-		get_branch_file 'src/rpm/php/php-fpm.conf' "${BUILD_DIR_HESTIAPHP}/usr/local/hestia/php/etc/php-fpm.conf"
-		get_branch_file 'src/rpm/php/php.ini' "${BUILD_DIR_HESTIAPHP}/usr/local/hestia/php/lib/php.ini"
+		# Download source files
+		download_file $PHP "$HOME/rpmbuild/SOURCES/"
 
 		# Build RPM package
-		mkdir -p $BUILD_DIR/rpmbuild
 		echo Building PHP RPM
-		rpmbuild -bb --define "sourcedir $BUILD_DIR_HESTIAPHP" --buildroot=$BUILD_DIR/rpmbuild/ ${BUILD_DIR_HESTIAPHP}/hestia-php.spec > ${BUILD_DIR_HESTIAPHP}.rpm.log
-		cp ~/rpmbuild/RPMS/$(arch)/hestia-php-*.rpm $RPM_DIR
-		rm ~/rpmbuild/RPMS/$(arch)/hestia-php-*.rpm
-		rm -rf $BUILD_DIR/rpmbuild
-	fi
-
-	rm -r $BUILD_DIR/usr
-
-	# clear up the source folder
-	if [ "$KEEPBUILD" != 'true' ]; then
-		rm -r $BUILD_DIR/php-$(echo $PHP_V | cut -d"~" -f1)
-		rm -r $BUILD_DIR_HESTIAPHP
-		if [ "$use_src_folder" == 'true' ] && [ -d $BUILD_DIR/hestiacp-$branch_dash ]; then
-			rm -r $BUILD_DIR/hestiacp-$branch_dash
-		fi
+		rpmbuild -bs ~/rpmbuild/SPECS/hestia-php.spec
+		mock -r rocky+epel-9-$(arch) ~/rpmbuild/SRPMS/hestia-php-$PHP_V-1.el9.src.rpm
+		cp /var/lib/mock/rocky+epel-9-$(arch)/result/*.rpm $RPM_DIR
+		rm -rf ~/rpmbuild/SPECS/* ~/rpmbuild/SOURCES/* ~/rpmbuild/SRPMS/*
 	fi
 fi
 
@@ -623,49 +622,48 @@ if [ "$HESTIA_B" = true ]; then
 	for BUILD_ARCH in $arch; do
 		echo "Building Hestia Control Panel package..."
 
-		BUILD_DIR_HESTIA=$BUILD_DIR/hestia_$HESTIA_V
-
-		# Change to build directory
-		cd $BUILD_DIR
+		if [ "$BUILD_DEB" = true ]; then
+			BUILD_DIR_HESTIA=$BUILD_DIR/hestia_$HESTIA_V
 
-		if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIA" ]; then
-			# Check if target directory exist
-			if [ -d $BUILD_DIR_HESTIA ]; then
-				rm -r $BUILD_DIR_HESTIA
-			fi
+			# Change to build directory
+			cd $BUILD_DIR
 
-			# Create directory
-			mkdir -p $BUILD_DIR_HESTIA
-		fi
+			if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIA" ]; then
+				# Check if target directory exist
+				if [ -d $BUILD_DIR_HESTIA ]; then
+					rm -r $BUILD_DIR_HESTIA
+				fi
 
-		cd $BUILD_DIR
-		rm -rf $BUILD_DIR/hestiacp-$branch_dash
-		# Download and unpack source files
-		if [ "$use_src_folder" == 'true' ]; then
-			[ "$HESTIA_DEBUG" ] && echo DEBUG: cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
-			cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
-		elif [ -d $SRC_DIR ]; then
-			download_file $HESTIA_ARCHIVE_LINK '-' 'fresh' | tar xz
-		fi
+				# Create directory
+				mkdir -p $BUILD_DIR_HESTIA
+			fi
 
-		mkdir -p $BUILD_DIR_HESTIA/usr/local/hestia
+			cd $BUILD_DIR
+			rm -rf $BUILD_DIR/hestiacp-$branch_dash
+			# Download and unpack source files
+			if [ "$use_src_folder" == 'true' ]; then
+				[ "$HESTIA_DEBUG" ] && echo DEBUG: cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
+				cp -rf "$SRC_DIR/" $BUILD_DIR/hestiacp-$branch_dash
+			elif [ -d $SRC_DIR ]; then
+				download_file $HESTIA_ARCHIVE_LINK '-' 'fresh' | tar xz
+			fi
 
-		# Move needed directories
-		cd $BUILD_DIR/hestiacp-$branch_dash
-		cp -rf bin func install web $BUILD_DIR_HESTIA/usr/local/hestia/
+			mkdir -p $BUILD_DIR_HESTIA/usr/local/hestia
 
-		# Set permissions
-		find $BUILD_DIR_HESTIA/usr/local/hestia/ -type f -exec chmod -x {} \;
+			# Move needed directories
+			cd $BUILD_DIR/hestiacp-$branch_dash
+			cp -rf bin func install web $BUILD_DIR_HESTIA/usr/local/hestia/
 
-		# Allow send email via /usr/local/hestia/web/inc/mail-wrapper.php via cli
-		chmod +x $BUILD_DIR_HESTIA/usr/local/hestia/web/inc/mail-wrapper.php
-		# Allow the executable to be executed
-		chmod +x $BUILD_DIR_HESTIA/usr/local/hestia/bin/*
-		find $BUILD_DIR_HESTIA/usr/local/hestia/install/ \( -name '*.sh' \) -exec chmod +x {} \;
-		chmod -x $BUILD_DIR_HESTIA/usr/local/hestia/install/*.sh
-		chown -R root:root $BUILD_DIR_HESTIA
+			# Set permissions
+			find $BUILD_DIR_HESTIA/usr/local/hestia/ -type f -exec chmod -x {} \;
 
-		if [ "$BUILD_DEB" = true ]; then
+			# Allow send email via /usr/local/hestia/web/inc/mail-wrapper.php via cli
+			chmod +x $BUILD_DIR_HESTIA/usr/local/hestia/web/inc/mail-wrapper.php
+			# Allow the executable to be executed
+			chmod +x $BUILD_DIR_HESTIA/usr/local/hestia/bin/*
+			find $BUILD_DIR_HESTIA/usr/local/hestia/install/ \( -name '*.sh' \) -exec chmod +x {} \;
+			chmod -x $BUILD_DIR_HESTIA/usr/local/hestia/install/*.sh
+			chown -R root:root $BUILD_DIR_HESTIA
 			# Get Debian package files
 			mkdir -p $BUILD_DIR_HESTIA/DEBIAN
 			get_branch_file 'src/deb/hestia/control' "$BUILD_DIR_HESTIA/DEBIAN/control"
@@ -680,29 +678,34 @@ if [ "$HESTIA_B" = true ]; then
 
 			echo Building Hestia DEB
 			dpkg-deb -Zxz --build $BUILD_DIR_HESTIA $DEB_DIR
+
+			# clear up the source folder
+			if [ "$KEEPBUILD" != 'true' ]; then
+				rm -r $BUILD_DIR_HESTIA
+				rm -rf hestiacp-$branch_dash
+			fi
+			cd $BUILD_DIR/hestiacp-$branch_dash
 		fi
 
 		if [ "$BUILD_RPM" = true ]; then
+			# Pre-clean
+			rm -rf ~/rpmbuild/SOURCES/*
+
 			# Get RHEL package files
-			get_branch_file 'src/rpm/hestia/hestia.spec' "${BUILD_DIR_HESTIA}/hestia.spec"
-			sed -i "s/%HESTIA-VERSION%/${HESTIA_V}/g" "${BUILD_DIR_HESTIA}/hestia.spec"
-			get_branch_file 'src/rpm/hestia/hestia.service' "${BUILD_DIR_HESTIA}/hestia.service"
+			get_branch_file 'src/rpm/hestia/hestia.spec' "$HOME/rpmbuild/SPECS/hestia.spec"
+			get_branch_file 'src/rpm/hestia/hestia.service' "$HOME/rpmbuild/SOURCES/hestia.service"
+
+			# Generate source tar.gz
+			tar -czf $HOME/rpmbuild/SOURCES/hestia-$BUILD_VER.tar.gz -C $SRC_DIR/.. hestiacp
 
 			# Build RPM package
-			mkdir -p $BUILD_DIR/rpmbuild
 			echo Building Hestia RPM
-			rpmbuild -bb --define "sourcedir $BUILD_DIR_HESTIA" --buildroot=$BUILD_DIR/rpmbuild/ ${BUILD_DIR_HESTIA}/hestia.spec > ${BUILD_DIR_HESTIA}.rpm.log
-			cp ~/rpmbuild/RPMS/$(arch)/hestia-*.rpm $RPM_DIR
-			rm ~/rpmbuild/RPMS/$(arch)/hestia-*.rpm
-			rm -rf $BUILD_DIR/rpmbuild
+			rpmbuild -bs ~/rpmbuild/SPECS/hestia.spec
+			mock -r rocky+epel-9-$(arch) ~/rpmbuild/SRPMS/hestia-$BUILD_VER-1.el9.src.rpm
+			cp /var/lib/mock/rocky+epel-9-$(arch)/result/*.rpm $RPM_DIR
+			rm -rf ~/rpmbuild/SPECS/* ~/rpmbuild/SOURCES/* ~/rpmbuild/SRPMS/*
 		fi
 
-		# clear up the source folder
-		if [ "$KEEPBUILD" != 'true' ]; then
-			rm -r $BUILD_DIR_HESTIA
-			rm -rf hestiacp-$branch_dash
-		fi
-		cd $BUILD_DIR/hestiacp-$branch_dash
 	done
 fi
 

+ 17 - 16
src/rpm/hestia/hestia.spec

@@ -1,40 +1,38 @@
+%define debug_package %{nil}
 %global _hardened_build 1
 
 Name:           hestia
-Version:        1.8.0
-Release:        1%~alpha{dist}
+Version:        1.8.0~alpha
+Release:        1%{dist}
 Summary:        Hestia Control Panel
 Group:          System Environment/Base
 License:        GPLv3
 URL:            https://www.hestiacp.com
+Source0:        hestia-%{version}.tar.gz
+Source1:        hestia.service
 Vendor:         hestiacp.com
 Requires:       redhat-release >= 8
-Requires:       bash
-Requires:       chkconfig
-Requires:       gawk
-Requires:       sed
-Requires:       acl
-Requires:       sysstat
-Requires:       (setpriv or util-linux)
-Requires:       zstd
-Requires:       jq
+Requires:       bash, chkconfig, gawk, sed, acl, sysstat, (setpriv or util-linux), zstd, jq
 Conflicts:      vesta
 Provides:       hestia = %{version}
-BuildRequires:  systemd-rpm-macros
+BuildRequires:  systemd
 
 %description
 This package contains the Hestia Control Panel.
 
 %prep
+%autosetup -p1 -n hestiacp
 
 %build
 
 %install
-cp -rfa %{sourcedir}/usr %{buildroot}
-mkdir -p %{buildroot}%{_unitdir}
-%{__install} -m644 %{sourcedir}/hestia.service %{buildroot}%{_unitdir}/hestia.service
+%{__rm} -rf $RPM_BUILD_ROOT
+mkdir -p %{buildroot}%{_unitdir} %{buildroot}/usr/local/hestia
+cp -R %{_builddir}/hestiacp/* %{buildroot}/usr/local/hestia/
+%{__install} -m644 %{SOURCE1} %{buildroot}%{_unitdir}/hestia.service
 
 %clean
+%{__rm} -rf $RPM_BUILD_ROOT
 
 %pre
 # Run triggers only on updates
@@ -147,5 +145,8 @@ fi
 %{_unitdir}/hestia.service
 
 %changelog
+* Sun May 14 2023 Istiak Ferdous <hello@istiak.com> - 1.8.0-1
+- HestiaCP RHEL 9 support
+
 * Thu Jun 25 2020 Ernesto Nicolás Carrea <equistango@gmail.com> - 1.2.0
-- HestiaCP CentOS 8 support
+- HestiaCP CentOS 8 support

+ 1 - 1
src/rpm/nginx/hestia-nginx.service

@@ -7,7 +7,7 @@ After=hestia-php.service
 [Service]
 Type=forking
 PIDFile=/run/hestia-nginx.pid
-ExecStart=/usr/local/hestia/nginx/sbin/nginx -c /usr/local/hestia/nginx/conf/nginx.conf
+ExecStart=/usr/local/hestia/nginx/sbin/hestia-nginx -c /usr/local/hestia/nginx/conf/nginx.conf
 ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /run/hestia-nginx.pid)"
 ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /run/hestia-nginx.pid)"
 

+ 27 - 6
src/rpm/nginx/hestia-nginx.spec

@@ -1,31 +1,50 @@
 %global _hardened_build 1
 
+%define WITH_CC_OPT $(echo %{optflags} $(pcre2-config --cflags)) -fPIC
+%define WITH_LD_OPT -Wl,-z,relro -Wl,-z,now -pie
+
+%define BASE_CONFIGURE_ARGS $(echo "--prefix=/usr/local/hestia/nginx --conf-path=/usr/local/hestia/nginx/conf/nginx.conf --error-log-path=%{_localstatedir}/log/hestia/nginx-error.log --http-log-path=%{_localstatedir}/log/hestia/access.log --pid-path=%{_rundir}/hestia-nginx.pid --lock-path=%{_rundir}/hestia-nginx.lock --http-client-body-temp-path=%{_localstatedir}/cache/hestia-nginx/client_temp --http-proxy-temp-path=%{_localstatedir}/cache/hestia-nginx/proxy_temp --http-fastcgi-temp-path=%{_localstatedir}/cache/hestia-nginx/fastcgi_temp --http-scgi-temp-path=%{_localstatedir}/cache/hestia-nginx/scgi_temp --user=admin --group=admin --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module")
+
+
 Name:           hestia-nginx
-Version:        1.23.4
+Version:        1.24.0
 Release:        1%{dist}
 Summary:        Hestia internal nginx web server
 Group:          System Environment/Base
 URL:            https://www.hestiacp.com
+Source0:        https://nginx.org/download/nginx-%{version}.tar.gz
+Source1:        hestia-nginx.service
+Source2:        nginx.conf
 License:        BSD
 Vendor:         hestiacp.com
 Requires:       redhat-release >= 8
 Requires:       hestia-php
 Provides:       hestia-nginx = %{version}
-BuildRequires:  systemd-rpm-macros
+BuildRequires:  gcc, zlib-devel, pcre2-devel, openssl-devel, systemd
 
 %description
 This package contains internal nginx webserver for Hestia Control Panel web interface.
 
 %prep
+%autosetup -p1 -n nginx-%{version}
 
 %build
+./configure %{BASE_CONFIGURE_ARGS} \
+    --with-cc-opt="%{WITH_CC_OPT}" \
+    --with-ld-opt="%{WITH_LD_OPT}"
+%make_build
 
 %install
-cp -rfa %{sourcedir}/usr %{buildroot}
+%{__rm} -rf $RPM_BUILD_ROOT
+%{__make} DESTDIR=$RPM_BUILD_ROOT INSTALLDIRS=vendor install
 mkdir -p %{buildroot}%{_unitdir}
-%{__install} -m644 %{sourcedir}/hestia-nginx.service %{buildroot}%{_unitdir}/hestia-nginx.service
+%{__install} -m644 %{SOURCE1} %{buildroot}%{_unitdir}/hestia-nginx.service
+rm -f %{buildroot}/usr/local/hestia/nginx/conf/nginx.conf
+cp %{SOURCE2} %{buildroot}/usr/local/hestia/nginx/conf/nginx.conf
+mv %{buildroot}/usr/local/hestia/nginx/sbin/nginx %{buildroot}/usr/local/hestia/nginx/sbin/hestia-nginx
 
 %clean
+%{__rm} -rf $RPM_BUILD_ROOT
 
 %pre
 
@@ -46,6 +65,9 @@ mkdir -p %{buildroot}%{_unitdir}
 
 
 %changelog
+* Sun May 14 2023 Istiak Ferdous <hello@istiak.com> - 1.24.0-1
+- 1.24.0-1
+
 * Wed Jun 24 2020 Ernesto Nicolás Carrea <equistango@gmail.com> - 1.17.8
 - HestiaCP CentOS 8 support
 
@@ -56,5 +78,4 @@ mkdir -p %{buildroot}%{_unitdir}
 - new init script
 
 * Wed Jun 27 2012 Serghey Rodin <builder@vestacp.com> - 0.9.7-1
-- initial build
-
+- initial build

+ 52 - 5
src/rpm/php/hestia-php.spec

@@ -1,30 +1,74 @@
 %global _hardened_build 1
+%global _prefix         /usr/local/hestia/php
 
 Name:           hestia-php
-Version:        8.2.5
+Version:        8.2.6
 Release:        1%{dist}
 Summary:        Hestia internal PHP
 Group:          System Environment/Base
 URL:            https://www.hestiacp.com
+Source0:        https://www.php.net/distributions/php-%{version}.tar.gz
+Source1:        hestia-php.service
+Source2:        php-fpm.conf
+Source3:        php.ini
 License:        PHP and Zend and BSD and MIT and ASL 1.0 and NCSA
 Vendor:         hestiacp.com
 Requires:       redhat-release >= 8
 Provides:       hestia-php = %{version}
-BuildRequires:  systemd-rpm-macros
+BuildRequires:  autoconf, automake, bison, bzip2-devel, gcc, gcc-c++, gnupg2, libtool, make, openssl-devel, re2c
+BuildRequires:  gmp-devel, oniguruma-devel, libzip-devel
+BuildRequires:  pkgconfig(libcurl)  >= 7.61.0
+BuildRequires:  pkgconfig(libxml-2.0)  >= 2.9.7
+BuildRequires:  pkgconfig(sqlite3) >= 3.26.0
+BuildRequires:  systemd
 
 %description
 This package contains internal PHP for Hestia Control Panel web interface.
 
 %prep
+%autosetup -p1 -n php-%{version}
+
+# https://bugs.php.net/63362 - Not needed but installed headers.
+# Drop some Windows specific headers to avoid installation,
+# before build to ensure they are really not needed.
+rm -f TSRM/tsrm_win32.h \
+      TSRM/tsrm_config.w32.h \
+      Zend/zend_config.w32.h \
+      ext/mysqlnd/config-win.h \
+      ext/standard/winver.h \
+      main/win32_internal_function_disabled.h \
+      main/win95nt.h
 
 %build
+%if 0%{?rhel} > 8
+# This package fails to build with LTO due to undefined symbols.  LTO
+# was disabled in OpenSuSE as well, but with no real explanation why
+# beyond the undefined symbols.  It really should be investigated further.
+# Disable LTO
+%define _lto_cflags %{nil}
+%endif
+%configure --sysconfdir=%{_prefix}%{_sysconfdir} \
+		--with-libdir=lib/$(arch)-linux-gnu \
+		--enable-fpm --with-fpm-user=admin --with-fpm-group=admin \
+		--with-openssl \
+		--with-mysqli \
+		--with-gettext \
+		--with-curl \
+		--with-zip \
+		--with-gmp \
+		--enable-mbstring
+%make_build
 
 %install
-cp -rfa %{sourcedir}/usr %{buildroot}
-mkdir -p %{buildroot}%{_unitdir}
-%{__install} -m644 %{sourcedir}/hestia-php.service %{buildroot}%{_unitdir}/hestia-php.service
+%{__rm} -rf $RPM_BUILD_ROOT
+mkdir -p %{buildroot}%{_unitdir} %{buildroot}/usr/local/hestia/php/{etc,lib}
+%make_install INSTALL_ROOT=$RPM_BUILD_ROOT/usr/local/hestia/php
+%{__install} -m644 %{SOURCE1} %{buildroot}%{_unitdir}/hestia-php.service
+cp %{SOURCE2} %{buildroot}/usr/local/hestia/php/etc/
+cp %{SOURCE3} %{buildroot}/usr/local/hestia/php/lib/
 
 %clean
+%{__rm} -rf $RPM_BUILD_ROOT
 
 %pre
 
@@ -47,5 +91,8 @@ mkdir -p %{buildroot}%{_unitdir}
 %{_unitdir}/hestia-php.service
 
 %changelog
+* Sun May 14 2023 Istiak Ferdous <hello@istiak.com> - 8.2.6-1
+- HestiaCP RHEL 9 support
+
 * Thu Jun 25 2020 Ernesto Nicolás Carrea <equistango@gmail.com> - 7.4.6
 - HestiaCP CentOS 8 support