maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   How to give permission to a script file inside a deb? (https://talk.maemo.org/showthread.php?t=89562)

flotron 2013-03-22 21:05

How to give permission to a script file inside a deb?
 
I'm making a theme packaged on deb.
The theme require to modify some files inside /usr/share/themes/base/meegotouch. It modifies succesfully those file s when i add the script to the posinst file BUT now i want to modify that files by a desktop icon that run an SH script that run commands like /sbin/initctl restart xsession/mthome or symlink inside /usr/share/themes/base/meegotouch/libmeegotouchhome/style but these ones doesn't work.

I don't have permission? I tried chmod +x script.sh on the postinst but no luck

Maybe the script should be placed in other folder? (now is in /opt/theme)

elros34 2013-03-22 21:19

Re: How to give permission to a script file inside a deb?
 
I guess you need to be root user so try run commands with sudo.

flotron 2013-03-22 21:24

Re: How to give permission to a script file inside a deb?
 
but if you run commands in sudo the user must enter the password?
and why this script is working when is inside the postinst but not in the script.sh?

peterleinchen 2013-03-22 21:41

Re: How to give permission to a script file inside a deb?
 
You need to put a file "myApp.sudoers" into /etc/sudoers.d/
with a content like
Quote:

user ALL = NOPASSWD: /path/to/script/scriptname
and call in postinst 'update-sudoers'.
Then you may call the script with sudo without requiring a password.

--edit
This guide is only valid for normal debian based systems. For Harmattans cripped aegisfs there needs to be obeyed a few things more ...

flotron 2013-03-22 21:55

Re: How to give permission to a script file inside a deb?
 
sorry for be insisten but why this script is working when is inside the postinst but not in the script.sh?

peterleinchen 2013-03-22 22:00

Re: How to give permission to a script file inside a deb?
 
postinst is executed as root.
Did you try to run the script with sudo or as root?

flotron 2013-03-22 22:26

Re: How to give permission to a script file inside a deb?
 
So.. if i execute this: ln -s /opt/mytheme /usr/share/themes
With sudo would be:

Code:

sudo ln -s /opt/mytheme usr/share/themes

flotron 2013-03-22 22:54

Re: How to give permission to a script file inside a deb?
 
Quote:

Originally Posted by peterleinchen (Post 1330942)
You need to put a file "myApp.sudoers" into /etc/sudoers.d/
with a content like
and call in postinst 'update-sudoers'.
Then you may call the script with sudo without requiring a password.

not working :(

I tried to add sudo in the desktop icon too but nothing..:confused:

Code:

[Desktop Entry]
Type=Application
Name=My Theme
Exec=sudo /opt/mytheme/changer/script.sh
Icon=/opt/mytheme/icon/icon.png
X-Window-Icon=
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable


peterleinchen 2013-03-22 23:14

Re: How to give permission to a script file inside a deb?
 
Instead of guessing around: what exactly is not working? Which errors?
What is the content of your script?
Forgot the shebang?
Does the script work when executed as root?
???

flotron 2013-03-22 23:23

Re: How to give permission to a script file inside a deb?
 
Sorry i forgot to answer that..

Yes is working manually via terminal with root

flotron 2013-03-22 23:33

Re: How to give permission to a script file inside a deb?
 
the content of my script remove files from themes/base folders and it replace them with symlinks

peterleinchen 2013-03-22 23:34

Re: How to give permission to a script file inside a deb?
 
Then it should work with hints given above ...

flotron 2013-03-22 23:36

Re: How to give permission to a script file inside a deb?
 
but how to execute the script now, what i need to put before ?
sudo script.sh?
devel-su script.sh?
su script.sh?
#sudo script.sh?

Schturman 2013-03-22 23:52

Re: How to give permission to a script file inside a deb?
 
OK, you can do it like this..
1. Before packaging you need your_package.aegis file that include this:
Code:

<aegis>
    <request policy="add">
    <credential name="UID::root" />
    <credential name="GID::root" />
    <credential name="GRP::root" />

    <for path="/opt/mytheme/changer/script.sh" />
    </request>
</aegis>

2. The .desktop file should look like this:
Code:

[Desktop Entry]
Type=Application
Name=My Theme
Exec=/usr/bin/aegis-exec -s -u user -l "/opt/mytheme/changer/script.sh"
Icon=/opt/mytheme/icon/icon.png
X-Window-Icon=
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable


flotron 2013-03-23 00:01

Re: How to give permission to a script file inside a deb?
 
where is should be placed in the package? your_package.aegis

that would be "packagename.aegis"?

Schturman 2013-03-23 00:16

Re: How to give permission to a script file inside a deb?
 
yes "packagename.aegis"

P.S. I don't know how you package your .deb file, but I use this method: http://talk.maemo.org/showthread.php?t=86291
By what I wrote before I removed password prompt from N9QT.

flotron 2013-03-23 00:17

Re: How to give permission to a script file inside a deb?
 
but where it should be placed? inside the DEBIAN folder?

Schturman 2013-03-23 00:21

Re: How to give permission to a script file inside a deb?
 
No, in: your_packagename/debian
full path:
Code:

/scratchbox/users/your_name/home/your_name/package_name/debian

Schturman 2013-03-23 00:24

Re: How to give permission to a script file inside a deb?
 
P.S. Also add to the "rules" file:
Code:

chmod 4755 debian/your_packagename/opt/mytheme/changer/script.sh

flotron 2013-03-23 00:53

Re: How to give permission to a script file inside a deb?
 
thank you schturman, but im kind confused because i dont understand so much of this
i only package the folder to deb and do you mean debian folder inside the package?
and the rules file must be inside debian folder too?

Schturman 2013-03-23 02:29

Re: How to give permission to a script file inside a deb?
 
do you have scrstchbox installed ?

coderus 2013-03-23 06:24

Re: How to give permission to a script file inside a deb?
 
Quote:

Originally Posted by Schturman (Post 1330968)
OK, you can do it like this..
1. Before packaging you need your_package.aegis file that include this:
Code:

<aegis>
    <request policy="add">
    <credential name="UID::root" />
    <credential name="GID::root" />
    <credential name="GRP::root" />

    <for path="/opt/mytheme/changer/script.sh" />
    </request>
</aegis>

2. The .desktop file should look like this:
Code:

[Desktop Entry]
Type=Application
Name=My Theme
Exec=/usr/bin/aegis-exec -s -u user -l "/opt/mytheme/changer/script.sh"
Icon=/opt/mytheme/icon/icon.png
X-Window-Icon=
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable


oh, really, aegis-exec -s -u user ... ?

coderus 2013-03-23 06:25

Re: How to give permission to a script file inside a deb?
 
@flotron. how you packaging to geb? you can use aegis-deb-add to inject aegis manifest ot existing deb package.

peterleinchen 2013-03-23 09:19

Re: How to give permission to a script file inside a deb?
 
A big SORRY from my side.
As soon as I stepped out and Schturmann stepped in, it was obvious that this imeant for N9. And all my guides of course only work for N900. Must have overread that in your first post.

Schturman 2013-03-23 10:59

Re: How to give permission to a script file inside a deb?
 
Quote:

Originally Posted by coderus (Post 1331006)
oh, really, aegis-exec -s -u user ... ?

Exactly... You are right he can change it to "root" too.. But for me in N9QT it work with "user". If i change it to root, the version-auto-checker script, that run from n9qt script, not work correctly..

Schturman 2013-03-23 11:17

Re: How to give permission to a script file inside a deb?
 
Quote:

Originally Posted by coderus (Post 1331007)
@flotron. how you packaging to geb? you can use aegis-deb-add to inject aegis manifest ot existing deb package.

Can you write please the full command how to do it? And first he need to create the aegis manifest file?

flotron 2013-03-23 19:44

Re: How to give permission to a script file inside a deb?
 
Quote:

Originally Posted by Schturman (Post 1331057)
Can you write please the full command how to do it? And first he need to create the aegis manifest file?

I package my debs with my n9 :( with this script

/home/user/MyDocs/makedeb.sh /home/user/mypackagefolder (inside folder: DEBIAN,opt,usr.. with control,postint,etc...)

Code:

#!/bin/sh

#create .deb files for packages (fremantle&harmattan)

if [ ! $1 ];then
 echo Create .deb files for fremantle and harmattan devices
 echo Usage: make-deb /path/to/package
 exit 0
fi

#step in package directory
chdir "$1"

#versionnumber and packagename from control file
packagename=`grep "Package: " DEBIAN/control | cut -d ' ' -f 2`
versionnumber=`grep "Version: " DEBIAN/control | cut -d ' ' -f 2`

#remove old md5 and digsig sums
rm -f DEBIAN/md5sums 2>/dev/null
rm -f DEBIAN/digsigsums 2>/dev/null

#list all folders except DEBIAN
find | grep -v "./DEBIAN" > ../md5

#get md5 and digsig sums to DEBIAN/
while read line
do
 if [ -f "$line" ]; then
  #cut "./" from beginning
  line=`echo "$line" | cut -c 3-`

  #get md5
  md5sum "$line" >> DEBIAN/md5sums

  #get sha1 for digital signatures
  echo S 15 com.nokia.maemo H 40 `sha1sum "$line" | cut -c -40` R `expr length "$line"` $line >> DEBIAN/digsigsums
 fi
done < "../md5"

#remove temp file list
rm -f ../md5

#package control.tar.gz and data.tar.gz
tar -cvzf ../control.tar.gz -C DEBIAN/ . >/dev/null
tar -cvzf ../data.tar.gz . --exclude=DEBIAN >/dev/null
echo 2.0>../debian-binary

#step outside package folder
cd ..

#create debian archive "package_version.deb"
ar -rcv $packagename"_"$versionnumber.deb debian-binary control.tar.gz data.tar.gz >/dev/null

#remove packaged files
rm -f debian-binary control.tar.gz data.tar.gz 2>/dev/null


Schturman 2013-03-23 20:13

Re: How to give permission to a script file inside a deb?
 
Ok, thanks, but I meant to Coderus :)
I also want to learn how inject aegis manifest ot existing deb package :)

flotron 2013-03-23 20:21

Re: How to give permission to a script file inside a deb?
 
I tried yours Schturman (adding the aegis an rules files and modifyng the desktop file) but when i press the icon nothing happens.
The script only works in the postint or preinst, etc.. Not executing from icon

Schturman 2013-03-23 20:53

Re: How to give permission to a script file inside a deb?
 
Packaging on n9 it's not really the same like packaging on the Linux pc via scratchbox. I don't know how to do it, we need to wait for Coderus that can explain how inject aegis manifest ot existing deb package.
Or another way, install scratchbox on Linux pc and i will try to help you crate this package..

flotron 2013-03-23 20:56

Re: How to give permission to a script file inside a deb?
 
Quote:

Originally Posted by Schturman (Post 1331206)
Packaging on n9 it's not really the same like packaging on the Linux pc via scratchbox. I don't know how to do it, we need to wait for Coderus that can explain how inject aegis manifest ot existing deb package.
Or another way, install scratchbox on Linux pc and i will try to help you crate this package..

Yes, i was thinking to start read your tutorial and see if i can pack the deb in my ubuntu

Schturman 2013-03-23 20:57

Re: How to give permission to a script file inside a deb?
 
It's easy on ubuntu :)

flotron 2013-03-26 15:06

Re: How to give permission to a script file inside a deb?
 
Inside the "data" folder should go the "opt" folder? or the data folder is the opt folder?


All times are GMT. The time now is 13:56.

vBulletin® Version 3.8.8