Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6985563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:41:47+00:00 2026-05-27T18:41:47+00:00

I have a program that I build from source. For this I’m using the

  • 0

I have a program that I build from source. For this I’m using the script resource. What is a good way to implement the logic for installation and update? Right now I just have installation implemented with the built-in not_if conditional.

script "install_program" do
  not_if {File.exists?('/program')}
  interpreter "bash"
  user "root"
  cwd "/tmp"
  code <<-EOH
    wget http://www.example.com/program.tar.gz
    tar -zxf program.tar.gz
    cd tarball
    ./configure
    make
    make install
  EOH
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:41:48+00:00Added an answer on May 27, 2026 at 6:41 pm

    First and foremost, if you have the means to host an internal package repository, I generally recommend that you build native packages for your target platform(s), and use the package resource to manage them, rather than building from source. I know that is not always available or feasible, so …

    The method which you make a “./configure && make && make install” style installation script idempotent depends on the kind of software you’re working with. Most often, it is sufficient to check for the target file’s existence. Sometimes, it is desirable to determine what version is required, and which version the program will output when executed with the proper command-line option. I will use your resource above as a starting point for these examples. Note that you can use bash as a shortcut for script resources that have interpreter bash.

    Assumptions: The program is installed to /usr/local/bin/program and takes an argument --version presumably to display the version number. I put the cd, configure, and make commands together with && because presumably if one fails we shouldn’t attempt to continue execution.

    bash "install_program" do
      not_if "/usr/local/bin/program --version | grep -q '#{node[:program][:version]}'"
      user "root"
      cwd "/tmp"
      code <<-EOH
        wget http://www.example.com/program-#{node[:program][:version]}.tar.gz -O /tmp/program-#{node[:program][:version]}.tar.gz
        tar -zxf program-#{node[:program][:version]}.tar.gz
        (cd program-#{node[:program][:version]}/ && ./configure && make && make install)
      EOH
    end
    

    Instead of using wget it is a bit better to use the remote_file resource as this is idempotent on its own. Note that the checksum parameter is added, with the value as an attribute. This parameter tells Chef not to download the remote file if the local target file matches the checksum. This is a SHA256 checksum. Also, this resource will notify the script to run immediately, so after it is downloaded. The script is set with action :nothing so it only gets executed if the remote_file is downloaded.

    remote_file "/tmp/program-#{node[:program][:version]}.tar.gz" do
      source "http://www.example.com/program-#{node[:program][:version]}.tar.gz"
      checksum node[:program][:checksum]
      notifies :run, "bash[install_program]", :immediately
    end
    
    bash "install_program" do
      user "root"
      cwd "/tmp"
      code <<-EOH
        tar -zxf program-#{node[:program][:version]}.tar.gz
        (cd program-#{node[:program][:version]}/ && ./configure && make && make install)
      EOH
      action :nothing
    end
    

    Also, /tmp may be erased on your system upon reboot. It is recommended that you download to another location that isn’t deleted, such as Chef’s file cache location, which is the value of Chef::Config[:file_cache_path]. For example:

    remote_file "#{Chef::Config[:file_cache_path]}/program.tar.gz" do
      ...
    end
    

    For further examples, you can see “source” recipes in several cookbooks shared by Opscode here: http://github.com/opscode/cookbooks. php, python, gnu_parallel, and nagios cookbooks all have “source” recipes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have build C# program that work with RAPI (communication to PPC or WinCE)
I have to build a C# program that makes CSV files and puts long
I have a program that creates a Windows user account using the NetUserAdd() API
I have a program that uses the mt19937 random number generator from boost::random. I
I have a program that monitors debug messages and I have tried using a
I have the following makefile that I use to build a program (a kernel,
Compiling FluidSynth 1.1.1 from source. I have unresolved external symbol with glib, using Visual
Suppose I have an SConstruct file that looks like this: env = Environment() env.Program(a,
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.