Author Topic: Need to add scriptlet to %post  (Read 1453 times)

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11037
  • MLUs Forever!
Re: Need to add scriptlet to %post
« Reply #15 on: June 28, 2012, 11:05:57 AM »
that was an older version of determining system users, the correct version is this one:
Code: [Select]
SYSUSERS=`cat /etc/passwd | grep "/home/.*/bash" |grep "[0-9][0-9][0-9]" |cut -d: -f1`

then you will not get the mysql nor the named but instead all system users but root, see addlocale for details.
best,
-p.

Just wondering ........  as PCLOS only uses user ids from 500 could/should the above be

SYSUSERS=`cat /etc/passwd | grep "/home/.*/bash" |grep "[5-9][0-9][0-9]" |cut -d: -f1`

or even

SYSUSERS=`cat /etc/passwd | grep "/home/.*/bash" |grep "[5-9]" |cut -d: -f1`

Makes sense but then you'd never find O-P's user ID. He told us some months ago that he still numbers his users starting with 1000.


That might be a good thing   ;D  ;D  ;D
MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8816
  • Aurum nostrum non est aurum vulgi.
Re: Need to add scriptlet to %post
« Reply #16 on: June 28, 2012, 09:38:38 PM »
I am still stuck with Synaptic still throwing errors ... and I got a headache ... and it's only 11:30 in the morning!

What I did was reuse codes made available on this thread and ...

This ought to be a good exercise for us - either the gurus and the learners. What I intend to do are:

(1) list available users on the system - CHECKED
(2) check if the target folders/files exist - CHECKED
(3) create symlinks - CHECKED

Download: Veromix Plasma Applet

The package builds fine and the focus of our attention should only be on %post. BTW I separated the scriptlet as Source1: check-n-symlink.sh on the SOURCE folder and that's the scriptlet that should do those items listed above.

I'm sure this is a simple exercise for some of our gurus and I am pretty sure it would also benefit us learning so much on our time spent here at PCLinuxOS.

Happy hunting!
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline ghostbunny

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1193
Re: Need to add scriptlet to %post
« Reply #17 on: June 29, 2012, 06:00:57 AM »
Hi Archie,

i "tweaked" you script a bit but i cant test it, i do not have a kde install for testing. here the link if you want to test it

http://dl.dropbox.com/u/53507975/check-n-symlink.sh

it filers now things like mysql user, checks the files and folders.

and btw. i made it "recycleable" so its possible to use it for other plasmoids which need the same procedure.

but read in the file i made some comments. read it also for how to change the call of the script in the spec file.

happy testing ;)
« Last Edit: June 29, 2012, 06:04:12 AM by ghostbunny »
The full life is a big mess

PS:
I'm German. Sorry because of possible mistakes in my written messages xD


Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8816
  • Aurum nostrum non est aurum vulgi.
Re: Need to add scriptlet to %post
« Reply #18 on: June 29, 2012, 06:13:35 AM »
Hi Archie,

i "tweaked" you script a bit but i cant test it, i do not have a kde install for testing. here the link if you want to test it

http://dl.dropbox.com/u/53507975/check-n-symlink.sh

it filers now things like mysql user, checks the files and folders.

and btw. i made it "recycleable" so its possible to use it for other plasmoids which need the same procedure.

but read in the file i made some comments. read it also for how to change the call of the script in the spec file.

happy testing ;)


Thanks for the "tweak", ghostbunny. I'll rebuild the app and test it. I'll post whatever results Synaptic throws back.

UPDATE:

Thought you might like to know ...

Code: [Select]
While installing package plasma-applet-veromix-0.18.3-1_archie_2012:

.//home/archie32/Temporary/src/rpm/SOURCES/check-n-symlink.sh: line 42: unexpected EOF while looking for matching `''
.//home/archie32/Temporary/src/rpm/SOURCES/check-n-symlink.sh: line 60: syntax error: unexpected end of file
warning: %post(plasma-applet-veromix-0.18.3-1_archie_2012.i586) scriptlet failed, exit status 2

The app was installed system-wide but the symlinks to userspace were not created. Back to the drawing board. ;)
« Last Edit: June 29, 2012, 06:32:43 AM by Archie »
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline ghostbunny

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1193
Re: Need to add scriptlet to %post
« Reply #19 on: June 29, 2012, 06:49:25 AM »
oh sorry

the disadvantage of a plain text editor replace line 21 by

Code: [Select]
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then

i forgot the closing " after $2
The full life is a big mess

PS:
I'm German. Sorry because of possible mistakes in my written messages xD


Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8816
  • Aurum nostrum non est aurum vulgi.
Re: Need to add scriptlet to %post
« Reply #20 on: June 29, 2012, 07:20:07 AM »
oh sorry

the disadvantage of a plain text editor replace line 21 by

Code: [Select]
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then

i forgot the closing " after $2

Good! Synaptic did not throw any scriplet fail error. Instrad it displayed the help on the script ...

Quote
While installing package plasma-applet-veromix-0.18.3-1_archie_2012:

Usage: check-n-symlink.sh <name of plasmoid> <name of file to link> <name of the link>

Explanation:
<name of plasmoid> means the folder in /usr/share/kde4/apps/plasma/plasmoids which contains the plasmoid

<name of file to link> means the file name of the desktop file in /usr/share/kde4/services

<name of the link> means the name of the link which appears in /home/<username>/.kde4/share/kde4/services

AND it still failed to create the userspace symlinks. Wrong syntax on lines 52 and 53?

For a package scriptlet, IMO the help is not necessary as an extra output in Synaptic. I think we can comment them out and those just be part of the scriptlet doumentation.

That's an excellent idea to make the script "recyclable". It would be beneficial to other plasma-applet packages needed to be installed in userspace.

UPDATE:

Changed the name of the scriplet and added a version. It still wouldn't create symbolic links on the user's home folders.

Download: chkdir-sylnk-0.1.sh
« Last Edit: June 29, 2012, 07:43:26 AM by Archie »
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline ghostbunny

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1193
Re: Need to add scriptlet to %post
« Reply #21 on: June 29, 2012, 07:32:47 AM »
how does your call of the script look in the %post section?

it should / have to be

Code: [Select]
sh ./$SOURCE1 veromix-plasmoid plasma-widget-veromix.desktop veromix.desktop

showing the help means the script misses one or more parameters so it fails to generate anything.

« Last Edit: June 29, 2012, 07:36:45 AM by ghostbunny »
The full life is a big mess

PS:
I'm German. Sorry because of possible mistakes in my written messages xD


Offline ghostbunny

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1193
Re: Need to add scriptlet to %post
« Reply #22 on: June 29, 2012, 09:27:06 AM »
Code: [Select]
if [ -d $PLMDIR/veromix-plasmoid ]; then
    if [ -L $PLMDIR/veromix-plasmoid ]; then  [color=red]# why did you add this it means "create the link if the link exists. Think you mean ! -L"[/color]
        # Create the symlinks
        ln -s $SYMDIR /home/$idx/$PLMDIR &&
        ln -s $SYMFILE /home/$idx/$DTOP
    else
        # Why do the directory exist?
        rm -f $PLMDIR/veromix-plasmoid
    fi       
    fi

so better is also

Code: [Select]
if [ -d $PLMDIR/$1 ]; then
    if [ ! -L $PLMDIR/$1 ]; then
        # Create the symlinks
        ln -s $SYMDIR /home/$idx/$PLMDIR &&
        ln -s $SYMFILE /home/$idx/$DTOP
        else
        # Why do the directory exist?
        rm -f $PLMDIR/$1
    fi       
fi


btw does this
Quote
UPDATE:

Changed the name of the scriplet and added a version. It still wouldn't create symbolic links on the user's home folders.

Download: chkdir-sylnk-0.1.sh



happen before or after doing this

how does your call of the script look in the %post section?

it should / have to be

Code: [Select]
sh ./$SOURCE1 veromix-plasmoid plasma-widget-veromix.desktop veromix.desktop

showing the help means the script misses one or more parameters so it fails to generate anything.


« Last Edit: June 29, 2012, 09:29:46 AM by ghostbunny »
The full life is a big mess

PS:
I'm German. Sorry because of possible mistakes in my written messages xD