--- pkgbuild.pl.old	Wed Mar 10 14:09:57 2010
+++ pkgbuild.pl	Mon Apr 26 13:39:12 2010
@@ -1232,7 +1232,7 @@
 	}
     }
 
-    if ($class_name ne 'none' and $type eq 'f' and $file->is_config ()) {
+    if ($class_name ne 'none' and $type eq 'f' and $file->is_config() and $file->is_manifest()) {
 	$type = "e";
     }
 
@@ -1241,6 +1241,8 @@
 	    $type = 'v';
 	} elsif ($file->is_config ()) {
 	    $type = 'v';
+	} elsif ($file->is_manifest()) {
+	    $type = 'v';
 	}
     }
 
@@ -1384,6 +1386,9 @@
 	if ($file->is_config()) {
 	    $line .= " preserve=\"renamenew\"";
 	}    
+	if ($file->is_manifest()) {
+	    $line .= " restart_fmri=\"svc:/system/manifest-import:default\"";
+	}
     } elsif ( $type eq 'd' ) {
 	my $file1 = $fname;
 	if ( not defined $file ) {
@@ -2080,6 +2085,20 @@
     }
 }
 
+# Prepare pkgsend lines, which add actions of package to ips repository
+sub make_ips_actions ($$$) {
+    my $ref_lines = shift;
+    my $spec = shift;
+    my $package = shift;
+    
+    my @actions = $package->get_actions ();
+    my $tag;
+    my %all_files_in_manifest = ();
+    foreach $action (@actions) {
+	push (@$ref_lines, $action);
+    }
+}
+
 # Create infrastructure for IPS packages
 sub create_ips_packages ($$) {
     my $spec = shift;
@@ -2107,6 +2126,8 @@
     make_ips_dependency(\@manifest_lines, $spec, $package);
     debug_print "Calling make_ips_files";
     make_ips_files(\@manifest_lines, $spec, $package);
+    debug_print "Calling make_ips_actions";
+    make_ips_actions(\@manifest_lines, $spec, $package);
     debug_print "Calling add_ips_summary";
     add_ips_summary(\@manifest_lines, $package, $src_fmri);
     debug_print "Calling add_ips_license";
--- rpm_spec.pm.old	Wed Mar 10 14:15:06 2010
+++ rpm_spec.pm	Mon Apr 26 13:40:58 2010
@@ -62,7 +62,7 @@
 # i.e. pre|preun wrong,  preun|pre good.
 my $all_script_names = "preun|postun|pre|post|verifyscript|triggerin|triggerun|triggerpostun|check";
 my $all_block_names = "prep|build|install|clean|check|changelog|$all_script_names";
-my $all_keywords = "$all_block_names|define|patch|setup|files|description|package|iclass|rclass|use";
+my $all_keywords = "$all_block_names|define|patch|setup|files|description|package|iclass|rclass|use|actions";
 
 sub get_version () {
     my $version = "1.3.101";
@@ -2188,6 +2188,7 @@
     my @this_attr = ();
     my $is_doc = 0;
     my $is_config = 0;
+    my $is_manifest = 0;
     my $is_ghost = 0;
     my $is_hardlink = 0;
     my @this_verify = (@all_verify);
@@ -2267,8 +2268,8 @@
 		my $file = rpm_file->new ($package_ref, $doc_name,
 					  \@this_attr, \@defattr, \@this_verify,
 					  not ($is_dir), $is_doc,
-					  $is_config, $class_name, $is_ghost,
-					  $is_hardlink);
+					  $is_config, $is_manifest, $class_name,
+                                          $is_ghost, $is_hardlink);
 		$package_ref->add_file ($file);
 		if (defined ($compression)) {
 		    $file->set_compression ($compression);
@@ -2282,6 +2283,11 @@
 	    $eline =~ s/^\s*%config\s*\([^)]*\)\s*// or
 		$eline =~ s/^\s*%config\s*//;
 	    next;	    
+        } elsif ($eline =~ /^\s*%manifest/) {
+            $is_manifest = 1;
+            $eline =~ s/^\s*%manifest\s*\([^)]*\)\s*// or
+                $eline =~ s/^\s*%manifest\s*//;
+            next;
 	} elsif ($eline =~ /^\s*%ghost/) {
 	    $is_ghost = 1;
 	    $eline =~ s/^\s*%ghost\s*\([^)]*\)\s*// or
@@ -2321,8 +2327,8 @@
 	    my $file = rpm_file->new ($package_ref, $1,
 				      \@this_attr, \@defattr, \@this_verify,
 				      not ($is_dir), $is_doc,
-				      $is_config, $class_name, $is_ghost,
-				      $is_hardlink);
+				      $is_config, $is_manifest, $class_name,
+				      $is_ghost, $is_hardlink);
 	    $package_ref->add_file ($file);
 	} elsif ($eline =~ /^\s*([A-Za-z0-9]\S*)/) {
 	    $self->_set_error ("File must begin with \"/\": $1", $fhandle);
@@ -2334,6 +2340,7 @@
 	@this_attr = ();
 	$is_doc = 0;
 	$is_config = 0;
+	$is_manifest = 0;
         $is_ghost = 0;
         $is_hardlink = 0;
 	@this_verify = (@all_verify);
@@ -2354,6 +2361,85 @@
     return 1;
 }
 
+sub _process_actions ($$$;$) {
+    my $self = shift;
+    my $fhandle = shift;
+    my $line = shift;
+    my $package_name = shift;
+
+    my $package_ref;
+
+    if (defined $line) {
+	my %macro_opts = $self->_process_macro_opts ('n:f@', $line, "actions");
+	if (defined ($self->{error})) {
+	    return 0;
+	}
+	if (($macro_opts{'argc'} > 1) or
+	    (defined ($macro_opts{'n'}) and ($macro_opts{'argc'} > 0))) {
+	    $self->_set_error ("Too many names: $line", $fhandle);
+	    return 0;
+	}
+	$package_ref = $self->{_packages}[0];
+	if (not defined($package_name)) {
+	    if (defined ($macro_opts{'n'})) {
+		$package_name = $macro_opts{'n'};
+	    } elsif (defined ($macro_opts{'argv0'})) {
+		$package_name = $package_ref->get_name() . "-" . 
+		    $macro_opts{'argv0'};
+	    } else {
+		$package_name = $package_ref->get_name();
+	    }
+	}
+	$package_ref = undef;
+	$package_ref = $self->find_package_by_name ($package_name);
+    } else {
+	if (not defined ($package_name)) {
+	    $self->_set_error ("assertion failed: _process_files: \$line or \$package_name must be defined");
+	    return 0;
+	}
+	$package_ref = $self->find_package_by_name ($package_name);
+    }
+
+    if (not defined ($package_ref)) {
+	$self->_set_error ("Undefined package $package_name", $fhandle);
+	return 0;
+    }
+
+    $line = $self->_get_next_line ($fhandle);
+    if (not defined($line)) {
+	if (defined $self->{error}) {
+	    return 0;
+	}
+
+	return 1;
+    }
+    my $eline = $self->_preprocess_line ($line);
+
+    while (1) {
+	if ($eline =~ /^$/) {
+	    # ignore empty lines
+	} elsif ($eline =~ /^#/) {
+	    # comment, skip to next line
+	} elsif ($eline =~ /^\s*([^%]\S.*)\s*$/) {
+	    $package_ref->add_action ($eline);
+	} else {
+	    return $self->_process_top_level ($fhandle, $line);
+	}
+
+	$line = $self->_get_next_line ($fhandle);
+	if (not defined($line)) {
+	    last;
+	}
+	$eline = $self->_preprocess_line ($line);
+    }
+
+    if (defined $self->{error}) {
+	return 0;
+    }
+
+    return 1;
+}
+
 sub _process_top_level ($$$) {
     my $self = shift;
     my $fhandle = shift;
@@ -2381,6 +2467,8 @@
 	    $self->_process_block ($fhandle, $line) or return 0;
 	} elsif ($eline =~ /^%files/) {
 	    $self->_process_files ($fhandle, $line) or return 0;
+	} elsif ($eline =~ /^%actions/) {
+	    $self->_process_actions ($fhandle, $line) or return 0;
 	} elsif ($eline =~ /^\s*%define/) {
 	    $self->_process_define ($fhandle, $self->_pre_eval ($line))
 		or return 0;
--- rpm_file.pm.old	Wed Mar 10 14:12:52 2010
+++ rpm_file.pm	Wed Mar 10 14:14:58 2010
@@ -47,6 +47,7 @@
     my $is_recursive = shift;
     my $is_doc = shift;
     my $is_config = shift;
+    my $is_manifest = shift;
     my $class_name = shift;
     my $is_ghost = shift;
     my $is_hardlink = shift;
@@ -75,6 +76,10 @@
 	$is_config = 0;
     }
 
+    if (not defined $is_manifest) {
+        $is_manifest = 0;
+    }
+
     if (not defined $is_ghost) {
 	$is_ghost = 0;
     }
@@ -94,6 +99,7 @@
     $self->{_verify} = $verify;
     $self->{_is_doc} = $is_doc;
     $self->{_is_config} = $is_config;
+    $self->{_is_manifest} = $is_manifest;
     $self->{_is_ghost} = $is_ghost;
     $self->{_is_hardlink} = $is_hardlink;
     $self->{_is_recursive} = $is_recursive;
@@ -218,6 +224,12 @@
     return $self->{_is_config};
 }
 
+sub is_manifest ($) {
+    my $self = shift;
+
+    return $self->{_is_manifest};
+}
+
 sub is_ghost ($) {
     my $self = shift;
 
--- rpm_package.pm.old	Fri Apr 23 16:38:55 2010
+++ rpm_package.pm	Fri Apr 23 16:52:13 2010
@@ -320,6 +320,19 @@
     push (@$files, $file);
 }
 
+sub add_action ($$) {
+    my $self = shift;
+    my $action = shift;
+
+    if (not defined $self->{_actions}) {
+        my @fs = ();
+        $self->{_actions} = \@fs;
+    }
+    return if not defined $action;
+    my $actions = $self->{_actions};
+    push (@$actions, $action);
+}
+
 sub add_metafile ($$) {
     my $self = shift;
     my $fname = shift;
@@ -351,6 +364,15 @@
     return @$files if $files;
     return undef;
 }
+
+sub get_actions ($) {
+    my $self = shift;
+
+    my $actions = $self->{_actions};
+    return undef if not defined $actions;
+    return @$actions if $actions;
+    return undef;
+}
 
 sub has_files ($) {
     my $self = shift;
