Skip to content

Commit

Permalink
Is. htacg#748 - Implement snap packaging
Browse files Browse the repository at this point in the history
Snaps are universal Linux packages that can be installed and run on
multiple GNU+Linux distributions with ease.  This patch implements the
necessary files to build tidy as a snap.

Refer-to: Snapcraft - Snaps are universal Linux packages
<https://snapcraft.io>
Conforming-to: tidy-html5/CONTRIBUTING.md at next · htacg/tidy-html5
<https://github.com/htacg/tidy-html5/blob/next/README/CONTRIBUTING.md>
Conforming-to: tidy-html5/CODESTYLE.md at next · htacg/tidy-html5
<https://github.com/htacg/tidy-html5/blob/next/README/CODESTYLE.md>
Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
  • Loading branch information
brlin-tw committed Aug 23, 2018
1 parent 86b52dc commit 0607ce4
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ temp*
.DS_Store
.idea
*.old

# Snap packaging specific rules
/parts/
/stage/
/prime/

/*.snap
/*_source.tar.bz2
9 changes: 9 additions & 0 deletions snap/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.yaml]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
6 changes: 6 additions & 0 deletions snap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Version Tracking Ignore Rules for Git VCS
# https://git-scm.com/docs/gitignore
/.snapcraft/

__pycache__
*.pyc
33 changes: 33 additions & 0 deletions snap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Snap Packaging for Tidy
![Placeholder Icon for Tidy](gui/icon.png "Placeholder Icon for Tidy")

**This is the snap for Tidy**, *"HTML parser and pretty printer. The grand daddy of HTML tools."*. It works on Ubuntu, Fedora, Debian, and other major Linux distributions.

[![Build Status Badge of the `tidy` Snap](https://build.snapcraft.io/badge/htacg/tidy-html5.svg "Build Status of the `tidy` snap")](https://build.snapcraft.io/user/htacg/tidy-html5)

![Screenshot of the Snapped Application](screenshots/tidy-help-heading.png "Screenshot of the Snapped Application")

Published for <img src="http://anything.codes/slack-emoji-for-techies/emoji/tux.png" align="top" width="24" /> with 💝 by Snapcrafters

## Installation
([Don't have snapd installed?](https://snapcraft.io/docs/core/install))

### In Terminal
# Install Snap #
sudo snap install tidy-brlin

# Connect the Snap to Optional Interfaces #
## `removable-media`: For accessing files under /media and /run/media ##
sudo snap connect tidy-brlin:removable-media

### The Graphical Way
Browse <https://snapcraft.io/tidy> and follow the instructions.

## Support
* Report issues regarding using this snap to the issue tracker:
<https://github.com/htacg/tidy-html5/issues>

be sure to mention you are using the snap package.

* You may also post on the Snapcraft Forum, under the `snap` topic category:
<https://forum.snapcraft.io/c/snap>
5 changes: 5 additions & 0 deletions snap/gui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# /snap/gui

Copy the snapped application's icon here and specify it in snapcraft.yaml file using the `icon` keyword. This folder is not necessary if the icon is already existed in the source tree.

NOTE: The Snap Store requires SVG scalable image or PNG image with at least 256x256px in size.
Binary file added snap/gui/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions snap/screenshots/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# /snap/screenshots

The screenshots of the snapped application. This is not currently synced to the product page on the Snap Store and should be uploaded by yourself.
Binary file added snap/screenshots/tidy-help-heading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
%YAML 1.2
---
# Snapcraft Recipe for Tidy
# ------------------------------
# This file is in the YAML data serialization format:
# http://yaml.org
# For the spec. of writing this file refer the following documentation:
# * The snapcraft syntax
# https://docs.snapcraft.io/build-snaps/syntax
# * Snap Docs
# https://snapdocs.labix.org
# * Latest doc topics in the Snapcraft Forum
# https://forum.snapcraft.io/c/doc
# For support refer to the snapcraft section in the Snapcraft Forum:
# https://forum.snapcraft.io/c/snapcraft

name: tidy
summary: HTML parser and pretty printer. The grand daddy of HTML tools
description: |
Tidy is a console application for Mac OS X, Linux, Windows, UNIX,
and more. It corrects and cleans up HTML and XML documents by fixing
markup errors and upgrading legacy code to modern standards.
version: determined-by-version-script
version-script: snap/utilities/set-snap-version.bash

confinement: strict
grade: stable

apps:
tidy:
command: tidy
plugs:
- home
- removable-media

parts:
tidy:
source: .
source-type: local

# For stable release build
#source-tag: '5.6.0'

plugin: cmake
configflags:
- -DCMAKE_BUILD_TYPE=Release

build-packages:
- build-essential
- xsltproc

filesets:
executables:
- bin/*
library-headers:
- include/*
library-shared:
- lib/*.so*
library-static:
- lib/*.a
pkgconfig:
- lib/pkgconfig/*
manpages:
- share/man/*
3 changes: 3 additions & 0 deletions snap/utilities/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# /snap/utilities

Here are some utilities programs to help with snap packaging.
44 changes: 44 additions & 0 deletions snap/utilities/set-snap-version.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Set snap version according to various factors
# 林博仁(Buo-ren, Lin) © 2018

set \
-o errexit \
-o errtrace \
-o nounset \
-o pipefail

init(){
set \
-o errexit \
-o nounset

local \
upstream_version \
upstream_git_revision

upstream_version="$(
head \
--lines=1 \
parts/tidy/src/version.txt
)"

upstream_git_revision="$(
git \
-C parts/tidy/src \
describe \
--always \
--dirty \
--match nothing \
| sed s/^v//
)"

printf \
-- \
'%s' \
"${upstream_version}-g${upstream_git_revision}"

exit 0
}

init "${@}"

0 comments on commit 0607ce4

Please sign in to comment.