Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Bash script in a ppa.

  1. #1
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    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

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,247
    Distro
    Ubuntu 10.04 Lucid Lynx

    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)?
    Last edited by Vaphell; November 30th, 2012 at 11:10 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash script in a ppa.

    Quote Originally Posted by Vaphell View Post
    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?

    Example
    [/FONT]
    Code:
    #!/bin/bash
    awk '{yada yada}' < infile > outfile
    sed -f outfile original > converted
    
    [FONT=Courier New]
    Running it with sudo makes converted property of root.

    ...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

  4. #4
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,247
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Bash script in a ppa.

    my 'score' should tell you that i lurk here quite often

    well, i don't know what your setup looks like.
    What is the minimal set of files that is needed to produce the working setup? I see you generate sed files so they don't count. Script+infile+original?
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  5. #5
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash script in a ppa.

    Quote Originally Posted by Vaphell View Post
    my 'score' should tell you that i lurk here quite often

    well, i don't know what your setup looks like.
    What is the minimal set of files that is needed to produce the working setup? I see you generate sed files so they don't count. Script+infile+original?
    Script and infile. Original is chosen via a prompt within the script itself and will vary from use to use. I tried

    Code:
    #!/bin/bash
    awk '{yada yada}' < infile > ~/.outfile
    sed -f ~/.outfile original > converted
    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

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,247
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Bash script in a ppa.

    i don't see anything wrong with that code.
    Are you sure there are no \r chars that mess things up or something like that?
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  7. #7
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    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.

  8. #8
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash script in a ppa.

    Quote Originally Posted by drmrgd View Post
    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

  9. #9
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    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:

    https://help.launchpad.net/Packaging...w&redirect=PPA

    Hope that helps!

  10. #10
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash script in a ppa.

    Quote Originally Posted by drmrgd View Post
    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:

    https://help.launchpad.net/Packaging...w&redirect=PPA

    Hope that helps!

    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

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •