diff -Nur nALFS-1.2.6/configure.ac nALFS-1.2.6-autopatch/configure.ac
--- nALFS-1.2.6/configure.ac	2006-01-28 19:20:24.000000000 +0100
+++ nALFS-1.2.6-autopatch/configure.ac	2006-03-27 13:33:24.000000000 +0300
@@ -237,6 +237,7 @@
 AC_DEFINE_UNQUOTED([HANDLER_SYNTAX_3_0], ${syntax_3_0}, [Define to 1 if ALFS 3.0 profile syntax handlers should be built.])
 AC_DEFINE_UNQUOTED([HANDLER_SYNTAX_3_1], ${syntax_3_1}, [Define to 1 if ALFS 3.1 profile syntax handlers should be built.])
 AM_CONDITIONAL([HANDLER_alfs], test $((syntax_2_0 + syntax_3_0 + syntax_3_1 + 0)) -gt 0)
+AM_CONDITIONAL([HANDLER_autopatch], test $((syntax_3_1 + 0)) -gt 0)
 AM_CONDITIONAL([HANDLER_build], test $((syntax_2_0 + 0)) -gt 0)
 AM_CONDITIONAL([HANDLER_check], test $((syntax_3_0 + 0)) -gt 0)
 AM_CONDITIONAL([HANDLER_chroot], test $((syntax_2_0 + 0)) -gt 0)
diff -Nur nALFS-1.2.6/Makefile.am nALFS-1.2.6-autopatch/Makefile.am
--- nALFS-1.2.6/Makefile.am	2006-01-28 19:20:24.000000000 +0100
+++ nALFS-1.2.6-autopatch/Makefile.am	2006-03-27 15:00:52.000000000 +0300
@@ -85,6 +85,9 @@
 if HANDLER_alfs
 src_nALFS_LDFLAGS += -dlopen src/handlers/alfs.la
 endif
+if HANDLER_autopatch
+src_nALFS_LDFLAGS += -dlopen src/handlers/autopatch.la
+endif
 if HANDLER_build
 src_nALFS_LDFLAGS += -dlopen src/handlers/build.la
 endif
@@ -184,6 +187,11 @@
 src_handlers_alfs_la_SOURCES = src/handlers/alfs.c
 src_handlers_alfs_la_LDFLAGS = -module -avoid-version
 endif
+if HANDLER_autopatch
+pkglib_LTLIBRARIES += src/handlers/autopatch.la
+src_handlers_autopatch_la_SOURCES = src/handlers/autopatch.c
+src_handlers_autopatch_la_LDFLAGS = -module -avoid-version
+endif
 if HANDLER_build
 pkglib_LTLIBRARIES += src/handlers/build.la
 src_handlers_build_la_SOURCES = src/handlers/build.c
diff -Nur nALFS-1.2.6/src/handlers/autopatch.c nALFS-1.2.6-autopatch/src/handlers/autopatch.c
--- nALFS-1.2.6/src/handlers/autopatch.c	1970-01-01 01:00:00.000000000 +0100
+++ nALFS-1.2.6-autopatch/src/handlers/autopatch.c	2006-03-27 14:25:42.000000000 +0300
@@ -0,0 +1,201 @@
+/*
+ *  autopatch.c - Handler.
+ * 
+ *  Copyright (C) 2006
+ *  
+ *  Mihail Zenkov <kreator@tut.by>
+ *
+ *  Based on patch.c by Neven Has <haski@sezampro.yu>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include <fnmatch.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define MODULE_NAME autopatch
+#include <nALFS.h>
+
+#include "handlers.h"
+#include "utility.h"
+#include "nprint.h"
+#include "parser.h"
+#include "backend.h"
+
+
+#if HANDLER_SYNTAX_3_1
+
+static const char *autopatch_parameters_ver3[] = { "path", "pattern", NULL };
+// char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
+
+static int patch_name(const char *path_with_name)
+{
+	int status = 0;
+	char *command;
+	command = xstrdup("");
+
+	if (fnmatch("*.bz2", path_with_name, FNM_LEADING_DIR) == 0) {
+		append_str(&command, "bzip2 -dc ");
+		append_str(&command, path_with_name);
+		append_str(&command, " | patch -Np1");
+	} else if (fnmatch("*.gz", path_with_name, FNM_LEADING_DIR) == 0) {
+		append_str(&command, "gzip -dc ");
+		append_str(&command, path_with_name);
+		append_str(&command, " | patch -Np1");
+	} else {
+		append_str(&command, "patch -Np1 -i ");
+		append_str(&command, path_with_name);
+	}
+
+	Nprint_h("    %s", command);
+
+	if ((status = execute_command(command))) {
+		Nprint_h_err("Patching failed.");
+	}
+	
+	xfree(command);
+
+	return status;
+}
+
+static int autopatch(const char *path, const char *pattern)
+{
+	int status = 0;
+	DIR *dir;
+	struct stat statbuf;
+	struct dirent *next;
+
+
+	if (lstat(path, &statbuf) == -1) {
+		Nprint_h_err("%s: %s", path, strerror(errno));
+		return -1;
+	}
+
+	if (! S_ISDIR(statbuf.st_mode)) {
+		Nprint_h_err("%s: It's not a directory", path);
+		return -1;
+	}
+
+	if (! (dir = opendir(path))) {
+		Nprint_h_err("%s: %s", path, strerror(errno));
+		return -1;
+	}
+
+	while ((next = readdir(dir)) != NULL) {
+		char path_with_name[strlen(path) + strlen(next->d_name) + 2];
+
+		sprintf(path_with_name, "%s%s%s",
+			path,
+			path[strlen(path)-1] == '/' ? "" : "/",
+			next->d_name);
+
+		if (lstat(path_with_name, &statbuf) == -1) {
+			Nprint_warn("%s: %s", path, strerror(errno));
+			continue;
+		}
+		if (S_ISDIR(statbuf.st_mode))
+			continue;
+
+		if (fnmatch(pattern, next->d_name, FNM_FILE_NAME) != 0)
+			continue;
+
+		//Nprint_h("%s: %s", path, next->d_name);
+		if((status=patch_name(path_with_name)) != 0) {
+			break;
+		}
+	}
+
+	closedir(dir);
+
+	return status;
+}
+
+static int autopatch_main_ver3(element_s *el)
+{
+	int status;
+	char *base;
+	char *path;
+	char *pattern;
+
+	if ((path = alloc_trimmed_param_value("path", el)) == NULL) {
+		Nprint_h_err("No path specified.");
+		return -1;
+	}
+
+	if ((pattern = alloc_trimmed_param_value("pattern", el)) == NULL) {
+		Nprint_h_err("No pattern specified.");
+		xfree(path);
+		return -1;
+	}
+
+	base = alloc_base_dir_new(el);
+
+	if (change_current_dir(base)) {
+		xfree(base);
+		xfree(path);
+		xfree(pattern);
+		return -1;
+	}
+	
+	Nprint_h("Patching in %s", base);
+	Nprint_h("path: %s", path);
+	Nprint_h("pattern: %s", pattern);
+
+	status = autopatch(path, pattern);
+
+	xfree(base);
+	xfree(path);
+	xfree(pattern);
+
+	return status;
+}
+
+#endif /* HANDLER_SYNTAX_3_1 */
+
+
+/*
+ * Handlers' information.
+ */
+
+handler_info_s HANDLER_SYMBOL(info)[] = {
+#if HANDLER_SYNTAX_3_1
+	{
+		.name = "autopatch",
+		.description = "Autopatch",
+		.syntax_version = "3.1",
+		.parameters = autopatch_parameters_ver3,
+		.main = autopatch_main_ver3,
+		.type = 0,
+		.alloc_data = NULL,
+		.is_action = 1,
+		.priority = 0
+	},
+#endif
+	{
+		NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0
+	}
+};
