.TAR AutoInstalavel Linux package

0

I'm following this procedure to create a file compactado autoexecutável but I'm not succeeding, is there something missing?

  • Compact the files to pacote.tar.gz
  • I create pacote.sh file with the following content:
  • #!/bin/sh
    skip=4
    tail +$skip $0 1 | tar -xzf - -C /
    exit
    
  • Concatenate with cat pacote.tar.gz >> pacote.sh
  • To test, I run:

    bash pacote.sh
    

    And I get the following error:

      
        

    tail: could not open "+4" to read: File or directory not found tail: could not open "1" to read: File     or directory not found

      
         

    gzip: stdin: not in gzip format tar: Child returned status 1 tar:   Error is not recoverable: exiting now

        
    asked by anonymous 13.09.2018 / 16:21

    1 answer

    1

    You are using tail +$skip $0 1 , and since the value of skip is 4 , the result is tail +4 $0 1 .

    In this way, he thinks that +4 and 1 are filenames, hence the errors "could not open" +4 "for reading" and "was not Possible to open "1" for reading ".

    The right thing is to use the -n option so that it skips lines. And remove 1 also, which seems to be "over" there:

    tail -n +$skip $0
    

    Another detail is that the output of the tail command should be passed as input to the following command ( tar ), and this is done through pipe ( | ): / p>

    tail -n +$skip $0 | tar ...
    

    Anyway, I do not know if it's a good thing to just rely on the number of lines to skip (because if the script changes, the number of lines to skip will also change, and then you'll have to keep changing the script all the time).

    Maybe a markup (any string indicating where content starts) is best. See an example in this article .

        
    13.09.2018 / 18:41