Skip to content

Commit

Permalink
build: Add pre-commit hooks (#537)
Browse files Browse the repository at this point in the history
* feat(precommit): Add initial config

* fix(all): Run initial precommit hooks on all files

* feat(precommit): Add `file-contents-sorter`

* fix(packagelist): Run `file-contents-sorter` on it

* feat(precommit): Add `mixed-line-ending` for `lf`

* fix(packages): Apply `mixed-line-ending` on it

* feat(precommit): Add `shellcheck` hook

* feat(precommit): Add `shfmt` hook

* feat(shfmt): Apply to all

* fix(shfmt): Simplify code

* feat(readme): Add dev env setup info

* docs(readme): fix grammer

`on` -> `for`

* build(precommit): skip `SC2154` check

Co-authored-by: The TwilightBlood <[email protected]>
  • Loading branch information
wizard-28 and Elsie19 authored Dec 5, 2021
1 parent d008b6e commit f8c8092
Show file tree
Hide file tree
Showing 133 changed files with 721 additions and 698 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/package-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ URL: <!-- URL of the package -->
Building Guide: <!-- Link to the building guide of the package -->

<!-- Requested By: <Name> -->
<!--
<!--
Type the name of the person requesting this package to be added, if you are not the person but acting as a messenger for the person requesting it. Also mention where you got the request from. For example:
Requested By: @AnonymouslyKnown cupid on discord server
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-package-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ jobs:
env:
TERM: xterm
shell: bash

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.tar.xz
*.tar.gz
*.zip
*.png
*.png
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: file-contents-sorter
files: packagelist
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.5
hooks:
- id: shellcheck
types: []
args: ["-o", "all", "-e", "2148", "-e", "SC2033", "-e", "SC2032", "-e", "SC2034", "-e", "SC2154"]
files: '^.*\.(pacscript)$'
- id: shfmt
args: ["-i", "2", "-bn", "-ci", "-sr", "-kp", "-s"]
types: []
files: '^.*\.(pacscript)$'
# vim:set ft=yaml ts=2 sw=2 et:
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
<p align="center">
<a href="https://github.com/pacstall/pacstall-programs/tree/master/packages"><img src="https://img.shields.io/github/repo-size/pacstall/pacstall-programs?color=G&style=flat-square"></a>

<p align="center">
<b>PACSTALL PROGRAMS</b>
<br/>
This is where (as of 1.6.1 Cerise) package scripts maintained by the pacstall team are located
</p>
# Pacstall Programs

This is the default repository of pacscripts which pacstall uses to install software. You can fork this repository and add make your own package repository as long as it follows the basic structure:

```monospace
package-repository/
├── packagelist
└── packages/
└── example-package/
└── example-package.pacscript
```

You can then use `pacstall -A` command to add your repository to your `repolist`. Consult the wiki for more info.

## How to setup the environment for pacscript development

This repository maintains a certain standard of commits. To ensure that your commits are up to the standard, we use [pre-commit](https://pre-commit.com/) hooks.

Here are the development dependencies that you need to install as a developer:

| Dependency | How to install |
:-------------------------------------------:|-------------------------------------------------------------------------------------------------------------------------------------------|
| [pre-commit](https://pre-commit.com/) | `sudo pip install pre-commit` |
| [shellcheck](https://www.shellcheck.net/) | `sudo apt install shellcheck` |
| [shfmt](https://pkg.go.dev/mvdan.cc/sh/v3) | You can install using [go](https://go.dev/) or download the linux binary from their [releases page](https://github.com/mvdan/sh/releases) |

After the dependencies are installed simply clone this repository, and use `pre-commit install` to install the pre-configured hooks to your cloned repository.

Now, whenever you try to commit a patch all the configured hooks will run and block/fix your code so that it adheres to or standards.

In case for some reason (false positives etc), you want to skip the hooks commit using `git commit --no-verify`
14 changes: 7 additions & 7 deletions make-a-pacscript.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install() {
# It is recommended for paths to be condensed with
# variables and to be wrapped by double quotes
sudo make install DESTDIR="$STOWDIR/$name"

# If the package comes already compiled, use 'install'
sudo install -Dm755 $name -t "$STOWDIR/$name/usr/bin"
}
Expand Down Expand Up @@ -103,7 +103,7 @@ They are the packages needed to compile the package. They must be Ubuntu apt pac

#### `pacdeps`

It's an array of pacscripts dependencies. Should be used when the pacscript needs a package that is not present in the `apt`repositories (see soundux).
It's an array of pacscripts dependencies. Should be used when the pacscript needs a package that is not present in the `apt`repositories (see soundux).

#### `ppa`

Expand All @@ -113,15 +113,15 @@ It's an array that you can use to install ppa's. It is highly discouraged to use

It's where you put optional dependencies. Pacstall will ask the user if they want to install them before the package starts installing.

#### `breaks`
#### `breaks`

This is where you put the packages that would break if you install this package. An example would be foo and foo-git. They both install to the same files, but different sources. It is not needed unless you are making a `-git`, `-bin` or `-deb` package.

#### `replace`
#### `replace`

It's the name of the apt package that this package replaces, the user will be asked to continue before the apt package is removed.

#### `gives`
#### `gives`

The name of the apt dependency which this package provides for. Often used in tandem with `replace`.

Expand All @@ -145,7 +145,7 @@ The `build` function is what compiles the package. Use multicore as much as poss

The `install` function is what installs the package. The most important thing is to install to `$STOWDIR/$name`. An example with make would be `sudo make install DESTDIR="$STOWDIR/$name"`.

#### `postinst`
#### `postinst`

It's a series of commands that should be run after pkg is installed. If you don't need it, leave it out.

Expand All @@ -169,7 +169,7 @@ Lastly, do not ask the user for any input unless absolutely necessary. Use exter

### Updating the packagelist

Before submitting a PR please update the `packagelist` inside the root of this repository. Add your package name in alphabetic order into the file.
Before submitting a PR please update the `packagelist` inside the root of this repository. Add your package name in alphabetic order into the file.

### Opening a PR
When you complete your script, fork this repo and add your script to packages/`$name`/`$name`.pacscript. Open a PR here and make the title: "Add `$name`" with the label `Package Add`. Please do one PR per package to make sure the auto checker can test if the pacscript works.
Expand Down
6 changes: 3 additions & 3 deletions packagelist
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ fsearch-git
gcmcore-deb
geekbench-bin
git
gitblade-deb
git-delta-deb
gitblade-deb
gitfiend-deb
github-cli-deb
github-desktop
Expand Down Expand Up @@ -163,8 +163,8 @@ soundux
spacecadetpinball-git
spotify-client-deb
st-distrotube-git
stellarium
st-lukesmith-git
stellarium
surf
surf-distrotube-git
suru-icon-theme-git
Expand Down Expand Up @@ -196,8 +196,8 @@ warpinator-deb
webapp-manager
webapp-manager-deb
windscribe-cli-deb
wine64
wine-staging-git
wine64
yabridge
yad
youtube-dl-git
Expand Down
2 changes: 1 addition & 1 deletion packages/adapta-gtk-theme-git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ GtkSourceView/Gedit Color Scheme Support

> **Note:**
>
> * The color-scheme can be used in Gnome-Builder, Gnome-Sushi, Meld and Gedit if installed to
> * The color-scheme can be used in Gnome-Builder, Gnome-Sushi, Meld and Gedit if installed to
> `~/.local/share/gtksourceview-3.0/styles` or `~/.local/share/gtksourceview-4/styles` directory.
> * Currently only dark-variant is supported.
Expand Down
2 changes: 1 addition & 1 deletion packages/alacritty/alacritty.pacscript
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ install() {
sudo install -D extra/completions/_alacritty -t /usr/src/pacstall/${name}/usr/share/zsh/vendor-completions

sudo mkdir -p /usr/src/pacstall/${name}/usr/local/share/man/man1
gzip -c extra/alacritty.man | sudo tee /usr/src/pacstall/${name}/usr/local/share/man/man1/alacritty.1.gz >/dev/null
gzip -c extra/alacritty.man | sudo tee /usr/src/pacstall/${name}/usr/local/share/man/man1/alacritty.1.gz > /dev/null

sudo install -D alacritty.yml -t /usr/src/pacstall/${name}/usr/doc/share/alacritty
}
2 changes: 1 addition & 1 deletion packages/android-studio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Android Studio is the official integrated development environment (IDE) for Goog
![Screenshot of Android Studio IDE](https://developer.android.com/studio/images/studio-homepage-hero.jpg)

## License
You can read the Android Studio License Agreement on the [Android Studio Website](https://developer.android.com/studio/terms).
You can read the Android Studio License Agreement on the [Android Studio Website](https://developer.android.com/studio/terms).
2 changes: 1 addition & 1 deletion packages/android-studio/android-studio.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-studio
MimeType=application/x-extension-iml;
MimeType=application/x-extension-iml;
6 changes: 3 additions & 3 deletions packages/android-studio/android-studio.pacscript
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ install() {
sudo install -Dm644 bin/studio.png "$STOWDIR/$name/usr/share/pixmaps/$name.png"
sudo chmod -R ugo+rX "$STOWDIR/$name/opt"
}
postinst(){
postinst() {
sudo update-desktop-database -q
# Finished installation
fancy_message info "Finished installation. Please start Android Studio to configure it!"
}
removescript(){
removescript() {
sudo update-desktop-database -q
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version="2.2.0"
url="https://github.com/TheAssassin/AppImageLauncher/releases/download/v$version/${gives}_${version}-travis995.0f91801.bionic_amd64.deb"
description="Helper application for Linux distributions serving as a kind of entry point for running and integrating AppImages."
hash="f4b9db56a6ba7dd091074b14157612986a9f6a0cb3fcd230abfc8f4555c70a7f"
maintainer="WRM-42 <[email protected]>"
maintainer="WRM-42 <[email protected]>"
122 changes: 61 additions & 61 deletions packages/ardour-git/ardour-git.pacscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ depends="libqm-dsp0 libcairo2 libgcc-s1 libglib2.0-0 libglibmm-2.4-1v5 libgtkmm-
build_depends="libgio2.0-cil-dev python3 libqm-dsp-dev libcairo2-dev libglib2.0-dev libglibmm-2.4-dev libgtkmm-2.4-dev libx11-dev libxml2-dev libsoundtouch-dev libtag1-dev libatkmm-1.6-dev libaubio-dev libboost-all-dev libcairomm-1.0-dev libcppunit-dev libdbus-1-dev doxygen libfftw3-dev libflac-dev libfontconfig-dev libfreetype6-dev libgdk-pixbuf2.0-0 graphviz libgtk2.0-dev libhidapi-dev itstool libjack-jackd2-dev libarchive-dev liblo-dev libltc-dev libogg-dev libpulse-dev libsamplerate0-dev libsndfile1-dev libusb-1.0-0-dev libwebsockets-dev liblilv-dev lv2-dev libpango1.0-dev libpangomm-1.4-dev libreadline-dev librubberband-dev libserd-dev libsord-dev libsratom-dev libsuil-dev vamp-plugin-sdk libfluidsynth-dev liblrdf0-dev libraptor2-dev libcurl4-gnutls-dev"

optdepends=("xjadeo: video monitoring"
"harvid: video timeline"
"linuxaudio-new-session-manager: for session management")
"harvid: video timeline"
"linuxaudio-new-session-manager: for session management")
gives="ladspa-host, lv2-host, vst-host, vst3-host, ardour, ardour-data"
breaks="ardour, ardour-data"
url="https://github.com/Ardour/ardour.git"
Expand All @@ -20,73 +20,73 @@ pkgver() {
}
version="$(pkgver)"

prepare() {
# Patch uses vendored version of qm-dsp because qm-dsp >= 1.8.0 is not compatible
# will be applied when ubuntu starts supporting qm-dsp 1.8.0
prepare() {
# Patch uses vendored version of qm-dsp because qm-dsp >= 1.8.0 is not compatible
# will be applied when ubuntu starts supporting qm-dsp 1.8.0

# unsetting gtk2 rc (FS#54389)
sed -e '8iexport GTK2_RC_FILES=/dev/null' -i "gtk2_ardour/ardour.sh.in"
# unsetting gtk2 rc (FS#54389)
sed -e '8iexport GTK2_RC_FILES=/dev/null' -i "gtk2_ardour/ardour.sh.in"
}

build() {
# export LINKFLAGS="$LDFLAGS"
./waf configure --prefix=/usr \
--configdir=/etc \
--cxx11 \
--freedesktop \
--lxvst \
--nls \
--no-phone-home \
--optimize \
--ptformat \
--use-external-libs \
--with-backends="alsa,dummy,jack,pulseaudio"
./waf build -v
# export LINKFLAGS="$LDFLAGS"
./waf configure --prefix=/usr \
--configdir=/etc \
--cxx11 \
--freedesktop \
--lxvst \
--nls \
--no-phone-home \
--optimize \
--ptformat \
--use-external-libs \
--with-backends="alsa,dummy,jack,pulseaudio"
./waf build -v
}

install() {
sudo ./waf i18n --destdir="$STOWDIR/$name"
sudo ./waf install --destdir="$STOWDIR/$name"
wait
sudo rm "$STOWDIR/$name/usr/bin/ardour6-copy-mixer"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-copy-mixer"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-export"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-export"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-fix_bbtppq"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-fix_bbtppq"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-new_empty_session"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-new_empty_session"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-new_session"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-copy-new_session"
# man pages
sudo install -vDm 644 "ardour.1" -t "$STOWDIR/$name/usr/share/man/man1/"
# File types
sudo install -vDm 644 "build/gtk2_ardour/ardour.xml" -t "$STOWDIR/$name/usr/share/mime/packages/"

# Install .desktop
sudo install -vDm644 "build/gtk2_ardour/ardour6.desktop" "$STOWDIR/$name/usr/share/applications/"

# Icons
for size in 16 22 32 48; do
sudo install -vdm 755 "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/mimetypes"
sudo install -vDm 644 "$STOWDIR/$name/usr/share/ardour6/icons/application-x-ardour_${size}px.png" "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/mimetypes/application-x-ardour.png"
done

for size in 16 22 32 48 256 512; do
sudo install -vdm 755 "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/apps"
sudo install -vDm 644 "$STOWDIR/$name/usr/share/ardour6/resources/Ardour-icon_${size}px.png" "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/apps/ardour.png"
done
sudo ./waf i18n --destdir="$STOWDIR/$name"
sudo ./waf install --destdir="$STOWDIR/$name"

wait

sudo rm "$STOWDIR/$name/usr/bin/ardour6-copy-mixer"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-copy-mixer"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-export"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-export"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-fix_bbtppq"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-fix_bbtppq"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-new_empty_session"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-new_empty_session"
sudo rm "$STOWDIR/$name/usr/bin/ardour6-new_session"
sudo ln -sf "$STOWDIR/$name/usr/lib/ardour6/utils/ardour-util.sh" "/usr/bin/ardour6-copy-new_session"

# man pages
sudo install -vDm 644 "ardour.1" -t "$STOWDIR/$name/usr/share/man/man1/"

# File types
sudo install -vDm 644 "build/gtk2_ardour/ardour.xml" -t "$STOWDIR/$name/usr/share/mime/packages/"

# Install .desktop
sudo install -vDm644 "build/gtk2_ardour/ardour6.desktop" "$STOWDIR/$name/usr/share/applications/"

# Icons
for size in 16 22 32 48; do
sudo install -vdm 755 "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/mimetypes"
sudo install -vDm 644 "$STOWDIR/$name/usr/share/ardour6/icons/application-x-ardour_${size}px.png" "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/mimetypes/application-x-ardour.png"
done

for size in 16 22 32 48 256 512; do
sudo install -vdm 755 "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/apps"
sudo install -vDm 644 "$STOWDIR/$name/usr/share/ardour6/resources/Ardour-icon_${size}px.png" "$STOWDIR/$name/usr/share/icons/hicolor/${size}x${size}/apps/ardour.png"
done

}

removescript() {
sudo rm "/usr/bin/ardour6-copy-mixer"
sudo rm "/usr/bin/ardour6-export"
sudo rm "/usr/bin/ardour6-fix_bbtppq"
sudo rm "/usr/bin/ardour6-new_empty_session"
sudo rm "/usr/bin/ardour6-copy-new_session"
sudo rm "/usr/bin/ardour6-copy-mixer"
sudo rm "/usr/bin/ardour6-export"
sudo rm "/usr/bin/ardour6-fix_bbtppq"
sudo rm "/usr/bin/ardour6-new_empty_session"
sudo rm "/usr/bin/ardour6-copy-new_session"
}
2 changes: 1 addition & 1 deletion packages/atom-editor-deb/atom-editor-deb.pacscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version="1.58.0"
url="https://github.com/$gives/$gives/releases/download/v$version/$gives-amd64.deb"
description="The hackable text editor."
hash="4310e1af8830952f4efe59349dfaacc39b0588f72449314bd795ed469421d2d5"
maintainer="WRM-42 <[email protected]>"
maintainer="WRM-42 <[email protected]>"
Loading

0 comments on commit f8c8092

Please sign in to comment.