Bash script in a ppa.

Hello all,
Bit of a Linux/Ubuntu n00b, have been using it about as long as I have been a member of this forum, but am learning pretty quick and loving every minute of it

I have created a script that uses awk and sed to convert .ust files between romaji and kana. I placed it in /usr/bin so I could call it globally, basic script such-stuffs. However, I want to be able to place this file in a ppa for install by other users via apt-get. Unfortunately, I have no idea how to do this, lol, and most of what I have found googling deals with "actual programs" that need to be compiled and such. All I want is a way that:

1. The script itself (luct) be saved into /usr/bin
2. A file used by the script named luct.lst be saved into /usr/bin.
3. Allow for updates via apt-get update.

A simple request, I think. I just have no idea where to look, lol.

Last edited by sandyd; December 1st, 2012 at 02:33 AM.
Reason: weird font

Technomancy
The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

Re: Bash script in a ppa.

your script has to create its own dotfile in user home (if it needs some local config) when it runs for the first time for that user.
consider this scenario:
- you install stuff, including putting files in homes
- you create new user
where would that new user get the files from?

imho these sed scripts should be packaged in a way that will install them somewhere in system directories, /usr/share maybe (i never packaged anything so i don't know where things exactly belong)?

Re: Bash script in a ppa.

Originally Posted by Vaphell

your script has to create its own dotfile in user home (if it needs some local config) when it runs for the first time for that user.
consider this scenario:
- you install stuff, including putting files in homes
- you create new user
where would that new user get the files from?

imho these sed scripts should be packaged in a way that will install them somewhere in system directories, /usr/share maybe (i never packaged anything so i don't know where things exactly belong)?

Holy lol, I can't escape you! OK, that is fine and true, did not consider the possibility of other users. I am using IO redirects (< and > as you well know) to write the output of certain actions to the sedscripts. Problem is I don't know how to make it write to /usr/bin without using sudo, and that end up making the resultant converted files property of root, which is not desirable. How can I do this?

...just re-read your post, you said /usr/share, can you write to that without being root?
...seems not, so original problem remains. I think I may have a solution, going to tinker a bit.

Last edited by sandyd; December 1st, 2012 at 02:34 AM.
Reason: more weird font

Technomancy
The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

but original and converted are still the exact same as if none of the sed operations had matched up. I know the outfile generated is correct because I have not changed the contents created only the location, and it did the conversions just fine before. Am I calling outfile wrong, is there some syntax I screwed up?

Nevermind, figured it out. I had copied a section of the script and pasted it again to use as a template, but did not change everything that needed changing. It now works fine, and should for any user.

Last edited by sandyd; December 1st, 2012 at 02:36 AM.
Reason: more weird font

Technomancy
The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

Re: Bash script in a ppa.

Maybe I'm not understanding something, but are you processing the output of the first awk command with sed? Also do you need the intermediate file? If you don't need the intermediate file, perhaps piping the output with the pipe command '|' would be a better way. If it's a file that needs to be held for a while until the script completes, then perhaps writing it to /tmp would be an option there instead of writing it to any /usr/bin folder.

You could change the permissions of the /usr/share/bin/<script> folder so that it's writable by everyone. But, I think that's a messy and less than ideal solution to the problem. Those /bin folders are really not intended for writing by general users.

Re: Bash script in a ppa.

Originally Posted by drmrgd

Maybe I'm not understanding something, but are you processing the output of the first awk command with sed? Also do you need the intermediate file? If you don't need the intermediate file, perhaps piping the output with the pipe command '|' would be a better way. If it's a file that needs to be held for a while until the script completes, then perhaps writing it to /tmp would be an option there instead of writing it to any /usr/bin folder.

You could change the permissions of the /usr/share/bin/<script> folder so that it's writable by everyone. But, I think that's a messy and less than ideal solution to the problem. Those /bin folders are really not intended for writing by general users.

The first awk command creates a sedscript which is used by sed to process the original file and produce the converted file. I have figured out the writing issue (I just had it write to ~ as a dotfile), and thank you for the /tmp idea, that would be perfect. My only issue now is getting it into the ppa, and the only info on that I can find is for packages compiled from source, and there is no compilation needed for this, just saving two files into /usr/bin. I know I could just instruct people to just do that, but I want to make it more or less fool-proof.

Vaphell I caught my error.

Last edited by sandyd; December 1st, 2012 at 02:37 AM.

Technomancy
The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

Re: Bash script in a ppa.

Whoops! Totally missed that 'sedscript' bit in your original posts. Sorry about that!

As for packaging it for a PPA, not sure how to do that. Out of curiosity though, had a quick look at Launchpads docs, and it seems like a bit of work and slightly complex. Not sure if you've seen this already, but here's the start of the documentation on how to set up a PPA and create a package for distribution:

Re: Bash script in a ppa.

Originally Posted by drmrgd

Whoops! Totally missed that 'sedscript' bit in your original posts. Sorry about that!

As for packaging it for a PPA, not sure how to do that. Out of curiosity though, had a quick look at Launchpads docs, and it seems like a bit of work and slightly complex. Not sure if you've seen this already, but here's the start of the documentation on how to set up a PPA and create a package for distribution:

Yes, I have been to that very page and read it. But as I said, this mainly deals with actual "programs" compiled from source, I just have 2 files (very small ones, at that) that I need saved to /usr/bin. Seems overkill to add it to a ppa, yes, but I want this to be installable and updatable like any other ubuntu package. If need be I will actually write into a program with source code, but that is even more overkill, lol.

Technomancy
The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things