Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 24 May 2015, 11:39
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
Script to make a SeaMonkey sfs
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
Uten


Joined: 29 Jan 2008
Posts: 91

PostPosted: Wed 23 Jan 2013, 16:43    Post_subject:  Script to make a SeaMonkey sfs  

It was time to update this script a bit. The following script is the one I use myself at the moment, but it is work in progress.
Code:

#!/bin/bash
###############################################################################
#   Script to download and make a puppylinux style seamonkey.sfs
#
#   NOTICE: In puppylinux the squashfs hiaracy as seen from the
#           systems perspective is Savefile, pup_xxx.sfs(the system
#           pup), then loaded sfs files in their load order(?)
#
#           Because of this we can not replace the original soft links
#           in pup_xxx's /usr/[bin|lib] with our own in the sfs file.
#
#           I can think of two solutions at the moment.
#           1) To place the links in a path with precidence to /usr/bin
#              in $PATH
#           2) Make a fix script to do the changes the next time you
#              boot the computer. The fix script may be placed in
#              /root/startup
#
#           This script use solution nr 1.
#             
#
#   CONFIGURE: Search for TODO: and select accordingly.
#   NOTICE:    This script does not create menu/desktop links.
#              Neither the mozstart stuff. Look at TODO's
#   NOTICE:    Apparently Java wil not work with seamonkey.
#              https://bugzilla.mozilla.org/show_bug.cgi?id=754622
#   NOTICE:    Version 2.17.1 did not contain everything. Just the
#              difference from version 2.17. As fare as I know this
#              was not the case with the 2.16 series. This was changed after
#              a few days
#
#   TODO:      Merge with woof template to get mozstart and desktop links
#              ../woof-tree/packages-templates/seamonkey/ 
#              /usr/local/lib/X11/mini-icons/seamonkey16.xpm
#              /usr/local/lib/X11/mini-icons/mozilla.xpm
#              /usr/local/lib/X11/mini-icons/mozilla-bin.xpm
#
###############################################################################
#
# sfs_load will check for files in the following folders and process accordingly
# $MNTPNT/lib/modules
# $MNTPNT/usr/share/fonts
# $MNTPNT/usr/share/applications
# $MNTPNT/etc/init.d
# $MNTPNT/root/Startup
# $MNTPNT/etc/profile.d
# $MNTPNT/usr/share/icons/hicolor
# $MNTPNT/usr/share/glib-2.0/schemas/
# $MNTPNT/root/Choices/ROX-Filer/PuppyPin
# Save params
PARAMS=$@
WORK_FOLDER=${WORK_FOLDER:-"$(pwd)"}
REPOSITORY_FOLDER=/mnt/sda1/packages
REPOSITORY_FOLDER=${REPOSITORY_FOLDER:-"$(pwd)"}

# TODO: LANG_ID could be en-GB, en-US, uk, it, and so one find yours
#       on the mozilla site. Tested with nb-NO and en-GB
# TODO: Modify the url?
LANG_ID="en-GB" #TODO: Hardcoded in DOWNLOAD_URL
DOWNLOAD_URL=
SEAMONKEY_VERSION=
SCRIPT_VERSION="0.6"
#
# TODO: Replace the version numbers so you get the one you want.
#       Script tested with SEAMONKEY_VERSION="2.15"
# RELEASES URL: http://www.seamonkey-project.org/releases/
#SAMPLE ULR: https://download.mozilla.org/?product=seamonkey-2.16&os=linux&lang=en-GB
function err() { # [errid] [msg]
   ret=${1:-1}
   echo "ERROR: at ${BASH_LINENO[1]} errid:=$1 :: $2"
   return $ret
}
function get_version_info() {
   if [  $SEAMONKEY_VERSION=='' ]; then
      #TODO: What if we do not have net connection?
      FOO_URL=$(wget --quiet -O - http://www.seamonkey-project.org/releases/ |sed -n  's/.*\(https.*linux.*en-GB\).*/\1/p')

      SEAMONKEY_VERSION=$(echo $FOO_URL|sed -n 's/[[:print:]]*-\([0-9.]\+\).*/\1/pg')
   fi
   if [ -z $SEAMONKEY_VERSION ]; then
      echo "WARNING: SEAMONKEY_VERSION ("$SEAMONKEY_VERSION")is unresolved (network problem?). Terminating script"
      exit 0   
   fi
   #SEAMONKEY_VERSION="2.16"

   TARGET_PATH=seamonkey-$SEAMONKEY_VERSION
   DOWNLOAD_URL=http://download.cdn.mozilla.net/pub/mozilla.org/seamonkey/releases/$SEAMONKEY_VERSION/linux-i686/$LANG_ID/$TARGET_PATH.tar.bz2
   echo "DOWNLOAD_URL:="$DOWNLOAD_URL

}
function help() {
   cat << EOF
   usage $0 [--version version_id] [--language lang_id] [options]
      --help|-h      Show help information
      --clean|-c      Removes seamonkey-X.ZZ.sfs and directroy seamonkey-X.ZZ
      --pristine|-p   Same as --clean and removes seamonkey-X.ZZ.tar.bz to ensure
                  new download.
               
      --version|-v version_id:    Get and build seamonkey sfs of version_id.
      --language|-l lang_id:    Get this language. default is en-GB
TODO:   --sfs|-s        Only make the sfs file (if he directroy is available)
TODO:   --unpack|-u     Only download and unpack. Use this before handtailoring.
      When no options are given the sfs file is verified to be the latest
      or recreated if it is not or does not exist.

EOF
   
}
function clean_workfolder_and_package() { #
   ret=0
   rm -f $TARGET_PATH.tar.bz2
   rm -rf $TARGET_PATH
   return 0
}
function clean() {
   rm $TARGET_PATH.sfs
   rm -rf $TARGET_PATH
}
function pristine() {
   clean
   rm $TARGET_PATH.tar.bz2
}
function download() {
   #
   # Download seamonkey from mozilla
   echo "PROCESS: download $DOWNLOAD_URL"
   if [ -e $REPOSITORY_FOLDER/$TARGET_PATH.tar.bz2 ]; then
      cp -f $REPOSITORY_FOLDER/$TARGET_PATH.tar.bz2 $WORK_FOLDER
   else
      wget --no-check-certificate -O $TARGET_PATH.tar.bz2 -nc $DOWNLOAD_URL
      if [ -d $REPOSITORY_FOLDER ]; then
         cp $TARGET_PATH.tar.bz2 $REPOSITORY_FOLDER/
      fi
   fi
}
function include_selfe() { #
   local ret=0
   mkdir -p "$WORK_FOLDER/$TARGET_PATH/root/my-applications/bin"
   cp "$0" "$WORK_FOLDER/$TARGET_PATH/root/my-applications/bin/"
   return $ret
}
function unpack () {
   # TODO_CODE: Check for errors.
   if [ -e $TARGET_PATH.tar.bz2 ]; then
      #File is present so unpack it to the opt folder
      if [ ! -e ./$TARGET_PATH/opt ]; then
         mkdir -p $TARGET_PATH/opt
      fi
      if [ ! -e $TARGET_PATH/opt/seamonkey ]; then
         echo unpacking $TARGET_PATH.tar.bz2
         #NOTICE: -axf must be followed by the file
         tar --checkpoint=500 --directory=./$TARGET_PATH/opt/ -axf  ./$TARGET_PATH.tar.bz2
      fi
   else
      echo "WARNING: $TARGET_PATH.tar.bz2 is not available?"
      ls
      exit 0
   fi
}
function relink(){
   # TODO_CODE: Check for errors.
   # Create folders and links to run seamonkey
   
   mkdir -p ./$TARGET_PATH/bin/
   mkdir -p ./$TARGET_PATH/usr/bin
   mkdir -p ./$TARGET_PATH/usr/lib
   cd $TARGET_PATH/
   ln -f -s -t ./usr/lib/ /opt/seamonkey
   # TODO: a link in ./usr/bin wil not replace the original link.
   # The official pup_xxx.sfs has precedence and is only replaced
   # by stuff in the personal save file
   # RESOURCE: http://puppylinux.com/development/howpuppyworks.html
   #ln -s -f -t ./usr/bin/ /opt/seamonkey/seamonkey
   # SOULUTION: (Sort of) place the links in an earlyer $PATH path.
   ln -s -f -t ./bin/ /opt/seamonkey/seamonkey
   cd ./bin
   ln -s -f seamonkey mozilla
   # TODO_CODE: Check for errors
   #
}
function set_desktop_icons() { #
   local ret=0
   return $ret
}
function set_menu_items() { #
   local ret=0
   return $ret
}
function write_init_d_script() { #[work_path] [sfs_root_path]
   # TODO: On startup we should check for updates, maybe ask for settings
   # TODO: On shutdown we should relink seamonkey.sfs to seamonkey_[version].sfs
   local ret=0
   local ret=0
   local foo=${PKG_FILE_NAME%\.tar*}
   local sfs_root_path=${2:-"$foo"}
   local work_path=${1:-$WORK_FOLDER}

   if [ ! -e $work_path/$sfs_root_path/etc/init.d/ ]; then
      mkdir -p $work_path/$sfs_root_path/etc/init.d/
      err $? "mkdir failed to create: $work_path/etc/init.d/"
      ret=$?
   fi   
   if [ $ret -eq 0 ]; then
   msg "write: $work_path/$sfs_root_path/etc/init.d/go.sfs.sh"
#   cat << 'EOF' > $work_path/$sfs_root_path/etc/init.d/seamonkey.sfs.sh
#   
#EOF
   fi
   return $ret   
}
function plugins() {
   # TODO_CODE: Add plugins, libflash and so on.
   echo "TODO: plugins code"
}

function java () {
   if [ -e java-sfs-relink.sh ]; then
      # . java-sfs-relink.sh
      echo "NO JAVA!"
   else
      echo "NO JAVA! Javascript not found."
   fi
}
function make_sfs() {   
   #
   # Create the sfs file   

   if [ -z $WORK_FOLDER -o  -z $TARGET_PATH -o ! -d "$WORK_FOLDER" -o ! -d "$WORK_FOLDER/$TARGET_PATH" ]; then
      echo "WARNING: could not locate:"
      echo "    WORK_FOLDER:=$WORK_FOLDER"
      echo " or "
      echo "    TARGET_PATH:=$TARGET_PATH"
      exit 0
   else
      cd $WORK_FOLDER   
      echo "mksquashfs  $WORK_FOLDER/$TARGET_PATH/ $TARGET_PATH.sfs -noappend"
      mksquashfs  $WORK_FOLDER/$TARGET_PATH/ $TARGET_PATH.sfs -noappend
   fi
}
function do_all() {
   clean
   echo "TARGET_PATH:=$TARGET_PATH"   
   download
   echo "PROCESS: unpack"
   unpack
   echo "PROCESS: relink"
   relink
   echo "PROCESS: plugins"
   plugins
   echo "PROCESS: java :NOTE java does not work with seamonkey-2.1x"
   java
   echo "PROCESS: include_selfe"
   include_selfe
   echo "PROCESS: write_desktop_menu_files"
   write_desktop_menu_files
   echo "PROCESS: make sfs"
   make_sfs   
   #clean_workfolder_and_package
}
function write_desktop_menu_files() { #work_folder
   # /usr/share/applications
   ret=0
   mkdir -p $WORK_FOLDER/$TARGET_PATH/usr/share/applications
   echo "mkdir returned $? making: $WORK_FOLDER/usr/share/applications"
   [ ! -d $WORK_FOLDER/$TARGET_PATH/usr/share/applications ] && echo "WTF!"
   cat << 'EOF' > $WORK_FOLDER/$TARGET_PATH/usr/share/applications/seamonkey.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Seamonkey
Icon=/opt/seamonkey/chrome/icons/default/default48.png
Comment=Seamonkey web browser
Exec=seamonkey
Terminal=false
Type=Application
Categories=X-Internet-browser
GenericName=Seamonkey web browser
EOF

   cat << 'EOF' > $WORK_FOLDER/$TARGET_PATH/usr/share/applications/seamonkeyPrivate.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Seamonkey Private
Icon=/opt/seamonkey/chrome/icons/default/default48.png
Comment=Seamonkey web browser
Exec=seamonkey -private
Terminal=false
Type=Application
Categories=X-Internet-browser
GenericName=Seamonkey web browser private session
EOF

   cat << 'EOF' > $WORK_FOLDER/$TARGET_PATH/usr/share/applications/seamonkeyEditor.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Seamonkey Editor
Icon=/opt/seamonkey/chrome/icons/default/editorWindow48.png
Comment=Seamonkey web browser
Exec=seamonkey -edit
Terminal=false
Type=Application
Categories=X-Internet-browser
GenericName=Seamonkey editor
EOF

   cat << 'EOF' > $WORK_FOLDER/$TARGET_PATH/usr/share/applications/seamonkeyAddressbook.desktop
[Desktop Entry]
Encoding=UTF-8
Name=SeamonkeyAddressbook
Icon=/opt/seamonkey/chrome/icons/default/addressbookWindow48.png
Comment=Seamonkey Addressbook
Exec=seamonkey -addressbook
Terminal=false
Type=Application
Categories=X-Internet-browser
GenericName=Seamonkey Addressbook
EOF
   
   cat << 'EOF' > $WORK_FOLDER/$TARGET_PATH/usr/share/applications/seamonkeyEmail.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Seamonkey Mail
Icon=/opt/seamonkey/chrome/icons/default//msgcomposeWindow48.png
Comment=Seamonkey email
Exec=seamonkey -mail
Terminal=false
Type=Application
Categories=X-Internet-browser
GenericName=Seamonkey Mail
EOF

   return $ret
}

function main() {   
   if [ "$WORK_FOLDER"=="${0%/*}" ] || [ "${0%/*}"=="." ]; then
      WORK_FOLDER="/tmp"
      echo $WORK_FOLDER
   fi
   cd $WORK_FOLDER

   case $1 in
      '-h'|'--help')
         help
         exit 0 ;;   
   esac
   echo "arg:=$1"
   echo "PROCESS: get_version_info"
   # We need the latest version info.
   # We allso need this info in clean and pristine
   # TODO: Lett user overide version info.
   get_version_info
   #TODO: parse --language and --version info
   case $1 in
      '-language'|'--language'|'-l')
         #do a shift, save the value to LANG_ID and do another shift, recursiv call to main
         ;;
      '-version'|'--version'|'-v')
         #do a shift, save the value to SEAMONKEY_VERSION and do another shift , recursiv call to main
         echo "Version $SCRIPT_VERSION $0"
         exit 0
         ;;
      '-pristine'|'--pristine'|'-p')
         pristine
         do_all ;;
      '-clean'|'--clean'|'-c')
         clean
         do_all ;;
      -*)
         echo "Unknown argument: " $*;;
      *)

         if [ -e $TARGET_PATH ]; then
            make_sfs
         else
            do_all
         fi ;;
   esac
}

echo "$0 ARGS: $@"
main "$@"

EDIT: Updated script. Previous script is below.
Back to top
View user's profile Send_private_message 
Uten


Joined: 29 Jan 2008
Posts: 91

PostPosted: Sat 04 Apr 2015, 16:52    Post_subject:  

Original post:
Think the script explains itself. I tested it with precise
Code:
#!/bin/bash
###################################################################
#   Script to download and make a puppylinux style seamonkey.sfs
#
#   NOTICE: In puppylinux the squashfs hiaracy as seen from the
#           systems perspective is Savefile, pup_xxx.sfs(the system
#           pup), then loaded sfs files in their load order(?)
#
#           Because of this we can not replace the original soft links
#           in pup_xxx's /usr/[bin|lib] with our own in the sfs file.
#
#           I can think of two solutions at the moment.
#           1) To place the links in a path with precidence to /usr/bin
#              in $PATH
#           2) Make a fix script to do the changes the next time you
#              boot the computer. The fix script may be placed in
#              /root/startup
#
#           This script use solution nr 1.
#             
#
#   CONFIGURE: Search for TODO: and select accordingly.
#   NOTICE:    This script does not create menu/desktop links.
#             
####################################################################

# Save params
PARAMS=$*
WORK_FOLDER=$(pwd)
#
# TODO: Replace the version numbers so you get the one you want.
#       Script tested with SEAMONKEY_VERSION="2.15"
SEMONKEY_VERSION="2.15.1"
#
# TODO: LANG_ID could be en-GB, en-US, uk, it, and so one find yours
#       on the mozilla site. Tested with nb-NO and en-GB
LANG_ID="en-GB"
#
# TODO: Modify the url?
DOWNLOAD_URL=http://download.cdn.mozilla.net/pub/mozilla.org/seamonkey/releases/$SEMONKEY_VERSION/linux-i686/$LANG_ID/seamonkey-$SEMONKEY_VERSION.tar.bz2

if [ "$1" == '--help'  -o  "$1" == '' ]; then
   echo ""
   echo "seamonkey-sfs.sh [--clean|--pristine|--help]"
   echo
   echo "Without options nothing is removed and only simple checks are done before sfs file is made"
   echo ""
   echo "--clean removes seamonkey-$SEMONKEY_VERSION.sfs and"
   echo "directory seamonkey-$SEMONKEY_VERSION"
   echo ""
   echo "--pristine: removes as clean and the file seamonkey-$SEMONKEY_VERSION.tar.bz2"
   echo ""
   echo "--help prints this information"
   echo ""
   exit 0
fi

if [ "$1" == '--clean' ]; then
   #rm seamonkey-$SEMONKEY_VERSION.tar.bz2
   rm seamonkey-$SEMONKEY_VERSION.sfs
   rm -rf seamonkey-$SEMONKEY_VERSION
fi
if [ "$1" == '--pristine' ]; then
   rm seamonkey-$SEMONKEY_VERSION.tar.bz2
   rm seamonkey-$SEMONKEY_VERSION.sfs
   rm -rf seamonkey-$SEMONKEY_VERSION
fi
#
# Download seamonkey from mozilla
wget -nc $DOWNLOAD_URL
# TODO_CODE: Check for errors.
if [ -e seamonkey-$SEMONKEY_VERSION.tar.bz2 ]; then
   #File is present so unpack it to the opt folder
   if [ ! -e ./seamonkey-$SEMONKEY_VERSION/opt ]; then
      mkdir -p seamonkey-$SEMONKEY_VERSION/opt
   fi
   if [ ! -e seamonkey-$SEMONKEY_VERSION/opt/seamonkey ]; then
      echo unpacking seamonkey-$SEMONKEY_VERSION.tar.bz2
      #NOTICE: -axf must be followed by the file
      tar --checkpoint=500 --directory=./seamonkey-$SEMONKEY_VERSION/opt/ -axf  ./seamonkey-$SEMONKEY_VERSION.tar.bz2
   fi
   # TODO_CODE: Check for errors.
   # Create folders and links to run seamonkey
   mkdir -p ./seamonkey-$SEMONKEY_VERSION/bin/
   mkdir -p ./seamonkey-$SEMONKEY_VERSION/usr/bin
   mkdir -p ./seamonkey-$SEMONKEY_VERSION/usr/lib
   cd seamonkey-$SEMONKEY_VERSION/
   ln -f -s -t ./usr/lib/ /opt/seamonkey
   # TODO: a link in ./usr/bin wil not replace the original link.
   # The official pup_xxx.sfs has precedence and is only replaced
   # by stuff in the personal save file
   # RESOURCE: http://puppylinux.com/development/howpuppyworks.html
   #ln -s -f -t ./usr/bin/ /opt/seamonkey/seamonkey
   # SOULUTION: (Sort of) place the links in an earlyer $PATH path.
   ln -s -f -t ./bin/ /opt/seamonkey/seamonkey
   cd ./bin
   ln -s -f seamonkey mozilla
   # TODO_CODE: Check for errors
   #
   # TODO_CODE: Add plugins, libflash and so on.
   
   #
   # Create the sfs file   
   cd $WORK_FOLDER
   mksquashfs  $WORK_FOLDER/seamonkey-$SEMONKEY_VERSION/ seamonkey-$SEMONKEY_VERSION.sfs -noappend
   #
fi
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1217s ][ Queries: 12 (0.0225s) ][ GZIP on ]