FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux User Repository

 
 
LinkBack Thread Tools
 
Old 05-21-2012, 10:52 PM
Jorge Barroso
 
Default postinstall script and local user directory

Hello, I need a little help with a postinstall script, the script should
make automatically a few postinstall steps on the LMD installation, qhat
the script should make it's to detect if a directory called .LMD on the
home directory exists, if it exists, it shows an informative message, if it
doesn't exist it makes it.
All right the problem is: It acts over the root directory, and I want it to
act over the user normal directory (/home/'user')
For you tu understand what I mean, this is the code:

http://pastebin.com/57L2Jt2P <- With that it looks for a directory called
"~", not "home" directory

I als otried with an array, and it was here when it used root like home
directory, and not the local user directory:

http://pastebin.com/TCh94dC9

I want the script to do the same that it makes with the second paste bin,
but not in root, it should be, in my pc for example, on /home/jorge...

Thanks in advance
 
Old 05-21-2012, 11:45 PM
Myles English
 
Default postinstall script and local user directory

>> On Tue, 22 May 2012 00:52:00 +0200, Jorge Barroso said:

> Hello, I need a little help with a postinstall script, the script should
> make automatically a few postinstall steps on the LMD installation, qhat
> the script should make it's to detect if a directory called .LMD on the
> home directory exists, if it exists, it shows an informative message, if it
> doesn't exist it makes it.
> All right the problem is: It acts over the root directory, and I want it to
> act over the user normal directory (/home/'user')
> For you tu understand what I mean, this is the code:

> http://pastebin.com/57L2Jt2P <- With that it looks for a directory called
> "~", not "home" directory

> I als otried with an array, and it was here when it used root like home
> directory, and not the local user directory:

> http://pastebin.com/TCh94dC9

> I want the script to do the same that it makes with the second paste bin,
> but not in root, it should be, in my pc for example, on /home/jorge...

> Thanks in advance

Hi Jorge,

Try "/home/$USER" instead of "~".

--
`--[ Myles ]
 
Old 05-21-2012, 11:45 PM
Auguste Pop
 
Default postinstall script and local user directory

On Tue, May 22, 2012 at 6:52 AM, Jorge Barroso
<jorge.barroso.11@gmail.com> wrote:
> Hello, I need a little help with a postinstall script, the script should
> make automatically a few postinstall steps on the LMD installation, qhat
> the script should make it's to detect if a directory called .LMD on the
> home directory exists, if it exists, it shows an informative message, if it
> doesn't exist it makes it.
> All right the problem is: It acts over the root directory, and I want it to
> act over the user normal directory (/home/'user')
> For you tu understand what I mean, this is the code:
>
> http://pastebin.com/57L2Jt2P <- With that it looks for a directory called
> "~", not "home" directory
>
> I als otried with an array, and it was here when it used root like home
> directory, and not the local user directory:
>
> http://pastebin.com/TCh94dC9
>
> I want the script to do the same that it makes with the second paste bin,
> but not in root, it should be, in my pc for example, on /home/jorge...
>
> Thanks in advance

i suggest installing a script doing what you want to do in $HOME
directory and print out an instruction in post_install function to
remind the user to run that script as normal user without sudo.

inside the script, $HOME can be used, or ~ too.

regards,
 
Old 05-21-2012, 11:52 PM
Jorge Barroso
 
Default postinstall script and local user directory

2012/5/22 Myles English <mylesenglish@gmail.com>

>
>
> >Hi Jorge,
>
> >Try "/home/$USER" instead of "~".
>
> --
> `--[ Myles ]
>

It takes it like /home/root... :S thanks even though
 
Old 05-21-2012, 11:56 PM
Jorge Barroso
 
Default postinstall script and local user directory

2012/5/22 Auguste Pop <auguste@gmail.com>

>
> >i suggest installing a script doing what you want to do in $HOME
> >directory and print out an instruction in post_install function to
> >remind the user to run that script as normal user without sudo.
>
> >inside the script, $HOME can be used, or ~ too.
>

Thanks Auguste, I'd like to do it all in the postinstall even though, I'll
try a little changes on it and I'll see what can I do and if I see it
doesn't works... I'll keep that on account

Good Idea, I wasn't thought about that
 
Old 05-22-2012, 01:22 AM
rafael ff1
 
Default postinstall script and local user directory

2012/5/21 Jorge Barroso <jorge.barroso.11@gmail.com>:
> 2012/5/22 Auguste Pop <auguste@gmail.com>
>
>>
>> >i suggest installing a script doing what you want to do in $HOME
>> >directory and print out an instruction in post_install function to
>> >remind the user to run that script as normal user without sudo.
>>
>> >inside the script, $HOME can be used, or ~ too.
>>
>
> Thanks Auguste, I'd like to do it all in the postinstall even though, I'll
> try a little changes on it and I'll see what can I do and if I see it
> doesn't works... I'll keep that on account
>
> Good Idea, I wasn't thought about that


Since your first post, I was not comfortable having a install script
looking for a normal user's home folder, because you can always find
yourself in the situation that a user might be added after LMD is
installed. (not being harsh, just not a good idea, IMO)

So, I came up with the idea of applying a patch in the 'ldm' script.
With this patch, 'lmd' would verify if the user have '~/.LMD'
everytime, right before starting the gtkdialog. See my diff:


--- src/usr/local/bin/lmd 2011-07-03 17:19:24.000000000 -0300
+++ pkg/usr/bin/lmd 2012-05-21 22:07:06.587084106 -0300
@@ -323,6 +323,7 @@

if [ -z $1 ];
then
+ [ ! -d ~/.LMD ] && lmd -reconf
gtkdialog --program=MAIN_DIALOG
fi
echo $1


I added the following line the PKGBUILD, after installing lmd to '$pkgdir':

sed -e '325s#then#then
[ ! -d ~/.LMD ] && lmd -reconf#' -i
"${pkgdir}"/usr/bin/lmd

which just replace in line 325 the "then", adding one more line with
the command command you provided.

Hope it helps.

Rafael
 
Old 05-22-2012, 12:13 PM
Jorge Barroso
 
Default postinstall script and local user directory

2012/5/22 rafael ff1 <rafael.f.f1@gmail.com>

> >Since your first post, I was not comfortable having a install script
> >looking for a normal user's home folder, because you can always find
> >yourself in the situation that a user might be added after LMD is
> >installed. (not being harsh, just not a good idea, IMO)
>
> >So, I came up with the idea of applying a patch in the 'ldm' script.
> >With this patch, 'lmd' would verify if the user have '~/.LMD'
> >everytime, right before starting the gtkdialog. See my diff:
>
>
> >--- src/usr/local/bin/lmd 2011-07-03 17:19:24.000000000 -0300
> >+++ pkg/usr/bin/lmd 2012-05-21 22:07:06.587084106 -0300
> >@@ -323,6 +323,7 @@
>
> >if [ -z $1 ];
> <then
> >+ [ ! -d ~/.LMD ] && lmd -reconf
> > gtkdialog --program=MAIN_DIALOG
> > fi
> > echo $1
>
>
> >I added the following line the PKGBUILD, after installing lmd to
> '$pkgdir':
>
> > sed -e '325s#then#then
[ ! -d ~/.LMD ] && lmd -reconf#' -i
> >"${pkgdir}"/usr/bin/lmd
>
> >which just replace in line 325 the "then", adding one more line with
> >the command command you provided.
>
> >Hope it helps.
>
> Rafael
>

Mmm yes it helps, I know what you mean, adding a line on the own lmd binary
script that checks if .LMD already exists... any time you run lmd an for
any user Not bad but... if fear I don't know so sed "command", so I
can't comprehend where are you exactly telling me that I should put that
or... well :S sorry, could you explain it a little more :S

My bigest thanks friend
 
Old 05-22-2012, 03:56 PM
rafael ff1
 
Default postinstall script and local user directory

2012/5/22 Jorge Barroso <jorge.barroso.11@gmail.com>:
> 2012/5/22 rafael ff1 <rafael.f.f1@gmail.com>
>
>>
>> > sed -e '325s#then#then
[ ! -d ~/.LMD ] && lmd -reconf#' -i
>> >"${pkgdir}"/usr/bin/lmd
>>
>
> Mmm yes it helps, I know what you mean, adding a line on the own lmd binary
> script that checks if .LMD already exists... any time you run lmd an for
> any user Not bad but... if fear I don't know so sed "command", so I
> can't comprehend where are you exactly telling me that I should put that
> or... well :S sorry, could you explain it a little more :S
>
> My bigest thanks friend

If you're not comfortable with sed, you can always create a patch
using 'diff -u foo1 bar2 > foo-bar.patch' and add to source=() ... But
since we are here:

My sed command executes an expression in an input text. The input text
is from the file 'lmd'. I also added the flag '-i' so the output of
this command will not go to stdout, but directly to the input file.
So, it will not just read the file, but alter/write too.

The expression structure is basically 'A#B#C#', where #s are
delimiters; A is a specific line number that sed will look and
replace; B is the regexp to look (and to be replaced) in that line in
A; and C is the replacement regexp that I want to replace B. Please
note that '
' is a newline character and ' ' is a tab character.

So, as I mentioned before, I replaced the string 'then' in line 325
with the new line/command you provided.

'sed' can do much more than that. Man page and google can help a lot.

Cheers,

Rafael Ferreira
 
Old 05-22-2012, 05:31 PM
Jorge Barroso
 
Default postinstall script and local user directory

2012/5/22 rafael ff1 <rafael.f.f1@gmail.com>

>
> >If you're not comfortable with sed, you can always create a patch
> >using 'diff -u foo1 bar2 > foo-bar.patch' and add to source=() ... But
> >since we are here:
>
> >My sed command executes an expression in an input text. The input text
> >is from the file 'lmd'. I also added the flag '-i' so the output of
> >this command will not go to stdout, but directly to the input file.
> >So, it will not just read the file, but alter/write too.
>
> >The expression structure is basically 'A#B#C#', where #s are
> >delimiters; A is a specific line number that sed will look and
> >replace; B is the regexp to look (and to be replaced) in that line in
> >A; and C is the replacement regexp that I want to replace B. Please
> >note that '
' is a newline character and ' ' is a tab character.
>
> >So, as I mentioned before, I replaced the string 'then' in line 325
> >with the new line/command you provided.
>
> >'sed' can do much more than that. Man page and google can help a lot.
>

Oh, ok, yeah I read a bit on the man page and o a webpage, but it's too
large, it has so many functions. Eitherway, I understand what you said now.
Then, on my PKGBUILD, I should modify the package()... in the next way?:

package() {
cd "${srcdir}"

tar xf data.tar.gz
mkdir -p "${pkgdir}/usr/"
cp -r "${srcdir}/./usr/local/bin" "${pkgdir}/usr/bin"
cp -r "${srcdir}/./usr/share" "${pkgdir}/usr/share"

sed -e '325s#then#then
[ ! -d ~/.LMD ] && lmd -reconf#' -i
"${pkgdir}"/usr/bin/lmd

chmod +x "${pkgdir}/usr/bin"/*
sed 's|usr/local|usr|' -i "${pkgdir}/usr/bin"/*
sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/applications/LMD.desktop"
sed 's|usr/local|usr|' -i
"${pkgdir}/usr/share/doc/linux-manga-downloader/copyright"
sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/icons/pen.png"
sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/lmd/langs/ca_ES"
sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/lmd/langs/es_ES"
}
 
Old 05-22-2012, 05:37 PM
rafael ff1
 
Default postinstall script and local user directory

2012/5/22 Jorge Barroso <jorge.barroso.11@gmail.com>:
> 2012/5/22 rafael ff1 <rafael.f.f1@gmail.com>
>
>>
>> >If you're not comfortable with sed, you can always create a patch
>> >using 'diff -u foo1 bar2 > foo-bar.patch' and add to source=() ... But
>> >since we are here:
>>
>> >My sed command executes an expression in an input text. The input text
>> >is from the file 'lmd'. I also added the flag '-i' so the output of
>> >this command will not go to stdout, but directly to the input file.
>> >So, it will not just read the file, but alter/write too.
>>
>> >The expression structure is basically 'A#B#C#', where #s are
>> >delimiters; A is a specific line number that sed will look and
>> >replace; B is the regexp to look (and to be replaced) in that line in
>> >A; and C is the replacement regexp that I want to replace B. Please
>> >note that '
' is a newline character and ' ' is a tab character.
>>
>> >So, as I mentioned before, I replaced the string 'then' in line 325
>> >with the new line/command you provided.
>>
>> >'sed' can do much more than that. Man page and google can help a lot.
>>
>
> Oh, ok, yeah I read a bit on the man page and o a webpage, but it's too
> large, it has so many functions. Eitherway, I understand what you said now.
> Then, on my PKGBUILD, I should modify the package()... in the next way?:
>
> package() {
> cd "${srcdir}"
>
> tar xf data.tar.gz
> mkdir -p "${pkgdir}/usr/"
> cp -r "${srcdir}/./usr/local/bin" "${pkgdir}/usr/bin"
> cp -r "${srcdir}/./usr/share" "${pkgdir}/usr/share"
>
> sed -e '325s#then#then
[ ! -d ~/.LMD ] && lmd -reconf#' -i
> "${pkgdir}"/usr/bin/lmd
>
> chmod +x "${pkgdir}/usr/bin"/*
> sed 's|usr/local|usr|' -i "${pkgdir}/usr/bin"/*
> sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/applications/LMD.desktop"
> sed 's|usr/local|usr|' -i
> "${pkgdir}/usr/share/doc/linux-manga-downloader/copyright"
> sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/icons/pen.png"
> sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/lmd/langs/ca_ES"
> sed 's|usr/local|usr|' -i "${pkgdir}/usr/share/lmd/langs/es_ES"
> }

Looks good. Try to build the package and then verify if
pkg/usr/bin/lmd has the command added with sed. Case yes, then you're
good to go.

Rafael Ferreira
 

Thread Tools




All times are GMT. The time now is 10:16 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org