PPM: How to download packages into any directory

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#61 Post by mavrothal »

mavrothal wrote: Yes could be using the defined directory for consistency
OK here is a patch for petget. Whoever builds the next version (if not me) is welcome to use it.

Code: Select all

--- a/usr/local/petget/petget	2014-08-27 23:07:44.000000000 +0300
+++ b/usr/local/petget/petget	2014-12-03 23:53:14.036633783 +0200
@@ -35,6 +35,12 @@
 
 [ ! $1 ] && exit
 
+if [ -f /root/.packages/download_path ]; then
+ . /root/.packages/download_path
+ [ -d "$dir_prefix" ] && dir_prefix="$dir_prefix" || dir_prefix=/root
+else
+ dir_prefix=/root
+fi
 #export LANG=C
 . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
 
@@ -97,7 +103,7 @@
 #download if required...
 PKGNAME=""
 if [ "`echo -n "$PASSEDPARAM" | grep -E '^ftp|^http'`" != "" ];then
- cd /root
+ cd "$dir_prefix"
  #101116 use download_file utility...
  download_file "$PASSEDPARAM"
  PKGPATH="`dirname "$PASSEDPARAM"`" #really a url.
@@ -126,10 +132,10 @@
    PKGMAIN="`basename "$PASSEDPARAM" ${EXT}`"
   fi
  fi
- cp -f "${PKGPATH}/${FULLPKGNAME}" /root/ 2>/dev/null #v424 fix if spaces in path.
+ cp -f "${PKGPATH}/${FULLPKGNAME}" "$dir_prefix"/ 2>/dev/null #v424 fix if spaces in path.
 fi
 originPKGPATH="$PKGPATH" #w482
-PKGPATH=/root
+PKGPATH="$dir_prefix"
 
 #split PKGMAIN, ex: FULLPKGNAME=xvidtune-1.0.1-i486-1.tgz has PKGNAME=xvidtune-1.0.1
  case $EXT in
@@ -178,7 +184,7 @@
   ;;
  esac
 
-cd "$PKGPATH" #well, this is /root
+cd "$PKGPATH"
 
 #confirm want to install...
 export INSTALL_DIALOG="<window title="$(gettext 'Puppy Package Manager')" icon-name="gtk-about">
@@ -219,7 +225,7 @@
 rm -f /tmp/petget_missing_dbentries-Packages-* 2>/dev/null
 rm -f /tmp/petget-installed-pkgs-log 2>/dev/null
 echo "$DB_ENTRY" > /tmp/petget_missing_dbentries-Packages-alien
-/usr/local/petget/installpkg.sh $PKGPATH/$FULLPKGNAME
+/usr/local/petget/installpkg.sh "$PKGPATH"/$FULLPKGNAME
 RETVAL=$?
 
 #installpkg.sh has already done this...
In the mean time you may want to test the next PPM project: Installing multiple packages at once with PPM (attended too)
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#62 Post by MochiMoppel »

bigpup wrote:I too was looking for a download location option as Greengeek talks about.
You should keep in mind the main reason for a download option (see 2nd para of my initial post): to help people who have a skimpy pupsave file and not enough room in /root. The download directory is foremost a working directory, should be the fastest possible and /root is still a good choice for most users. The present default is: download pet to RAM, install and delete. The pet never touches your USB or HDD.

EDIT: OK, last statement depends on PUPMODE. I'm using PUPMODE 5 and tend to forget that some modes write directly to disc.

If you ask for a default directory for download-only pets, then we are possibly talking about a target somewhere on a permanent save location. Normally this location outside of RAM would be much slower and not ideal for PPM as a working directory.

@mavrothal
After good night's sleep I think that petget should keep its current defaults. Was just one of those ideas :lol:


-
Last edited by MochiMoppel on Thu 04 Dec 2014, 06:36, edited 1 time in total.

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#63 Post by bigpup »

MochiMoppel you bring up some good points.

However, this feature is already changing the default download location and making this change the new default setting.

I may be wrong, but as it stands the normal install operation:
download pet to RAM, install and delete
is not that clearcut anymore.
It will use this new location to do the install.
So, does it not already do what you are worried about?

AT least what I propose would make you at least verify the setting is what you want to use and give you option to change it, just before doing the download.

Just to make the discussion more confusing.
Seems working only in ram, is not that clear, for a normal program install.
Before adding the download feature it still had options.

PPM could have two possible looks after adding this feature.

see images:
Attachments
capture12187.png
PPM before adding download option
(33.66 KiB) Downloaded 405 times
download_folder.png
download feature added to PPM on a hard drive install
(26.51 KiB) Downloaded 410 times
capture15919.png
download feature added to PPM on a USB flash drive
(38.39 KiB) Downloaded 404 times
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#64 Post by MochiMoppel »

@bigpup
Interesting. I've never seen the installation mode option. This will be shown only to users of PUPMODE 3,7 or 13.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#65 Post by MochiMoppel »

mavrothal wrote:configure.sh: Add GUI code to check and save user options for download folder and to save installed pets
downloadpkgs.sh: Add code to look for presets (dir and save pet); cd to preset dir; change hard coded /root to preset dir;
installpkg.sh: double quote pre-existing variables so will accept path names with spaces; modify code so will not delete installed pets if we choose to save them
verifypkg.sh : double quote pre-existing variables so will accept path names with spaces
pet2tgz: modify code so will not delete installed pets if we choose to save them
download_file.sh: Add code to look for presets dir (only when called from PPM); cd to preset dir; double quote pre-existing variables so will accept path names with spaces; added download dir variable to wget command (this last one could be skipped since we already cd'ed in it but some extra precausion)

Would be nice if some of these changes can be eliminated and still maintain the same functionality.
Done. :lol: I tried to keep changes to a minimum, which eliminates some of your fixes but on the other hand adds some new ones.

I tested in Slacko and Precise. I tried to make it compatible with Lucid 5.2.8 but gave up. Too many differences. Lucid users can still patch manually (solution 2), this worked. And Puppy 4.2...no way, but solution 1 always works.

Biggest change is the GUI. I moved the directory selection from the configuration dialog to the preinstall dialog. I did this mainly for technical reason, but there is also a benefit for the users: The choices are more visible and are better linked to their context. It also answers the request of some forum members who asked for the option to choose a download directory before each download.
Features of directory input field:
  • Input field shows current download directory
  • New directories entered into the field will be created on-the-fly if they don't exist.
  • User may enclose path with quotation marks (he shouldn't, but if he does, the marks will be stripped automatically)
The pet includes 4 files:

installpreview.sh
- Added GUI code to check and save user options for download folder and to save installed packages.

downloadpkgs.sh:
- cd to preset dir
- Removed hard coded /root
- Modified "Finished. The packages have been downloaded" dialog to show correct download path
- Fixed bug which would show "Finished. The packages have been downloaded" dialog even if download failed and nothing had been downloaded.

installpkg.sh:
- Added function to optionally keep installed packages in the download directory.
- Added code to correctly reassemble .pet files after PPM changed them to .tar.gz files

download_file
- Changed PWD variable to dot placeholder to avoid problems with spaces in path name.

Keyword "mochi" will find all my changes and comments.
Attachments
preinstall.png
(30.74 KiB) Downloaded 347 times
ppm_mochi-1.pet
Adds option to choose dl directory and to keep pkgs after install
(27.35 KiB) Downloaded 256 times

Jasper

#66 Post by Jasper »

Hi all,

I have tried the above pet with Precise 5.6 (in pupmode 77) and also with Quirky unicorn 6.2.1 and it worked well in both.

Thank you MochiMoppel.

My regards

User avatar
Griot
Posts: 131
Joined: Fri 12 Sep 2014, 18:10
Location: Serbia

#67 Post by Griot »

Ok, after Mochi's intervention on the installpreview.sh script,
my problem with the PPM disappeared. :D
There was some kind of gtkdialog nonsense which caused
an error while trying to select download dir. It's gone with the wind.

Thanks again Mochi. :wink:
Attachments
sjp15_8.jpg
Good luck!
(5.81 KiB) Downloaded 224 times
Last edited by Griot on Thu 11 Dec 2014, 15:08, edited 2 times in total.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#68 Post by MochiMoppel »

@ Jasper:Thanks for testing.
@ Griot: Check your mail :wink:

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#69 Post by mavrothal »

MochiMoppel wrote:
mavrothal wrote: Would be nice if some of these changes can be eliminated and still maintain the same functionality.
Done. :lol: I tried to keep changes to a minimum, which eliminates some of your fixes but on the other hand adds some new ones.
Works OK.
As far as I can see you moved the configure.sh and pet2tgz changes in installpreview.sh (BTW, why duplicate the pet2tgz function ?) and left out the verifypkg.sh change.
One thing I noticed in the current implementation is that if someone drags a folder in the path field, the name is added in what ever is already there, and also accepts files too. So you can have "/mnt/home/Download/more pets/root/my-documents/test.txt" as your path. And then it goes ahead and creates the folder with this path and name (which is good - the folder creation). You may want to erase the previous path and accept only folders, when drag&drop.
I also noticed in the code that you already marked some bugs. Are you working on these?

I personally find the installprview window too loaded and maybe confusing (specially if you add the examine dependencies button and info on top), combining configuration and installation options with minimal info, but I'm sure there are people preferring it this way 8). I go the "opposite" way right now, automating things :wink: Is good for puppy users to have options :D
You may still want to keep configuration options in configure.sh and add the change-folder option only when "Download" is pressed .
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#70 Post by MochiMoppel »

mavrothal wrote:As far as I can see you moved the configure.sh and pet2tgz changes in installpreview.sh
I moved pet2tgz changes to installpkg.sh, not installpreview.sh, keeping pet2tgz unchanged
(BTW, why duplicate the pet2tgz function ?)
Wasn't my idea. That's the way bug fix 101225 was implemented in verifypkg.sh, and since we need exactly the same functionality for installed pets that was needed for download-only pets, I used the same code. I figured it would be confusing to have 2 different code solutions for the same thing. That doesn't mean that I like the code. There are much more elegant ways to do it, but then I would also have to fix the bug fix 101225, which obviously was approved by the Puppy makers. As I said before I tried to keep changes to a minimum. The target is to implement the new download functionality. Changes not directly related to that will have to wait.
.... left out the verifypkg.sh change.
There was nothing to change.
One thing I noticed in the current implementation is that if someone drags a folder in the path field, the name is added in what ever is already there
Just normal behavior in any input field. I believe that users who prefer drag&drop already know this. I can change this and have the input text selected whenever the window is activated. This would replace the existing path when another path is dropped on it.
I also noticed in the code that you already marked some bugs. Are you working on these?
Only one, and that I fixed already. What else did you notice?
I personally find the installprview window too loaded and maybe confusing (specially if you add the examine dependencies button and info on top), combining configuration and installation options with minimal info
I'm not sure if I understand correctly. I fully agree that the preinstall dialog is overloaded, but only because it carries too much non-essential text. Just look at the screenshot. Who needs that stuff? Telling me that everything looks OK and that PPM will check again to make sure that it is really OK and that I may push the "Install" button now. Frankly, I prefer to know only if something is not OK. And then this big "More Info" button, together with a lengthy explanation what I can expect when I push it. I appreciate explanations, but they belong into tooltips, keeping the main window tidy. Could it be that tooltips were not yet implemented when the dialogs were designed?
Your "minimal information" refers to the entry field? Whatever is neccessary is there, the rest should go into a tooltip. I haven't done it yet, we are still in alpha. Particularly the checkbox needs explanation because not every user understands the installation procedure.
I think we can't make a clear-cut distinction between configuration and installation option. If a user prefers to always download pets to the same folder and always keep installed pets, then you may call it a configuration option. Set and forget. Other users may change their preference depending on the information in the preinstall dialog, mainly the package size. They may want to download huge packages to a different location than they normally would download small ones. And likewise they may opt to discard installed pets depending on the nature of the pets. For such users it would be an installation option.
You may still want to keep configuration options in configure.sh and add the change-folder option only when "Download" is pressed .
Do we agree that the user may want to know where downloads will be saved and that he may want to know this before he presses the Install or Download-only button?

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#71 Post by mavrothal »

MochiMoppel wrote:Do we agree that the user may want to know where downloads will be saved and that he may want to know this before he presses the Install or Download-only button?
Don't wary about it. Will always be people disagree or agree with whatever is there. So do as you like. :lol:
I would prefer a cleaner GUI with configurations in "preferences", and there in addition to the "path" and "keep" options, have the "ask every time" option that will show up only when you choose to "download only" or have "keep" preselected in config.
But I'm sure <puppyuser2> is loving it the way it is and ask if possible to add a field/button so "when there are dependencies to keep the main package and its dependencies in their own folder " :roll:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

Jasper

#72 Post by Jasper »

Hi mavrothal,

As I wrote above - MochiMoppel's pet worked for me - and I understood the options. So, in an effort to help others.....

and as an exercise in logic - I have just spent some 40 minutes trying to simplify a small part of the gui wording limited to the download location and saving and deletion and, so far, I'm not pleased with my attempts.

I hope the use of a later version of the pet (if any) will be optional rather than mandatory.

My regards

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#73 Post by greengeek »

MochiMoppel wrote:Done. :lol: I tried to keep changes to a minimum, which eliminates some of your fixes but on the other hand adds some new ones.
ppm_mochi-1.pet works perfectly for me on a Slacko 5.6 derivative. Sorry for the late report - I got odd results during testing but then found it was my own fault for losing a vital symlink during a remaster and that stuffed up my PPM.

I like the way this pet is working - it does everything I need. (I don't do anything complex with PPM so can't say that I've done extensive testing...)

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#74 Post by bigpup »

Just to give you some added information.

All that information on the GUI is old school Puppy.
From Puppies beginning, it was common for the information about what you were doing would be displayed when you did it.
Tried to eliminate the need for help documents to read or even need to have in Puppy.

It does seem a little overdone at times, but not to a new user of Puppy. :wink:
They need any and all the help they can get.

Remember, you where one at one time :lol:
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#75 Post by MochiMoppel »

Griot wrote:Ok, after Mochi's intervention on the installpreview.sh script,
my problem with the PPM disappeared. :D
There was some kind of gtkdialog nonsense which caused
an error while trying to select download dir. It's gone with the wind.
I guess I'll have to explain that. :lol:

In short: The folder dialog that appears when you press the "Change" button doesn't work correctly in Precise (all versions). After pressing "OK" the dialog doesn't close and the selected folder path would not be pasted into the entry field.

The problem occurs because PPM calls "gtkdialog3" to display the preinstall dialog. Though gtkdialog3 is obsolete, there is no problem in Slacko: A symlink gtkdialog3 points to the binary gtkdialog, which happens to be the latest gtkdialog version.

In Precise, for reasons beyond me, 2 indentically named symlinks gtkdialog exist, one points to binary gtkdialog4, the other to gtkdialog3. In Precise, a script gets what it asks for. If it calls gtkdialog3, Precise runs a real gtkdialog3, version 0.7.20 to be precise. The functions in the folder dialog require at least version 0.7.21.

Changing the code in PPM from "gtkdialog3" to "gtkdialog" fixes the problem, because Precise first will try the symlink gtkdialog that points to gtkdialog4.

@mavrothal: Any chance that all references to gtkdialogX are changed to gtkdialog to facilitate future updates? You already touched this problem in your other thread.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#76 Post by mavrothal »

MochiMoppel wrote: @mavrothal: Any chance that all references to gtkdialogX are changed to gtkdialog to facilitate future updates? .
Woof-CE is awaiting your patches. I'm sure you (and probably others) can do it :wink:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#77 Post by MochiMoppel »

I have now updated the pet and added it as solution 3 to theinitial post.

The only fixes:
- path in input field is selected to facilitate drag&drop
- "OK" button in path selection dialog now works in Precise

I think that's it. My thanks to mavrothal and all who contributed.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#78 Post by mavrothal »

Which PPM version was the original (from which puppy)?
Any chance to provide patches?
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#79 Post by MochiMoppel »

mavrothal wrote:Which PPM version was the original (from which puppy)?
Slacko 5.9.3
Any chance to provide patches?
Certainly, but
1) First I have to come to grips with Github. Have created an account, but I'm not sure how to preceed
2) You and zigbert are currently turning PPM upside down. Makes no sense to provide patches for constantly changing code
3) The pet is pretty new and forum members had little chance to test it . It's much too early to commit it. Give it some time to mature, it's no bug fix.

On a related note: I see that you reverted a new version of pet2tgz in github and moved it to the testing branch. I see problems with this new version. Is the testing branch open for comments?

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#80 Post by mavrothal »

MochiMoppel wrote:On a related note: I see that you reverted a new version of pet2tgz in github and moved it to the testing branch. I see problems with this new version. Is the testing branch open for comments?
What kind of problems?
The nice thing about git is you can always hit "git reverse" :wink:
I believe that comments are open. You can even comment on individual lines of a commit (but not the full file - github bug).
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

Post Reply