adding --prefix support for RPM #230

Merged
merged 1 commit into from Jul 22, 2012

Conversation

Projects
None yet
2 participants

jkoppe commented May 29, 2012

I exposed prefix and build_sub_dir so the ERB can read these bits and manipulate the SPEC according to http://www.rpm.org/max-rpm/s1-rpm-reloc-prefix-tag.html. It's a pretty simple change, and I've used it to generate RPMs with and without the --prefix argument. Let me know if there's anything else you need!

Owner

jkoppe commented on 7d307fe May 29, 2012

Expose prefix and build_sub_dir so the ERB can reference this information to generate the correct spec when using --prefix.

@jordansissel jordansissel commented on the diff May 29, 2012

templates/rpm.erb
@@ -99,7 +102,7 @@ fi
%defattr(-,<%= attributes[:rpm_user] %>,<%= attributes[:rpm_group] %>,-)
<%# Output config files and then regular files. -%>
<% config_files.each do |path| -%>
-%config(noreplace) <%= path %>
+%config(noreplace) <%= path.gsub(/^/,prefix) %>
@jordansissel

jordansissel May 29, 2012

Owner

Just an FYI: path.gsub(/^/, prefix) is probably better written as "#{prefix}/#{path}" or perhaps better File.join(prefix,path)

@jkoppe

jkoppe Jun 4, 2012

Those two options make more sense. Note though that prefix is either / or /something/like/this. And I'm also doing no validation on prefix -- I assumed it was already done elsewhere.

Owner

jordansissel commented May 29, 2012

I am excited for relocatable package support! :)

Owner

jordansissel commented May 29, 2012

will test this later this week and try to write some tests to verify rpm is happy with it, then push a new gem :)

jkoppe commented Jul 20, 2012

@jordansissel: eta on this pull?

Owner

jordansissel commented Jul 20, 2012

Ooh sorry. Will get on this ASAP and put a new release out! Thanks again
for this :)

-Jordan

On Friday, July 20, 2012, Jason Koppe wrote:

@jordansissel: eta on this pull?


Reply to this email directly or view it on GitHub:
#230 (comment)

@jordansissel jordansissel added a commit that referenced this pull request Jul 22, 2012

@jordansissel jordansissel Merge pull request #230 from jkoppe/master
Make rpms relocatable by respecting fpm's --prefix appropriately.
d6dddf2

@jordansissel jordansissel merged commit d6dddf2 into jordansissel:master Jul 22, 2012

Owner

jordansissel commented Jul 22, 2012

This change broke a few tests, but the fixes were super easy.

I also changed it to use the File.join(prefix, path) as discussed.

Thanks again for this patch! :)

@jordansissel jordansissel added a commit that referenced this pull request Jul 22, 2012

@jordansissel jordansissel - fix some failing tests introduced by #230 (regression check on quoted
  filenames, etc)
- Prefer File.join() when joining paths
6f3cd25
Owner

jordansissel commented Jul 22, 2012

I also couldn't get this to work properly, though I could be messing something. Here's what I tried, roughly 'package /etc/motd in the prefix /usr/local, but be relocatable.`

% fpm -s dir -t rpm -n example --prefix /usr/local /etc/motd`
% rpm -qlp example-1.0-1.x86_64.rpm 
/usr/local/usr/local/etc/motd

/usr/local/ was present twice.

Yet, if I patch it slightly, making 'build_sub_dir' always return "BUILD" instead of "BUILD/{prefix}", I get:

# Corrected behavior, I think?
% rpm -qlp example-1.0-1.x86_64.rpm                                  
/usr/local/etc/motd
% rpm -qip example-1.0-1.x86_64.rpm | grep Relo
Relocations : /usr/local 
% sudo rpm -i --prefix /pants example-1.0-1.x86_64.rpm 
% rpm -ql example
/pants/etc/motd
Owner

jordansissel commented Jul 22, 2012

Does the above behavior seem correct to you? If so, I"ll release with my patches.

jkoppe commented Jul 22, 2012

I'm probably abusing some RPM standard here, but the double /usr/local is ok in our case:

--> rpm -qpl Indeed-Percona-Server-server-5.5.24-rel26.0.256.rhel5-1-x86_64.rpm
/usr/local/percona/mysql-5.5.24/etc/init.d/mysql
/usr/local/percona/mysql-5.5.24/etc/logrotate.d/mysql
/usr/local/percona/mysql-5.5.24/usr/bin/innochecksum
/usr/local/percona/mysql-5.5.24/usr/bin/my_print_defaults
/usr/local/percona/mysql-5.5.24/usr/bin/myisam_ftdump
/usr/local/percona/mysql-5.5.24/usr/bin/myisamchk
/usr/local/percona/mysql-5.5.24/usr/bin/myisamlog
/usr/local/percona/mysql-5.5.24/usr/bin/myisampack
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_convert_table_format
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_fix_extensions
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_install_db
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_plugin
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_secure_installation
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_setpermission
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_tzinfo_to_sql
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_upgrade
/usr/local/percona/mysql-5.5.24/usr/bin/mysql_zap
/usr/local/percona/mysql-5.5.24/usr/bin/mysqlbug
/usr/local/percona/mysql-5.5.24/usr/bin/mysqld_multi
/usr/local/percona/mysql-5.5.24/usr/bin/mysqld_safe
/usr/local/percona/mysql-5.5.24/usr/bin/mysqldumpslow
/usr/local/percona/mysql-5.5.24/usr/bin/mysqlhotcopy
/usr/local/percona/mysql-5.5.24/usr/bin/mysqltest
/usr/local/percona/mysql-5.5.24/usr/bin/perror
/usr/local/percona/mysql-5.5.24/usr/bin/replace
/usr/local/percona/mysql-5.5.24/usr/bin/resolve_stack_dump
/usr/local/percona/mysql-5.5.24/usr/bin/resolveip
...

For MySQL RPMs, we use a modified startup script which sets environment variables correctly so the /usr/local/.../usr/ stuff just works.

Perhaps this is a no-no for RPMs. I'm going on vacation this week and won't be spending any time thinking about this. I hotfixed fpm on a machine so we could get this functionality for now -- but lets hold off on this pull until we have some more time to chat (August)

Owner

jordansissel commented Jul 22, 2012

Sounds reasonable to me! In the mean-time, I"ll try to find someone who uses relocatable rpms and see what their use cases are.

@prof-milki prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 18, 2014

jls Merge pull request #230 from jkoppe/master
Make rpms relocatable by respecting fpm's --prefix appropriately.
110dc2e

@prof-milki prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 18, 2014

jls - fix some failing tests introduced by #230 (regression check on quoted
  filenames, etc)
- Prefer File.join() when joining paths
e63fffb

@prof-milki prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 27, 2014

@jordansissel jordansissel Merge pull request #230 from jkoppe/master
Make rpms relocatable by respecting fpm's --prefix appropriately.
c40f313

@prof-milki prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 27, 2014

@jordansissel jordansissel - fix some failing tests introduced by #230 (regression check on quoted
  filenames, etc)
- Prefer File.join() when joining paths
ded6c5f

@jordansissel jordansissel added a commit that referenced this pull request Apr 24, 2015

@jordansissel jordansissel Merge pull request #230 from jkoppe/master
Make rpms relocatable by respecting fpm's --prefix appropriately.
541faf3

@jordansissel jordansissel added a commit that referenced this pull request Apr 24, 2015

@jordansissel jordansissel - fix some failing tests introduced by #230 (regression check on quoted
  filenames, etc)
- Prefer File.join() when joining paths
ba015ee

@jordansissel jordansissel added a commit that referenced this pull request Jun 20, 2016

@jordansissel jordansissel Merge pull request #230 from jkoppe/master
Make rpms relocatable by respecting fpm's --prefix appropriately.
81baf83

@jordansissel jordansissel added a commit that referenced this pull request Jun 20, 2016

@jordansissel jordansissel - fix some failing tests introduced by #230 (regression check on quoted
  filenames, etc)
- Prefer File.join() when joining paths
6b7f4c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment