You are not logged in.

#1 2012-09-09 16:51:41

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

PKGBUILD for Unix Shell code

Okay so I wanted to make a PKGBUILD for the Family Search Indexing program--the actual program is written in Java, but FamilySearch.org made a install script for us Linux folks, which I thought was awfully nice of them; but I'm not sure how to create a PKGBUILD for such a program since the usual

build() { 
cd "${srcdir}/${pkgname}-${pkgver}"
make
}

isn't going to work since this is a Unix Shell script that needs to run and not regular source code.  In addition, by default the script installs the Indexing program to your $HOME directory.  I thought about just doing some like this

build() {
cd ${srcdir}/${pkgname}-${pkgver}"

sh <programname.sh>
}

but I'm not sure if that is too unorthodox or if there already is method for building Unix Shell based programs or something along those lines.  Any suggestions?  (I've searched  google, the wiki, the forum, and the AUR--though I can never seem to find packages that deal with shell scripts, even though I know that there are some out there, when I search the AUR--extensively, so I'd really appreciate some pointers.)


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#2 2012-09-09 17:08:40

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: PKGBUILD for Unix Shell code

Firstly, Arch packages can't touch your $HOME - a definite no-no.

Next, this may be of use to you.

Most important, though, would be to read through the install script in detail, making sure you understand what it's putting where, and whether you can pass alternative install locations to it. Running it in its default state, as you have suggested above, obviously isn't going to work.

Offline

#3 2012-09-09 17:46:43

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: PKGBUILD for Unix Shell code

tomk wrote:

Firstly, Arch packages can't touch your $HOME - a definite no-no.

Next, this may be of use to you.

Most important, though, would be to read through the install script in detail, making sure you understand what it's putting where, and whether you can pass alternative install locations to it. Running it in its default state, as you have suggested above, obviously isn't going to work.


Why can't they, though?  Is it bad form, or just a bad idea?  Is there an article that I could read about it?  I'll google it, I guess.

And what about shell scripts in general?  Like what if I wrote a really totally awesome script and wanted to share it with the whole Arch Linux community? (Not saying that I do have a script like that or that I could produce one, just a general 'what if' kind of thing)

Last edited by lspci (2012-09-09 17:48:05)


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#4 2012-09-09 18:42:51

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 5,363

Re: PKGBUILD for Unix Shell code


Sakura:-
Mobo: ASUS P8Z77-V PRO // Processor: Intel Core i7-3770K 3.4GHz // GFX: nVidia GeForce GTX 970 Ti // RAM: 32GB (4x 8GB) Corsair DDR3 (@ 2133MHz) // Storage: 1x 3TB Seagate SATAII 5x 1TB Samsung SATAII, 2x 120GB Corsair SSD

Offline

#5 2012-09-09 20:44:25

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: PKGBUILD for Unix Shell code

If you decided your awesome script deserved to be packaged, just write a PKGBUILD that installs it in /usr/bin.

Offline

#6 2012-09-09 21:05:31

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,991
Website

Re: PKGBUILD for Unix Shell code

Couldn't you just change line 15 of the script to change the db_home variable to something more suitable that $HOME?  Perhaps /opt/local/whatever-the-appname-is/ would be good, or /usr/share/appname/


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#7 2012-09-10 02:25:39

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: PKGBUILD for Unix Shell code

Trilby wrote:

Couldn't you just change line 15 of the script to change the db_home variable to something more suitable that $HOME?  Perhaps /opt/local/whatever-the-appname-is/ would be good, or /usr/share/appname/


That's what I plan on doing.  Except when I tried that it gave me some kind of error saying that some file had been corrupted.  But I think that may have to do with Java and not with the actual script.


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#8 2012-09-10 11:45:36

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,991
Website

Re: PKGBUILD for Unix Shell code

lspci wrote:

when I tried that it gave me some kind of error saying that some file had been corrupted.  But I think that may have to do with Java and not with the actual script.

You'll have to make sure the change leaves the script at the exact same length (bytes, not lines).  Remove some blank lines, or add a blank/comment line to adjust as necessary.

Alternately, check the length of the file (in bytes) before your edit, then after your edit and adjust the byte offset listed on line 482.

Or - as yet another alternative - temporarily reset the "$HOME" environment variable from the pkgbuild, then run the script as is.

Last edited by Trilby (2012-09-10 11:48:02)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#9 2012-09-15 11:53:00

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: PKGBUILD for Unix Shell code

Trilby wrote:
lspci wrote:

when I tried that it gave me some kind of error saying that some file had been corrupted.  But I think that may have to do with Java and not with the actual script.

You'll have to make sure the change leaves the script at the exact same length (bytes, not lines).  Remove some blank lines, or add a blank/comment line to adjust as necessary.

Alternately, check the length of the file (in bytes) before your edit, then after your edit and adjust the byte offset listed on line 482.

Or - as yet another alternative - temporarily reset the "$HOME" environment variable from the pkgbuild, then run the script as is.

Okay, so here's a small script that should move all of the stuff created in the $HOME directory by the setup script from $HOME to /opt/familysearch/indexing/
Take a look at it and let me know if it looks good enough or if I ought to change anything; I have a feeling that I'll need to write an uninstall script as well, but I'm not really sure. 

$ cat correct-install.sh

if [[ $UID -eq 0 ]] ; then
    printf "\e[1;31mSorry:\e[0m Should not be run as root, all necessary root-like actions will be handled by sudo.\n";
    exit;
else
   sudo install -dm775 /home/$USER/.FamilySearchIndexing /opt/familysearch/indexing/;
   rm -R /home/$USER/.FamilySearchIndexing;
   cd /opt/familysearch/indexing/;
   cd .FamilySearchIndexing;
   cd indexing.familysearch.org;
   cp -R * /opt/familysearch/indexing/;
   rm -R /opt/familysearch/indexing/.FamilySearchIndexing;
   printf "\n\e[1;32mDone!\e[0m\n";

fi

Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#10 2012-09-15 12:28:40

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: PKGBUILD for Unix Shell code

Ehmm... OK, but that's only of use if everything gets installed in $HOME in the first place. Have you given up on packaging it correctly?

Offline

#11 2012-09-17 13:25:48

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: PKGBUILD for Unix Shell code

tomk wrote:

Ehmm... OK, but that's only of use if everything gets installed in $HOME in the first place. Have you given up on packaging it correctly?

The shell script provided by new.familysearch.org installs everything to the $HOME directory, so this moves all of that to the /opt directory.  Do you mean following the Java packaging guidelines, or other guidelines? 


PKGBUILD

# Maintainer: lspci <agm2819[a  t] g     m a i l [  d  o t ]c o  m>

pkgname=familysearch-indexing
pkgver=3.14.0
pkgrel=1
pkgdesc="FamilySearch's indexing program used to extract data from digitized vital records for genealogical research."
arch=('i686' 'x86_64')
url="https://familysearch.org/volunteer/indexing"
license=('')
groups=()
depends=('java-environment>=6')
makedepends=('sh')
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=familysearch.install
#changelog=
source=("https://sites.google.com/site/aarchived/s/")

familysearch.install

post_install() {

    printf "\e[1;31mNote:\e[0mTo finish the installation process please run '/opt/familysearch/correct-installation.sh\n"
}

post_upgrade() {
    printf "\e[1;31mNote:\e[0mTo finish the installation process please run '/opt/familysearch/correct-installation.sh\n"
}

Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#12 2012-09-17 13:36:03

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: PKGBUILD for Unix Shell code

So basically, you're ignoring the whole "packages should never touch $HOME" thing, installing it in $HOME, then telling the user to rip it out again, and stick it in /opt using your script....

Well, whatever makes you happy smile I'm sure I don't need to say this, but you won't do anything silly like submit this to the AUR.. right?

Finally, that's only half a PKGBUILD there - you won't get far without at least a package() function.

Offline

#13 2012-09-17 14:14:09

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,991
Website

Re: PKGBUILD for Unix Shell code

I guess my three options were just ignored in favor of doing something more involved and less appropriate.  Sometimes I wonder why I bother.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#14 2012-09-17 15:41:41

fsckd
Forum Moderator
Registered: 2009-06-15
Posts: 3,564

Re: PKGBUILD for Unix Shell code

For the PKGBUILD to work correctly it would have to "install" to $pkgdir, not $HOME. Your PKGBUILD will result in an empty package as the script will install the files outside of the build directory. Please see man PKGBUILD and the various wiki articles.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#15 2012-09-20 20:10:40

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: PKGBUILD for Unix Shell code

Trilby wrote:

I guess my three options were just ignored in favor of doing something more involved and less appropriate.  Sometimes I wonder why I bother.

Sorry, I'm super new to PKGBUILDs; I'll take another look at your suggestions Trilby. 

fsckd wrote:

For the PKGBUILD to work correctly it would have to "install" to $pkgdir, not $HOME. Your PKGBUILD will result in an empty package as the script will install the files outside of the build directory. Please see man PKGBUILD and the various wiki articles.

Okay, uhh.. once again with the new to this thing, and I'll take a look at that. 

tomk wrote:

So basically, you're ignoring the whole "packages should never touch $HOME" thing, installing it in $HOME, then telling the user to rip it out again, and stick it in /opt using your script....

Well, whatever makes you happy smile I'm sure I don't need to say this, but you won't do anything silly like submit this to the AUR.. right?

Finally, that's only half a PKGBUILD there - you won't get far without at least a package() function.

Uh... k.  I'll try to get it to work... I guess, I dunno.  Brain functions aren't present at the moment so I'll take a look at this post again later on.


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

Board footer

Powered by FluxBB