github.com/szyn/goreleaser@v0.76.1-0.20180517112710-333da09a1297/www/content/linux-packages.md (about)

     1  ---
     2  title: Linux Packages
     3  series: customization
     4  hideFromIndex: true
     5  weight: 80
     6  ---
     7  
     8  GoReleaser can generate RPM, Deb and Snap packages for your projects.
     9  
    10  Let's see each option in detail:
    11  
    12  ## NFPM
    13  
    14  GoReleaser can be wired to [nfpm](https://github.com/goreleaser/nfpm) to
    15  generate and publish `.deb` and `.rpm` packages.
    16  
    17  Available options:
    18  
    19  ```yml
    20  # .goreleaser.yml
    21  nfpm:
    22    # You can change the name of the package.
    23    # This is parsed with the Go template engine and the following variables
    24    # are available:
    25    # - ProjectName
    26    # - Tag
    27    # - Version (Git tag without `v` prefix)
    28    # - Os
    29    # - Arch
    30    # - Arm (ARM version)
    31    # - Env (environment variables)
    32    # Default: `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
    33    name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
    34  
    35    # Replacements for GOOS and GOARCH in the package name.
    36    # Keys should be valid GOOSs or GOARCHs.
    37    # Values are the respective replacements.
    38    # Default is empty.
    39    replacements:
    40      amd64: 64-bit
    41      386: 32-bit
    42      darwin: macOS
    43      linux: Tux
    44  
    45    # Your app's vendor.
    46    # Default is empty.
    47    vendor: Drum Roll Inc.
    48    # Your app's homepage.
    49    # Default is empty.
    50    homepage: https://example.com/
    51  
    52    # Your app's maintainer (probably you).
    53    # Default is empty.
    54    maintainer: Drummer <drum-roll@example.com>
    55  
    56    # Your app's description.
    57    # Default is empty.
    58    description: Software to create fast and easy drum rolls.
    59  
    60    # Your app's license.
    61    # Default is empty.
    62    license: Apache 2.0
    63  
    64    # Formats to be generated.
    65    formats:
    66      - deb
    67      - rpm
    68  
    69    # Packages your package depends on.
    70    dependencies:
    71      - git
    72      - zsh
    73  
    74    # Packages your package recommends installing.
    75    # For RPM packages rpmbuild >= 4.13 is required
    76    recommends:
    77      - bzr
    78      - gtk
    79  
    80    # Packages your package suggests installing.
    81    # For RPM packages rpmbuild >= 4.13 is required
    82    suggests:
    83      - cvs
    84      - ksh
    85  
    86    # Packages that conflict with your package.
    87    conflicts:
    88      - svn
    89      - bash
    90  
    91    # Override default /usr/local/bin destination for binaries
    92    bindir: /usr/bin
    93  
    94    # Empty folders that should be created and managed by the packager
    95    # implementation.
    96    # Default is empty.
    97    empty_folders:
    98    - /var/log/foobar
    99  
   100    # Files or directories to add to your package (beyond the binary).
   101    # Keys are source paths/globs to get the files from.
   102    # Values are the destination locations of the files in the package.
   103    files:
   104      "scripts/etc/init.d/": "/etc/init.d"
   105      "path/**/glob": "/var/foo/glob"
   106  
   107    # Config files to add to your package. They are about the same as
   108    # the files keyword, except package managers treat them differently (while
   109    # uninstalling, mostly).
   110    # Keys are source paths/globs to get the files from.
   111    # Values are the destination locations of the files in the package.
   112    config_files:
   113      "tmp/app_generated.conf": "/etc/app.conf"
   114      "conf/*.conf": "/etc/foo/"
   115  
   116    # Scripts to execute during the installation of the package.
   117    # Keys are the possible targets during the installation process
   118    # Values are the paths to the scripts which will be executed
   119    scripts:
   120      preinstall: "scripts/preinstall.sh"
   121      postinstall: "scripts/postinstall.sh"
   122      preremove: "scripts/preremove.sh"
   123      postremove: "scripts/postremove.sh"
   124  
   125    # Some attributes can be overrided per package format.
   126    overrides:
   127      deb:
   128        conflicts:
   129          - subversion
   130        dependencies:
   131          - git
   132        suggests:
   133          - gitk
   134        recommends:
   135          - tig
   136        empty_folders:
   137        - /var/log/bar
   138      rpm:
   139        replacements:
   140          amd64: x86_64
   141        name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Arch }}"
   142        files:
   143          "tmp/man.gz": "/usr/share/man/man8/app.8.gz"
   144        config_files:
   145          "tmp/app_generated.conf": "/etc/app-rpm.conf"
   146        scripts:
   147          preinstall: "scripts/preinstall-rpm.sh"
   148  ```
   149  
   150  Note that GoReleaser will not install `rpmbuild` or any dependencies for you.
   151  As for now, `rpmbuild` is recommended if you want to generate rpm packages.
   152  You can install it with `apt-get install rpm` or `brew install rpm`.
   153  
   154  ## Snapcraft
   155  
   156  GoReleaser can also generate `snap` packages.
   157  [Snaps](http://snapcraft.io/) are a new packaging format, that will let you
   158  publish your project directly to the Ubuntu store.
   159  From there it will be installable in all the
   160  [supported Linux distros](https://snapcraft.io/docs/core/install), with
   161  automatic and transactional updates.
   162  
   163  You can read more about it in the [snapcraft docs](https://snapcraft.io/docs/).
   164  
   165  Available options:
   166  
   167  ```yml
   168  # .goreleaser.yml
   169  snapcraft:
   170    # You can change the name of the package.
   171    # This is parsed with the Go template engine and the following variables
   172    # are available:
   173    # - ProjectName
   174    # - Tag
   175    # - Version (Git tag without `v` prefix)
   176    # - Os
   177    # - Arch
   178    # - Arm (ARM version)
   179    # - Env (environment variables)
   180    # Default: `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
   181    name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
   182  
   183    # Replacements for GOOS and GOARCH in the package name.
   184    # Keys should be valid GOOSs or GOARCHs.
   185    # Values are the respective replacements.
   186    # Default is empty.
   187    replacements:
   188      amd64: 64-bit
   189      386: 32-bit
   190      darwin: macOS
   191      linux: Tux
   192  
   193    # The name of the snap. This is optional.
   194    # Default is project name.
   195    name: drumroll
   196  
   197    # Single-line elevator pitch for your amazing snap.
   198    # 79 char long at most.
   199    summary: Software to create fast and easy drum rolls.
   200  
   201    # This the description of your snap. You have a paragraph or two to tell the
   202    # most important story about your snap. Keep it under 100 words though,
   203    # we live in tweetspace and your description wants to look good in the snap
   204    # store.
   205    description: |
   206      This is the best drum roll application out there.
   207      Install it and awe!
   208  
   209    # A guardrail to prevent you from releasing a snap to all your users before
   210    # it is ready.
   211    # `devel` will let you release only to the `edge` and `beta` channels in the
   212    # store. `stable` will let you release also to the `candidate` and `stable`
   213    # channels. More info about channels here:
   214    # https://snapcraft.io/docs/reference/channels
   215    grade: stable
   216  
   217    # Snaps can be setup to follow three different confinement policies:
   218    # `strict`, `devmode` and `classic`. A strict confinement where the snap
   219    # can only read and write in its own namespace is recommended. Extra
   220    # permissions for strict snaps can be declared as `plugs` for the app, which
   221    # are explained later. More info about confinement here:
   222    # https://snapcraft.io/docs/reference/confinement
   223    confinement: strict
   224  
   225    # Each binary built by GoReleaser is an app inside the snap. In this section
   226    # you can declare extra details for those binaries. It is optional.
   227    apps:
   228  
   229      # The name of the app must be the same name as the binary built.
   230      drumroll:
   231  
   232        # If your app requires extra permissions to work outside of its default
   233        # confined space, declare them here.
   234        # You can read the documentation about the available plugs and the
   235        # things they allow:
   236        # https://snapcraft.io/docs/reference/interfaces).
   237        plugs: ["home", "network"]
   238  
   239        # If you want your app to be autostarted and to always run in the
   240        # background, you can make it a simple daemon.
   241        daemon: simple
   242  ```
   243  
   244  Note that GoReleaser will not install `snapcraft` nor any of its dependencies
   245  for you.