pts / sam2p

raster (bitmap) image converter with smart PDF and PostScript (EPS) output
http://pts.50.hu/sam2p/
GNU General Public License v2.0
42 stars 15 forks source link

Homebrew formula for easy installation from source on macOS #34

Closed sbibauw closed 6 years ago

sbibauw commented 6 years ago

I think sam2p would be perfect with a Homebrew formula for easy installation from source on macOS. I am not an experienced developer and this is my first "new" formula, so it should certainly be corrected and improved, but it is a start.

I copy the ruby Formula here considering the best place would probably to create a homebrew-pdfutils or something repo on your Github where adding formulas for sam2p, tif22pnm and pdfsizeopt...

class Sam2p < Formula
  desc "Raster image converter with smart PDF and PostScript output"
  homepage "https://github.com/pts/sam2p"
  url "https://github.com/pts/sam2p/archive/v0.49.4.tar.gz"
  sha256 "17313810a724aaf6ef7c146443c452f324edfd70ae291eb1f5a297c621df9d1e"
  head "https://github.com/pts/sam2p.git"

  def install
    system "./configure", "--disable-debug",
                          "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--prefix=#{prefix}",
                          "--enable-gif",
                          "--enable-lzw"
    system "make"
    system "make", "install"
  end

  test do
    system "#{bin}/sam2p", "examples/ptsbanner_zip.job"
    system "#{bin}/sam2p", "examples/pts2.pbm", "try.eps"
    assert_predicate "try.eps", :exist?
  end
end
pts commented 6 years ago

Thank you for this contribution!

How is this file useful for Homebrew users? What command do they have to run? Wouldn't it be more useful if this file was added to the Homebrew package database?

sbibauw commented 6 years ago

Sorry, I forgot a few important things:

  1. Having a brew formula allows Homebrew users to install (from source) with brew install sam2p. More importantly, it allows to manage all the dependencies perfectly. Not a big deal here, but my goal is to propose a formula for pdfsizeopt with sam2p and all other libraries managed as homebrew dependencies. It would really solve a lot of issues for Mac users (including optional and recommended dependencies, the question of including Ghostscript or not, etc.)

  2. Indeed the best option is to send this file (sam2p.rb) to the main homebrew-core tap (package database), BUT it fails for now to comply with the requirement that the Github repo should have at least 20 watchers/20 forks/50 stars (to ensure that the software has a certain importance). For a future pdfsizeopt formula, a potential issue would also be that it has pngout as dependency, which can not be on homebrew-core because not open sourced (see this issue). But, while the formulas can't be hosted on the homebrew-core tap, they can be on a private tap (basically a Github repo). The command for users would then be: brew install pts/homebrew-utils/sam2p.

For this, you just have to create a homebrew-utils (or homebrew-whateveryouwant) repo and add this sam2p.rb file (and future tif2pnm.rb and pdfsizeopt.rb) to it. Technically, I could very well create this repo myself, but I think it makes more sense that you control it.

pts commented 6 years ago

Is it possible to add this brew file to the https://github.com/pts/sam2p repo instead? What should be the filename? What would be the corresponding brew install command?

For adding pdfsizeopt to Homebrew, please open an issue in https://github.com/pts/pdfsizeopt/issues/new.

sbibauw commented 6 years ago

I suppose it is theoretically possible (putting sam2p.rb in a Formula subdirectory) (see https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md). The problem is that the whole repo would be considered as a Tap and cloned to /usr/local/Homebrew/Library/Taps/, which seems a little bit too much for this purpose (and will be updated/synced by homebrew on any upstream change, even when it does not affect the formula). And the same would happen for pdfsizeopt, etc. (all their repos synced as a tap).

If you really prefer not to create a new homebrew-utils repo, I can create (and maintain -- even though it is not much) it myself.

sbibauw commented 6 years ago

FYI, I tried to do it on my own fork of sam2p, by creating a subdirectory (HomebrewFormula) but Hombrew fails to tap it correctly, because it expects a repository named homebrew-something (so this naming convention is more than a recommendation, it seems to be mandatory):

$ brew install sbibauw/sam2p/sam2p
==> Tapping sbibauw/sam2p
Cloning into '/usr/local/Homebrew/Library/Taps/sbibauw/homebrew-sam2p'...
fatal: repository 'https://github.com/sbibauw/homebrew-sam2p/' not found

So it definitely needs a specific repo for the brew formulas. Let me know if you prefer creating/hosting it yourself or not.

sbibauw commented 6 years ago

@pts Let me know what you think about creating this specific repo for brew formulas. Otherwise, I'll create it myself. In any case, I have the 3 formulas ready (sam2p, tif2pnm and pdfsizeopt)

pts commented 6 years ago

I've created https://github.com/pts/homebrew-utils , added sam2p.rb above, and I've added you (sbibauw) as a collaborator. Please add the rest of the formulas.

FYI There are binary releases of sam2p, png22pnm and pdfsizeopt for macOS, which I'm maintaining. Installation instructions are in the Installation instructions and usage on macOS section of https://github.com/pts/pdfsizeopt . For new and/or casual users I recommend using the binary releases, because they are easy to install, the download is small, and they don't depend on Homebrew (which is a huge and slow-to-install dependency, and not all users need it).

Nevertheless, thank you very much for your work on these Homebrew formulas! Some users may want to install from source, and these formulas let them do so conveniently.