detecting if petget is called in pinstall.sh

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

detecting if petget is called in pinstall.sh

#1 Post by s243a »

In a pinstall.sh script I want to detect if it is being installed via the petget command because unlike package_chooser.sh, the petget command won't install dependencies and the pinstall.sh script needs the dependencies in order to work.

Unfortunately there is currently no variable exported in petget that would allow the pinstall.sh script to dected whether the petget command is a parrent process. So what to do? Well...let's abuse stack traces.

Bash has a command "called caller" (see manpage) that can be used to build a stack trace.

Here is such a function

Code: Select all

stacktrace() {
  local frame=0 LINE SUB FILE
  while read LINE SUB FILE < <(caller "$frame"); do
    printf '  %s @ %s:%s' "${SUB}" "${FILE}" "${LINE}"
    ((frame++))
  done
}
https://unix.stackexchange.com/question ... er-command

So, in theory I should be able to do something like this:

Code: Select all

petget_cmd="$(stacktrace | grep petget/petget)"
if [ ! -z "$petget_cmd" ]; then
  echo "Petget command called"
else
  echo "Petget command not called"
fi
I'll try it tommorow and report back on the results.

Edit:

Here's a draft of what I was thinking (not tested)

pinstall.sh arch_certs-1.0.1 (draft)
https://pastebin.com/bwyHBeX9

a modified version of my previous pet (see post). The old pet had the dependencies stored in /var/tmp as pets. The new pinstall script will first look in the folder /var/tmp and /root and otherwise download the pet. However, it will only do this if the petget command is a parent command. Otherwise it will rely on the package manager to install the dependencies. Well at least that is my idea but it isn't fully implemented yet.
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#2 Post by jamesbond »

my 2c: you should not do this in pinstall.sh. If the dependencies are not found, just run xmessage saying that the required dependencies aren't installed and the user is supposed to install it themselves, or the package will not work.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
rockedge
Posts: 1864
Joined: Wed 11 Apr 2012, 13:32
Location: Connecticut, United States
Contact:

#3 Post by rockedge »

Hello s243a


do you think that sc0ttman's Pkg package manager is a candidate for ArchPup? I'm wondering if installing it might help in the installation process overall.

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#4 Post by s243a »

rockedge wrote:Hello s243a


do you think that sc0ttman's Pkg package manager is a candidate for ArchPup? I'm wondering if installing it might help in the installation process overall.
You won't be able to add or update repos with it until we add the necessary functionality to it. However you can probably use it to download and install packages. Give it a try. If you get stuck I can help.

That all said, I think that pkg will have many of the same issues that the ppm does. In our build we need to fix the firefox certificate issues and make sure that ld.so.conf is correct.
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#5 Post by s243a »

I've updated my script:

pinstall.sh arch_certs-1.0.1 (draft)
https://pastebin.com/bwyHBeX9

It appears to work when I run the pinstall.sh script by its self. To do this I export:

Code: Select all

export DEPENDS_VIA_PINSTALL=yes
However, I suppose that this doesn't test weather or not the script successfully detects of petget is a parent process. I'll test that aspect tomorrow but for now I'll assume it works...
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

Post Reply