You are not logged in.

#1 2016-11-09 20:20:30

NewS
Member
From: Netherlands
Registered: 2016-11-08
Posts: 4

PKGBUILD review request: Sublime 3 count words

Ok, so I've decided to try and write my own PKGBUILD, just for the fun of it.

I am pretty new to all of this so it is a super-basic package that basically performs 2 simple steps:

1. Download & extract a zip from an existing Git repository.
2. Copy the output file to a specified folder.

After this, sublime 3 will count the amount of words each time a user selects text and it will print the output to the bottom-panel.

I have not written this script myself, but got it from here --> http://eyalarubas.com/count-words-in-su … ext-3.html
The same script (from the same author) is also available on git: https://gist.github.com/EyalAr/8383050

I have found myself to always install it immediately after I install sublime 3 so I thought; why not make it into an Arch AUR-package?

I would love to hear some thoughts on:

- The PKGBUILD file itself; any thoughts on necessary / optional improvements?

- The usefulness of the package; as I read that this is a requirement for submitting a package to the AUR.

--

PS: the license is currently labeled as unknown. If this PKGBUILD would prove to be considered 'useful' and 'correct' I will contact the original author of the script that is applied by this package to get this sorted. Until then, I figured; no need yet to bother him with it.


"Stay hungry - Stay foolish"

Offline

#2 2016-11-09 20:35:46

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: PKGBUILD review request: Sublime 3 count words

You haven't posted the PKGBUILD for us to look at smile


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2016-11-09 21:13:58

NewS
Member
From: Netherlands
Registered: 2016-11-08
Posts: 4

Re: PKGBUILD review request: Sublime 3 count words

Haha, see, knew I forgot something.

The actual PKGBUILD would probably be useful yes ;-).

Here it is:

pkgname=sublime-text-3-wordcount-plugin
pkgdesc='Prints the number of selected words to Sublime-text-3 bottom panel.'
pkgver=1
pkgrel=1
arch=('any')
url="https://gist.github.com/EyalAr/8383050"
license=('unknown')
depends=('sublime-text-dev>=3.0' 'sublime-text-dev<4.0')
source=($pkgname::https://gist.github.com/EyalAr/8383050/archive/dee61bb50dc02af9eef24425770c882c5a780a10.zip)
md5sums=('48e37e4c4f9f9ec32c8dd26ca1597b9b')

prepare() {
  destinationfolder=$(eval echo ~/.config/sublime-text-3/Packages/User)
  if [ ! -d $destinationfolder ]; then
    echo "$destinationfolder does not exist, please verify that Sublime Text 3 is properly installed."
    echo "Note: This package might not work on some customized Sublime setups."
    echo "If package fails, you can try visiting the original Git; https://gist.github.com/EyalAr/8383050/"
    exit
  fi
}

package() {
  destinationfolder=$(eval echo ~/.config/sublime-text-3/Packages/User)
  `cp "$srcdir/8383050-dee61bb50dc02af9eef24425770c882c5a780a10/count_words_in_selection.py" "$destinationfolder/count_words_in_selection.py"`
}

"Stay hungry - Stay foolish"

Offline

#4 2016-11-09 21:34:12

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: PKGBUILD review request: Sublime 3 count words

PKGBUILD's should never modify anything in a users home folder.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2016-11-09 21:44:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: PKGBUILD review request: Sublime 3 count words

I agree with the above - a PKGBUILD should definitely not try to do anything in a user's home directory.

Further, this fails completely to make a package.  Or, more precisely, it creates a completely empty package as nothing is in the pkgdir.

Assuming these are fixed, you can also get rid of that whole prepare function.  It doesn't do anything.

Also, the following three lines are equivalent - don't use the first two as they just create nested subshells for no reason:

var=$(eval echo /some/path)
var=$(echo /some/path)
var=/some/path

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2016-11-09 22:19:18

NewS
Member
From: Netherlands
Registered: 2016-11-08
Posts: 4

Re: PKGBUILD review request: Sublime 3 count words

Ok, so there are definitely a lot of wrongs with this first try.

Which is ok, as it was the main reason for requesting a quick review. Also, I understand the application of the python-script as a Sublime-add-on function might not be the best foundation for building a package. 

A few questions that remain though are;

- Are function-add-on's ever offered as a package in AUR, or would this normally require addressing the maintainers of the base-package (Sublime Text) to request the extra functionality to be build in? (I thought I saw some similar add-functionality type packages in the AUR before, but can't seem to locate them right now, so just wondering).

- If these kind of add-on's are sometimes offered as a package; then what in this case would be the way to go? If copying the file to the designated folder via PKGBUILD is bad practice, then how to get the file to its destination? In order for the python-file to work it has to be placed in the specified folder for Sublime to be able to pick up on it.


"Stay hungry - Stay foolish"

Offline

#7 2016-11-09 22:32:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: PKGBUILD review request: Sublime 3 count words

NewS wrote:

- Are function-add-on's ever offered as a package in AUR

Yes, they frequently are, see many vim plugin packages.  I think the utility of many of these is debatable as one could just as easily download the vim file and put it in the appropriate place in their ~/.vim directory.

NewS wrote:

- then what in this case would be the way to go?

That depends on how sublime-text works.  Building on the vim example, extensions, plugins, themes, etc can be placed under ~/.vim/ but vim will also check for system extensions under /usr/share/vim/.  This is common for *nix software to allow both user-specific configs and extensions as well as system-wide configs and extensions.  I have no idea if this is how sublime works (and I will not find out as I'm ethically opposed to the license violations perpetuated by most of it's users who get it from the AUR).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2016-11-10 01:23:33

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: PKGBUILD review request: Sublime 3 count words

Trilby wrote:
NewS wrote:

- Are function-add-on's ever offered as a package in AUR

Yes, they frequently are, see many vim plugin packages.  I think the utility of many of these is debatable as one could just as easily download the vim file and put it in the appropriate place in their ~/.vim directory.

For the same reason you put anything in a package manager.

Of course, vim does have several plugin managers already, but I don't see why it is completely unreasonable for someone to want to have only one package manager. smile

Also, global plugins are, well, global. So if you have multiple users who all need the same vim plugins (or you have the incredible habit of running `sudo vim` instead of `sudoedit` but maybe hat shouldn't count!)...


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2016-11-10 02:01:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: PKGBUILD review request: Sublime 3 count words

I didn't say there's no reason to have these plugins as packages.  But I have seen some (I don't know if these are in the AUR, but they are downloadable as "packages" from the authors' sites) where the sum total of the code is about 3 or 4 lines.  A package for these is silly when one could just say "copy these lines to your vimrc".  We don't have a package for "vim-syntax-enabling-rc-command", people just put "syntax on" in their vimrc.

Between the two extremes of large tools and vimrc one-liners there is a wide range - and either there is a clear objective line between what should be packaged and what should not, or there is a collection of bits that are of debatable worth as packages.  To me, the second of those interpretations seems more reasonable as I'd have no idea where to place the line.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2016-11-10 02:28:33

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: PKGBUILD review request: Sublime 3 count words

I didn't realize anyone was silly enough to turn a viml one-liner into a "plugin".

Whether this counts as something trivial enough to not be worth the effort of a plugin/AUR package... I guess I am not sure either. Although I feel confident the vim plugins I have installed are substantial enough. big_smile


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB