How to build a SFS downloader and installer!

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

How to build a SFS downloader and installer!

#1 Post by oldyeller »

I beleive that I can do the GUI for this just don't know the code for downloading and installing.

This is what I want to do. I would like to upload all the sfs on my ov-precise threads so that they wil all be in one place and therfore can be downloaded.

I have learned a liitle about GTKdailog but really don't know anything about bash or any of the others.
Last edited by oldyeller on Wed 29 Aug 2012, 17:34, edited 3 times in total.

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#2 Post by goingnuts »

Maybe not what you are asking for but here is a script to download all sfs-files from a webpage:

Code: Select all

#!/bin/sh
wget -nd -r -A sfs http://the_target_webpage.html
#-nd = --no-directories (all files are saved in the current directory
#-r = --recursive
#-A sfs = --accept sfs
#if you would download all images instead use:
#wget -nd -r -A jpeg,jpg,bmp,gif,png http://the_target_webpage.html
For the install afterwards you could use sfs_load-1.9.6 on-the-fly or otf_sfs_loader.sh looping through the downloaded sfs-files...

Code: Select all

for X in *.sfs; do
#some call to load sfs ex:
otf_sfs_loader.sh $X
done
NB: remember that sfs-files must be placed outside the current unionfs branch (could be in /tmp or somewhere on your save-file partition /home).
Last edited by goingnuts on Wed 29 Aug 2012, 04:31, edited 1 time in total.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

Re: How to build a SFS downloader and installer?

#3 Post by RSH »

oldyeller wrote:I beleive that I can do the GUI for this just don't know the code for downloading and installing.

This is what I want to do. I would like to upload all the sfs on my ov-precise threads so that they wil all be in one place and therfore can be downloaded.

I have learned a liitle about GTKdailog but really don't know anything about bash or any of the others.
Hello, oldyeller.

You can find everything you will need for a feature like this in LazY Puppy. Just have a look at the Run-Scripts in /root/.my-sfs-scripts and/or at the Scripts for the SFS-Suites in /usr/sbin/ceelab/lazy-sfs-load

LazY Puppy tries to run a application. If the application is not available, it tries to load the sfs. If the sfs is not available, it tries to download the sfs from smokey01.com. After a successful download, LazY Puppy loads the sfs (using sfs_load) and after this the application starts (this is what the automatically generated Run-Scripts are doing). :D :D :D

Greetings,

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

Re: How to build a SFS downloader and installer?

#4 Post by oldyeller »

RSH wrote:
oldyeller wrote:I beleive that I can do the GUI for this just don't know the code for downloading and installing.

This is what I want to do. I would like to upload all the sfs on my ov-precise threads so that they wil all be in one place and therfore can be downloaded.

I have learned a liitle about GTKdailog but really don't know anything about bash or any of the others.
Hello, oldyeller.

You can find everything you will need for a feature like this in LazY Puppy. Just have a look at the Run-Scripts in /root/.my-sfs-scripts and/or at the Scripts for the SFS-Suites in /usr/sbin/ceelab/lazy-sfs-load

LazY Puppy tries to run a application. If the application is not available, it tries to load the sfs. If the sfs is not available, it tries to download the sfs from smokey01.com. After a successful download, LazY Puppy loads the sfs (using sfs_load) and after this the application starts (this is what the automatically generated Run-Scripts are doing). :D :D :D

Greetings,

RSH


Thanks RSH I will take a look I really like what you did with LaYzPuppy awesome job.


goingnuts thanks but not what I was looking for.

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#5 Post by oldyeller »

This is what I am using
#!/bin/bash

### .sfs downloader ###
### stu90 ###

### root password for user fido ###
[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}


TESTSERVER="174.132.189.156"
SERVER="www.smokey01.com/Oldyeller/pet_packages-upup/"

## test server ##
ping -4 -c 1 "$TESTSERVER"
if [[ "$?" == "1" ]]; then
yaf-splash -placement center -bg yellow -fontsize large -timeout 10 -text "Either your Internet connection is not working, or the primary repository is down. Aborting SFS Downloader" &
exit 1
fi

## default download location ##
if [[ -f /etc/rc.d/PUPSTATE ]]; then
PUPPYSFS="/mnt/home/`grep 'PUPSFS' /etc/rc.d/PUPSTATE | cut -d '/' -f 2`"
fi

## action for first run with out save file ##
if [[ ! -d "$PUPPYSFS" ]]; then

## get available partitions ##
AVPART="`probepart -m | grep -v -E 'none|iso9660|swap' | cut -f 1 -d '|' | cut -f 3 -d '/' | tr '\n' '!' | sed '$s/.$//'`"

## mount partition info and gui ##
TEXT1=" This is a first boot of Puppy and you have not yet saved a session. \n You want to download the .sfs package, and this needs to be downloaded \n to the same partition in which you will be creating the session save-file.
\n Here is a list of suitable partitions. Whichever one you choose, at \n shutdown you will be asked to save the session and be sure to choose the \n same partition - please select a partition to mount from the box below: "

MNTPART=$(yad --title="$TITLE $VER" --text="$TEXT1" --form --field="mount partition:CB" "$AVPART" \
--button="gtk-quit:1" --button="gtk-ok:0")
result=$?

if [[ "$MNTPART" = "" ]]; then
echo "Exiting" && exit
fi

case $result in
0)

GETMNT=`echo $MNTPART | cut -d '|' -f 1`

## mount selected partition ##

if [[ ! -d /mnt/"$GETMNT" ]];then
mkdir -p /mnt/"$GETMNT"
mount /dev/"$GETMNT" /mnt/"$GETMNT"
fi

if [ $? -ne 0 ];then
xmessage -bg red -center "ERROR: Could not mount /dev/"$GETMNT", aborting"
exit 1
else
## set mounted partition as download location ##
PUPPYSFS="/mnt/"$GETMNT""
fi
;;
1)
echo "cancel pressed exiting"
exit
;;
esac
fi

## .sfs selection gui ##

## gui info ##
TITLE="Ov-Precise Get .sfs"
VER="0.2"
TEXT=" Please choose the .sfs packages that you would like to download from the drop down box below."

## get available .sfs on server ##
AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | tr '\n' '!' | sed '$s/.$//' `"

LISTSFS=$(yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" --form \
--field="Available sfs":CB "$AVSFS" \
--field="Download to":DIR "$PUPPYSFS" \
--button="gtk-quit:1" --button="gtk-ok:0")

result=$?
[[ $result = 1 ]] && echo "Exiting" && exit

case $result in
0)

GETSFS=`echo $LISTSFS | cut -d '|' -f 1`
GETLOC=`echo $LISTSFS | cut -d '|' -f 2`

## move to .sfs download location ##
cd "$GETLOC"

## check if .sfs exists in download location ##
if [ -f "$GETLOC/$GETSFS" ]; then
yaf-splash -placement center -bg yellow -close never -fontsize large -timeout 10 -text "$GETSFS already exists - aborting connection" &
exit 1
else
## download .sfs - could do with some error check here ##
yaf-splash -placement center -bg yellow -close never -fontsize large -text "Please wait, downloading .sfs..." &
YPID=$!

TERMSET="urxvt -fg green -bg black -geometry 65x10+0+0 +sb -e "
$TERMSET wget -c "$SERVER/$GETSFS"


kill $YPID
fi
## load .sfs ##
if [ "$GETLOC" == "/mnt/home/$PUPPYSFS" ];then
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
else
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
fi
;;

1)
echo "cancel pressed exiting"
exit
;;
esac
would I be able to improve on this. Like not having a dropdown list but a scroll bar with the list? or is this better?

User avatar
stu91
Posts: 145
Joined: Mon 06 Aug 2012, 15:11
Location: England. Dpup. Dell Inspiron 1501

#6 Post by stu91 »

oldyeller wrote:
would I be able to improve on this. Like not having a dropdown list but a scroll bar with the list? or is this better?
Hi oldyeller,
I do not think it is possible to have the download to option available when using --list --column ( sroll bar ) to display available .sfs files.

For a list of different Yad options run command: yad --help-all

cheers.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

How to build a SFS downloader and installer!

#7 Post by L18L »

Hi oldyeller,
is this that what you want?

Code: Select all

#!/bin/bash

### .sfs downloader ###
### stu90 ###
# 20120830 hacked by L18L for oldyeller
# Separate dialog "Preferences" for location where to download
# SFS files in a list with scroll bar
# version 0.2.1

### root password for user fido ###
[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}


TESTSERVER="174.132.189.156"
SERVER="www.smokey01.com/Oldyeller/pet_packages-upup/"

## test server ##
ping -4 -c 1 "$TESTSERVER"
if [[ "$?" == "1" ]]; then
yaf-splash -placement center -bg yellow -fontsize large -timeout 10 -text "Either your Internet connection is not working, or the primary repository is down. Aborting SFS Downloader" &
exit 1
fi

## default download location ##
if [[ -f /etc/rc.d/PUPSTATE ]]; then
PUPPYSFS="/mnt/home/`grep 'PUPSFS' /etc/rc.d/PUPSTATE | cut -d '/' -f 2`"
fi

## action for first run with out save file ##
if [[ ! -d "$PUPPYSFS" ]]; then

## get available partitions ##
AVPART="`probepart -m | grep -v -E 'none|iso9660|swap' | cut -f 1 -d '|' | cut -f 3 -d '/' | tr '\n' '!' | sed '$s/.$//'`"

## mount partition info and gui ##
TEXT1=" This is a first boot of Puppy and you have not yet saved a session. \n You want to download the .sfs package, and this needs to be downloaded \n to the same partition in which you will be creating the session save-file.
\n Here is a list of suitable partitions. Whichever one you choose, at \n shutdown you will be asked to save the session and be sure to choose the \n same partition - please select a partition to mount from the box below: "

MNTPART=$(yad --title="$TITLE $VER" --text="$TEXT1" --form --field="mount partition:CB" "$AVPART" \
--button="gtk-quit:1" --button="gtk-ok:0")
result=$?

if [[ "$MNTPART" = "" ]]; then
echo "Exiting" && exit
fi

case $result in
0)

GETMNT=`echo $MNTPART | cut -d '|' -f 1`

## mount selected partition ##

if [[ ! -d /mnt/"$GETMNT" ]];then
mkdir -p /mnt/"$GETMNT"
mount /dev/"$GETMNT" /mnt/"$GETMNT"
fi

if [ $? -ne 0 ];then
xmessage -bg red -center "ERROR: Could not mount /dev/"$GETMNT", aborting"
exit 1
else
## set mounted partition as download location ##
PUPPYSFS="/mnt/"$GETMNT""
fi
;;
1)
echo "cancel pressed exiting"
exit
;;
esac
fi

## .sfs selection gui ##

## gui info ##
TITLE="Ov-Precise Get .sfs"
VER="0.2.1"

function getloc() {
        GETLOC=$(echo "$AVSFS" | sed -r s%!%\n%  | \
                 yad --title="$TITLE $VER Preferences" --width="300" --justify=center  \
                     --form --field="Download to":DIR "$PUPPYSFS" \
                 )
         result=$?
         case $result in
         1|252) exit ;;
             0) GETLOC=${GETLOC%%|*}  # cut -d '|' -f1       
         esac
}

while true; do # endless loop

[ "$GETLOC" ] || getloc # if $GETLOC is not set then set it

##move "Download to" Preferences
#GETLOC=$(echo "$AVSFS" | sed -r s%!%\n%  | \
#         yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" \
#             --form --field="Download to":DIR "$PUPPYSFS" \
#         )
#result=$?
#GETLOC=${GETLOC%%|*}         
#echo result=$result
#case $result in
# 1|252) exit;;
#     0) GETLOC=${GETLOC%%|*}  # cut -d '|' -f1       
#esac

#TEXT=" Please choose the .sfs packages that you would like to download from the drop down box below."

## get available .sfs on server ##
#AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | tr '\n' '!' | sed '$s/.$//' `"

#LISTSFS=$(yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" --form \
#--field="Available sfs":CB "$AVSFS" \
#--field="Download to":DIR "$PUPPYSFS" \
#--button="gtk-quit:1" --button="gtk-ok:0")

TEXT=" Please choose the .sfs packages that you would like to download from the list below.
 Download to ${GETLOC} (Can be changed in Preferences) "
AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | sed '$s/.$//' `"
LISTSFS=$(echo "$AVSFS" | sed -r s%!%\n%  | \
          yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" --height="220" \
              --list --column="Available sfs":2   \
              --button="gtk-preferences":3 \
              --button="gtk-quit:1" --button="gtk-ok:0")
result=$?
case $result in
 1|252) echo "Exiting" && exit ;;
     3) getloc ;;
     0) 

GETSFS=`echo $LISTSFS | cut -d '|' -f 1`

## move to .sfs download location ##
cd "$GETLOC"

## check if .sfs exists in download location ##
if [ -f "$GETLOC/$GETSFS" ]; then
yaf-splash -placement center -bg yellow -close never -fontsize large -timeout 10 -text "$GETSFS already exists - aborting connection" &
exit 1
else
## download .sfs - could do with some error check here ##
yaf-splash -placement center -bg yellow -close never -fontsize large -text "Please wait, downloading .sfs..." &
YPID=$!

TERMSET="urxvt -fg green -bg black -geometry 65x10+0+0 +sb -e "
$TERMSET wget -c "$SERVER/$GETSFS"


kill $YPID
fi
## load .sfs ##
if [ "$GETLOC" == "/mnt/home/$PUPPYSFS" ];then
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
else
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
fi
;;

esac 

done
Attachments
sfsget-0.2.1.png
(28.35 KiB) Downloaded 686 times
Last edited by L18L on Thu 30 Aug 2012, 17:02, edited 1 time in total.

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#8 Post by oldyeller »

Hi L18L,

That will workout just fine. This will be nice once I have Manna-002 out.

Cheers.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#9 Post by L18L »

Glad to see it is useful and you like it :D

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#10 Post by oldyeller »

L18L wrote:Glad to see it is useful and you like it :D
There is just one thing that I did notice when looking at both of these.

Not sure why this is like this any ideas?

I did look at the sfs file and the extension is sfs
Attachments
sfsget 0.2.1.jpg
This is yours notice the .sf
(86.92 KiB) Downloaded 618 times
getsfs 0.2.jpg
The sfs is ok with this one
(68.59 KiB) Downloaded 425 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

missing s at the end of list

#11 Post by L18L »

Thanks for the bug report
oldyeller wrote:Not sure why this is like this any ideas?
No idea why this happens
but a simple workaround is: just append a s to the list of available sfs (AVSFS)

# 20120831 appending missing s to AVSFS
# version 0.2.2

#AVSFS="` curl -s $SERVER | awk -F '"' '/href=".*\.sfs/ {print $8}' | sort -f -u | sed '$s/.$//' `" # 20120831
AVSFS="` curl -s $SERVER | awk -F '"' '/href=".*\.sfs/ {print $8}' | sort -f -u | sed '$s/.$//' `s" # 20120831
Attachments
sfsget-0.2.2.png
bug fix
(12.49 KiB) Downloaded 598 times

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#12 Post by oldyeller »

L18L
thanks for your help on this that worked out just fine.
I added a note for the fix.

I some point I will learn how to do code myself :D :D


Cheers

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#13 Post by RSH »

Hi.

Again a useful script by stu90. 8)

Again i "found" it from a post of oldyeller. :o

Again i could not resist to make a useful and comfortable tool by this inspiration. :lol:

Again i did learn something. 8) :D

What i did use from the script (i do not know such commands and do wish, i would have the bash knowledge of stu90), is:

(already modified for sfs)

Code: Select all

AVSFS="` curl -s $NEWSERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | tr '\n' ' ' | sed '$s/.$//' `"
and (modified for .pet)

Code: Select all

AVPET="` curl -s $NEWSERVER | awk -F '\"' '/href=\".*\.pet/ {print $8}' | sort -f -u | tr '\n' ' ' | sed '$s/.$//' `"
The result is: ---> 8) 8) 8) LazY FReD 0.1! 8) 8) 8)

Image

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#14 Post by oldyeller »

Very nice

I will take a look and check it out. :D :D

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#15 Post by oldyeller »

stu91 or L18L,

How do I put an icon on the bar?

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#16 Post by L18L »

oldyeller wrote:stu91 or L18L,

How do I put an icon on the bar?
Sorry, that is beyond my scope.

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#17 Post by oldyeller »

L18L wrote:
oldyeller wrote:stu91 or L18L,

How do I put an icon on the bar?
Sorry, that is beyond my scope.
thanks for all the help you have been on this, will ask stu91.

Cheers

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#18 Post by RSH »

Hi, Oldyeller...

Setting an Icon in the TitleBar of YAD?

Image

Code is in LazY Puppy 2.0.2 Final Buld 0.0.2 in file /usr/lib/package_creator_fs/package_creator at line 32. Parameter $WIcon is set in the locals.
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#19 Post by oldyeller »

Thanks Rainer,

Will take a look see.

Also what would I need to do to modify this with a list of repo' s.

I like the idea of showing what sfs's are already in mnt home. You did a really great job on LazY FRed.

Cheers.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#20 Post by RSH »

Just do yourself a favor: drink some coffee or watch the news or anything else and wait a little... :D

I will upload LazY FReD 1.0.0 today/tonight. It has a lot of nice new features. One feature is to have multiple lists of server addresses (repos) and new lists can be created and added. It searches now for sfs, pet, iso, tar.gz, .gz, .tgz, .zip, .deb.

And lots more...

Aaahhh - have added around 140 server addresses that will work - right after installing 1.0.0 or loading the sfs. :D
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

Post Reply