Installing a package manager - IPKG

I found a awesome article about install a package manager in a NAS at http://www.openstora.com/wiki/index.php?title=Installing_a_package_manager. The good news is: the CPU of this NAS is binary compatible with G-Connect, both are ARMv5.  So basically to have a packaging system on G-Connect it's necessary "create" a new /opt inside hard drive and set some new paths to the future installed packages. The linux installed in G-Connect comes without anything installed inside /opt so "move" this directory to a new path doesn't change anything important.  let's start!



1- Create a new opt in hard drive:


# cd /
# mv opt opt-OLD
# ln -s /mnt/eSata/root/opt opt

Your / will look like this:

drwxr-xr-x  2 root root  6064 Feb 17 11:17 bin
drwxr-xr-x  2 root root   160 Jul 28  2011 boot
drwxr-xr-x  9 root root 15504 Feb 18 20:15 dev
drwxr-xr-x 61 root root 12992 Feb 28 13:14 etc
-rw-r--r--  1 root root     3 Nov  3  2008 fsckoptions                                                                                         
drwxr-xr-x 13 root root   888 Feb 18 14:21 home
drwxr-xr-x  8 root root 10512 Jul 29  2011 lib
drwxrwxr-x  3 root www    368 May 23  2012 links
drwxr-xr-x 18 root root  1184 Nov 12  2010 locale
drwxr-xr-x  2 root root   160 May 11  2009 media
drwxr-xr-x  4 root root   288 Feb 18 20:16 mnt
lrwxrwxrwx  1 root root    19 Feb 17 11:28 opt -> /mnt/eSata/root/opt
drwxr-xr-x  2 root root   160 May 11  2009 opt-OLD
dr-xr-xr-x 81 root root     0 Dec 31  1969 proc
drwxr-x---  4 root root   776 Feb 18 20:14 root
drwxr-xr-x  2 root root 10352 Feb 17 11:17 sbin
drwxr-xr-x  2 root root   160 May 11  2009 selinux
drwxr-xr-x  2 root root   160 May 11  2009 srv
drwxr-xr-x 11 root root     0 Dec 31  1969 sys
drwxrwxrwt 16 root root   320 Feb 28 17:19 tmp
drwxr-xr-x 14 root root  1000 Sep 18  2008 usr
drwxr-xr-x 20 root root  1384 Apr  6  2010 var

2 - Installing the IPKG

Now let's install the ipkg manager.

# cd /opt
# wget  http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/ipkg-opt_0.99.163-10_arm.ipk
# tar -xzf ipkg-opt_0.99.163-10_arm.ipk
# cp ./data.tar.gz /data.tar.gz
# cd /
# tar -xzf data.tar.gz
# rm  data.tar.gz

3- Cleaning the temporary files:

You can remove this old files also:

# cd /opt
# rm control.tar.gz
# rm debian.binary
# rm ipkg-opt_0.99.163-10_arm.ipk


4- Updating the IPKG

Now  let's set the source of packages and update the local list
# echo src cs08q1armel http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable >> /opt/etc/ipkg.conf
# /opt/bin/ipkg update                                                                                                                 
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/Packages                                                        
Updated list of available packages in /opt/lib/ipkg/lists/cs08q1armel                                                                          
Successfully terminated.

A little help of ipkg.

ipkg: ipkg must have one sub-command argument                                                                                                  
ipkg version 0.99.163                                                                                                                          
usage: ipkg [options...] sub-command [arguments...]                                                                                            
where sub-command is one of:                                                                                                                   
                                                                                                                                              
Package Manipulation:                                                                                                                          
       update                  Update list of available packages                                                                              
       upgrade                 Upgrade all installed packages to latest version                                                               
       install <pkg>           Download and install <pkg> (and dependencies)                                                                  
       install <file.ipk>      Install package <file.ipk>                                                                                     
       configure [<pkg>]       Configure unpacked packages                                                                                    
       remove <pkg|regexp>     Remove package <pkg|packages following regexp>                                                                 
       flag <flag> <pkg> ...   Flag package(s) <pkg>                                                                                          
        <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)                                                                   
                                                                                                                                              
Informational Commands:                                                                                                                        
       list                    List available packages and descriptions                                                                       
       list_installed          List all and only the installed packages and description                                                       
       files <pkg>             List all files belonging to <pkg>                                                                              
       search <file|regexp>            Search for a package providing <file>                                                                  
       info [pkg|regexp]               Display all info for <pkg>                                                                             
       status [pkg|regexp]             Display all status for <pkg>                                                                           
       download <pkg>          Download <pkg> to current directory.                                                                           
       compare_versions <v1> <op> <v2>                                                                                                        
                                 compare versions using <= < > >= = << >>                                                                     
       print_architecture      prints the architecture.                                                                                       
       print_installation_architecture                                                                                                        
       whatdepends [-A] [pkgname|pat]+                                                                                                        
       whatdependsrec [-A] [pkgname|pat]+                                                                                                     
       whatprovides [-A] [pkgname|pat]+                                                                                                       
       whatconflicts [-A] [pkgname|pat]+                                                                                                      
       whatreplaces [-A] [pkgname|pat]+                                                                                                       
                               prints the installation architecture.                                                                          
                                                                                                                                              
Options:                                                                                                                                       
       -A                      Query all packages with whatdepends, whatprovides, whatreplaces, whatconflicts                                 
       -V <level>               Set verbosity level to <level>. If no value is                                                                
       --verbosity <level>      provided increase verbosity by one. Verbosity levels:                                                         
                                0 errors only                                                                                                 
                                1 normal messages (default)                                                                                   
                                2 informative messages                                                                                        
                                3 debug output                                                                                                
       -f <conf_file>          Use <conf_file> as the ipkg configuration file                                                                 
       -conf <conf_file>       Default configuration file location                                                                            
                               is /opt/etc/ipkg.conf                                                                                          
       -d <dest_name>          Use <dest_name> as the the root directory for                                                                  
       -dest <dest_name>       package installation, removal, upgrading.                                                                      
                               <dest_name> should be a defined dest name from                                                                 
                               the configuration file, (but can also be a                                                                     
                               directory name in a pinch).                                                                                    
       -o <offline_root>       Use <offline_root> as the root directory for                                                                   
       -offline <offline_root> offline installation of packages.                                                                              
       -verbose_wget           more wget messages                                                                                             
       Force Options (use when ipkg is too smart for its own good):                                                                           
       -force-depends          Make dependency checks warnings instead of errors                                                              
                                       Install/remove package in spite of failed dependences                                                  
       -force-defaults         Use default options for questions asked by ipkg.                                                               
                               (no prompts). Note that this will not prevent                                                                  
                               package installation scripts from prompting.                                                                   
       -force-reinstall        Allow ipkg to reinstall a package.                                                                             
       -force-overwrite        Allow ipkg to overwrite files from another package during an install.                                          
       -force-downgrade        Allow ipkg to downgrade packages.                                                                              
       -force_space            Install even if there does not seem to be enough space.                                                        
       -noaction               No action -- test only                                                                                         
       -nodeps                 Do not follow dependences                                                                                      
       -force-removal-of-dependent-packages                                                                                                   
       -recursive              Allow ipkg to remove package and all that depend on it.                                                        
       -test                   No action -- test only                                                                                         
       -t                      Specify tmp-dir.                                                                                               
       --tmp-dir               Specify tmp-dir.                                                                                               
                                                                                                                                              
       regexp could be something like 'pkgname*' '*file*' or similar                                                                          
       eg: ipkg info 'libstd*'  or ipkg search '*libop*' or ipkg remove 'libncur*'

A list of available packages:

#/opt/bin/ipkg list

To install anything:

#/opt/bin/ipkg install packagename

OPTIONAL:


To include all new binaries in default path I change/include this contents in environment and profile files.
# cat /etc/environment
                                                                                                        
PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/sbin:/opt/sbin:/usr/sbin:/sbin:

# vi /etc/profile
Then edited this section to read:
# Path manipulation
if [ "$EUID" = "0" ]; then
       pathmunge /opt/bin
       pathmunge /sbin
       pathmunge /opt/sbin
       pathmunge /usr/sbin
       pathmunge /usr/local/sbin
fi

More information about IPKG - http://en.wikipedia.org/wiki/Ipkg