Installing a customized package: use custom repo / overwrite / patch?

94 views
Skip to first unread message

Eugene Kirpichov

unread,
Jul 30, 2012, 5:51:18 PM7/30/12
to puppet...@googlegroups.com
Hello puppet-users,

I need to use puppet to install a slightly modified version of a
package (modify a few lines in the scripts it installs), but I don't
want to build my own version of the package and distribute it via a
private package repository because this seems too heavyweight.

What's the common way to do this? I have a few things in mind:
* Add separate file resources to overwrite the files I need to
modify. Pro: easy to implement. Con: essentially fixes the "base"
version of the package I'm using (won't merge with the updated
package's changes in the same file)
* Add an exec task to patch the files. Pro: seems like the right way.
Con: how do I detect if the patch is already applied? (should I just
force-reinstall the base package before patching?)

--
Eugene Kirpichov
http://www.linkedin.com/in/eugenekirpichov

Bryan Hunt

unread,
Aug 1, 2012, 4:33:57 AM8/1/12
to puppet...@googlegroups.com
On Mon, Jul 30, 2012 at 10:51 PM, Eugene Kirpichov <ekirp...@gmail.com> wrote:
Hello puppet-users,

I need to use puppet to install a slightly modified version of a
package (modify a few lines in the scripts it installs)
 
Which script, the init script? Which package?

 * Add separate file resources to overwrite the files I need to
modify. Pro: easy to implement. Con: essentially fixes the "base"
version of the package I'm using (won't merge with the updated
package's changes in the same file)

This is the fundamental issues with any fork. It's the oldest story in the book, once you have a customized package install you must then main your version in perpetuity.
 
 * Add an exec task to patch the files. Pro: seems like the right way.
Con: how do I detect if the patch is already applied? (should I just
force-reinstall the base package before patching?)

Could use a checksum or execute something like sed to modify the file in old school manner. Or more idiomatically, write a puppet plugin.

Regards,

Bryan Hunt


Calvin Walton

unread,
Aug 1, 2012, 11:49:42 AM8/1/12
to puppet...@googlegroups.com
On Mon, 2012-07-30 at 14:51 -0700, Eugene Kirpichov wrote:
> Hello puppet-users,
>
> I need to use puppet to install a slightly modified version of a
> package (modify a few lines in the scripts it installs), but I don't
> want to build my own version of the package and distribute it via a
> private package repository because this seems too heavyweight.
>
> What's the common way to do this? I have a few things in mind:

> * Add an exec task to patch the files. Pro: seems like the right way.
> Con: how do I detect if the patch is already applied? (should I just
> force-reinstall the base package before patching?)

The easiest way to do this sort of thing is to add some sort of marker
keyword to the file when the patch is applied. Then you can use a
resource like

exec { 'patch script':
unless => 'grep MARKER_KEYWORD /path/to/script',
command => 'patch /path/to/script some-patch',
require => [ Package['thepackage'], File['some-patch'] ],
}

If the package will always be installed and upgraded through puppet, you
might consider making the exec 'refreshonly' and notifying it from the
package resource.

--
Calvin Walton <calvin...@kepstin.ca>

Eugene Kirpichov

unread,
Aug 1, 2012, 12:55:13 PM8/1/12
to puppet...@googlegroups.com
Hi Calvin,

Thanks, your solution is exactly what I need! So simple and elegant and obvious in retrospect :)

среда, 1 августа 2012 г., 8:49:42 UTC-7 пользователь Calvin Walton написал:
Reply all
Reply to author
Forward
0 new messages