PackageEnhancement2007Story
Acceptance Criteria Write scripts to create and populate the database with basic data and, optionally, with sample fictional data (users, projects and tasks), supporting different languages for that basic data. Check and manage non-standard conditions, for example, if the database is already installed. Test the installation process in deep. Make debian packages based on the former scripts. Check the package dependencies and the installation process in deep. If there is time enough, design a method to handle database schema updates and add support for them into the debian installer. Additional Specification Comments Have a look at the current database schema and the default predefined queries. Study what user data can be translated without disturbing the proper application operation. Translate them to create multilingual installation data sets. Learn about some standard ways for deploying a database and its data set in Postgres. Write a script, or enhance the curren one, to handle that deployment. Check as many possible non-standard install conditions and errors as possible. Create a tgz package with that install script included. Learn about making debian packages. Study how the current v1.4 package is done and find a way to improve it with the scripts done before. The package install process should be user friendly and follow the guidelines of standard packages in debian. It should ask the user for her preferred install language and if she want to install the sample example data, check if there is a previous version already installed, give the opportunity to keep the old data, delete it or update it. Think of a way to handle schema updates based in the old and new package versions and the language chosen by the user. Implement it in the Debian package and test the process in deep. If there is plenty of free time, study how to create an rpm package as well and build it. -- EnriqueOcana - 10 Jul 2007 As a hint to learn how to make debian packages as much "standard" as possible, have a look at the following documentation:- http://www.debian.org/doc/maint-guide/
- http://webapps-common.alioth.debian.org/draft/html/
- http://webapps-common.alioth.debian.org/draft-php/html/
- http://people.debian.org/~seanius/policy/dbapp-policy.html/
- http://es.tldp.org/Presentaciones/200002hispalinux/conf-29/29-html/debian-paquetes.html
- http://www.ibm.com/developerworks/linux/library/l-debpkg.html?ca=dgr-lnxw01DebianLinux
- To see a description of a package:
apt-cache show PACKAGE - To see what files come with a package (once installed):
dpkg -L PACKAGE - To remove a package (purge is for config files deletion also):
apt-get remove --purge PACKAGE - More actions: have a look at http://crysol.org/node/59
- http://www.fifi.org/doc/debconf-doc/tutorial.html
- http://xarxantoni.net:8080/mediawiki/index.php/Creaci%C3%B3n_de_paquetes_Debian
COMANDO1=`mktemp`
cat > $COMANDO1 << END
psql template1 -c "CREATE USER $DBUSER WITH ENCRYPTED PASSWORD '$DBPWD'" \
|| { echo "User exists. What do you want?:"
OPTIONS="foo"
echo $OPTIONS
}
END
Well.. i will wait one day. If you know the reason.. you can write to amaneiro@igalia.com
See you later!
-- AndresManeiro - 06 Jul 2007
Yesterday i had problems with here-documents mechanism, for this the $OPTIONS variable don't print his value. It's because the here documents mechanism
COMANDO1=`mktemp`
cat > $COMANDO1 << END
psql template1 -c "CREATE USER $DBUSER WITH ENCRYPTED PASSWORD '$DBPWD'" \
|| { echo "User exists. What do you want?:"
OPTIONS="foo"
echo \$OPTIONS
}
END
But it's very hard if you want to scape more than one variable. In this case, is useful quot or escape the "limit string" at the head of a here document. It disables parameter substitution within its body ( cat > $COMANDO1 << 'END' or cat > $COMANDO1 << \END):
COMANDO1=`mktemp`
cat > $COMANDO1 << 'END'
psql template1 -c "CREATE USER $DBUSER WITH ENCRYPTED PASSWORD '$DBPWD'" \
|| { echo "User exists. What do you want?:"
OPTIONS="foo"
echo $OPTIONS
}
END
-- AndresManeiro - 09 Jul 2007
Today, i completed the deployment scripts to install phpreport aplication# First Step: # If there is an existent user there are some options to choose: # - overwrite it # - keep the existent user and continue the installation process # - abort the installation # # Second Step: # If a database already exists there are some options to choose: # - overwrite it # - keep existent user and go on with the installing # - abort the installation # # Third: LOAD SCHEMA FROM $DBSCHEMA AND POPULATE IT WITH $DBEXAMPLEDATAIn the point 1.1 (overwrite user) the script needs to remove default user 'phpreport' and his owned objects. So, it can delete the existent database BEFORE the second step. The clausule from postgres DROP OWNED
- control.tar.gz: contains configuration files and metadata
- data.tar.gz: contains all the relevant files to install in system
- debian-binary: contains the version number for the binary package
- Step 1: to debianize. In this point we only have to create a FHS (Filesystem Hierarchy Standard) with files that we want to put in final system. So, we have to create a few configuration files need for step 2.
- Step 2: to package. Here, we use the available software tools to create a debian package and other relation files from debianized program.
- Create Filesystem Hierarchy Standard (FHS)
- Create Specific files
- dh_installdirs: create the directory that you indicate in "dirs" file in FHS (not in the system but in you package directory when build the package). I create a file "dirs" look like this..
usr/share/doc/phpreport/ var/www/phpreport/css var/www/phpreport/images var/www/phpreport/include
- dh_installdocs: install the docs indicates by "docs" file in usr/share/doc/package, copyright file and other useful scripts if exists too. I also create a "docs" file look like this ...
sql
- dh_install: install other files in directory as you indicate in file "install". By example, my "install" file look like this ...
*.php var/www/phpreport *.html var/www/phpreport *.dtd var/www/phpreport css var/www/phpreport images var/www/phpreport include var/www/phpreportSo, you can see that debhelper utilities and dh_make are very easy to use and they do your life as debian maintainer more easy! -- AndresManeiro - 01 Aug 2007 Build a debian package is very easy once you had debianized the aplication (view above). Then, you can use dpkg-buildpackage. In your favourite shell write dpkg-buildpackage -rfakeroot -us -uc and wait for outcome (you must do it within your directory web aplication). It create the package.deb file. So, we already have a debian package ready to install. So, you can install this package with dpkg -i package.deb (you must be root for this). But the building process isn't complete yet. I want do that the user can choose some options during install (username and database name by example), for this, i use debconf utility
- dpkg -i => (config, if debconf) => prerinst => postinst => package ok
- A variable exists for help you: DEBCONF_DEBUG. You must set it as DEBCONF_DEBUG="developer". Use it.
- I also recommend you set the answer priority to low (db_set debconf/priority low)
- Finally, you can view the source primitives (db_get, db_set, etc) in /usr/share/debconf/confmodule and go on. I could resolve some trouble quickly because i know source insight script. And never forget source this script in you config (or postinst) script!
| Priority | Low | Medium | High | Critical |
|---|---|---|---|---|
| Conection method (socket unix, tcp/ip, tcp/ip +ssl) | X | - | - | - |
| Admin Autentication Method (ident/password) | X | - | - | - |
| User Autentication Method (ident/password) | X | X | - | - |
| Database Admin Name (for postgres database) | X | - | - | - |
| Database User Name (for your package) | X | - | - | - |
| Password (for you database package) | X | X | X | - |
| Database Name (for you package) | X | - | - | - |
Conection method (socket unix, tcp/ip, tcp/ip +ssl) = unix socket Admin Autentication Method (ident/password) = ident User Autentication Method (ident/password) = ident Database Admin Name (for postgres database) = postgres Database User Name (for your package) = packagename without characters as - or .For instance, if you package name is phpreport-1.5, default value is phpreport15. Database Name (for you package) = phpreport15 (same as above) Password (for you database package) = 12-random-charactersUNISTALL/PURGE APLICATION In order to unintall phpreport, you must difference two actions: desintall (dpkg -r phpreport) and purge (dpkg -P phpreport). First, only uninstall aplication. Second, unistall aplication and purge data (database and configuration files; you can view phpreport.postrm). -- AndresManeiro - 20 Sep 2007 We want install PHPreport with dataset in order to you can to realice some probes with them. So, we did a backup from igalia data (limited from date and others parameters) and change date with other invented date. Today, i wrote a simple script wich changes igalian people names by 100 most frecuent girl spanish names
#!/bin/bash
# Script to change words from file usersfile
# oldusers = path to file with words to replace
# newusers = path to file with words wich you want
numusers=`uniq -u usersfile | wc -l`
for i in `seq 1 $numusers`; do
rpl -wq `sed -n "${i}p" oldusersfile` `sed -n "${i}p" newusersfile` usersfile;
done
Other way to do the same is:
#!/bin/bash
oldusers=${dirbase}/oldusersfile
newusers=${dirbase}/newusersfile
rplusers=${dirbase}/rplusersfile
exec 3<>$oldusers
exec 4<>$newusers
numusers=`uniq -u usersfile | wc -l`
for i in `seq 1 $numusers`; do
read olduser <&3;
read newuser <&4;
rpl -wq $olduser $newuser $rplusers;
done
exec 3>&-
exec 4>&-
-- AndresManeiro - 21 Sep 2007
I improvement scripts above in order to abstract them and resolve some problems:
- files are passed as parameters
- lines can to contain more than a word (by example, a sustitution from bussines names: "bussines inc. from galician")
- protection when number words in old file is largest than a number word into new file (only into script which use rpl whitin sed clausules: the new file are readed recursively, once it is finished, it's started from init)
#!/bin/bash
# Script to change words from file usersfile
# Parameters:
# * file old words ($1)
# * file new words ($2)
# * file to replace ($3)
exec 3<>$1
exec 4<>$2
# use uniq to count num_olds, because once sustituted in $3 never more will be sustituted
num_olds=`uniq -u "$1" | wc -l`
#num_news=`cat "$2" | wc -l`
for i in `seq 1 $num_olds`; do
read old <&3
read new <&4
rpl -wq "$old" "$new" $3
done
exec 3>&-
exec 4>&-
# # WARNING: you must check that num_olds < num_news
# # otherway, sustitutions wich num_olds > num_news are made with ""
# # for correct this, you can use comment code below (more ineficient)
# num_olds=`uniq -u "$1" | wc -l`
# num_news=`cat "$2" | wc -l`
# for i in `seq 1 $num_olds`; do
# # it prevents errors because num_old > num_new
# j=`expr $i % $num_news + 1`
# rpl -wq "`sed -n "${i}p" "$1"`" "`sed -n "${j}p" "$2"`" $3
# done
In other hand, i am having some problem because when i change id_projects because some "projects id" fit in with "areas", and then, they are sustituted too.
-- AndresManeiro - 24 Sep 2007
In order to improvement script eficience i am probing this solution:
exec 3<>$1
exec 4<>$2
# use uniq to count num_olds, because once sustituted in $3 never more will be sustituted
num_olds=`uniq -u "$1" | wc -l`
#num_news=`cat "$2" | wc -l`
for i in `seq 1 $num_olds`; do
read old <&3
read new <&4
pars[i-1]="-e s/\<$old\>/$new/g"
#echo "${pars[i-1]}"
done
#echo "${pars[@]:0}"
sed `echo "${pars[@]:0}"` $3
exec 3>&-
exec 4>&-
I was some problem because i was probing with echo (view comment lines) but i don't use doble-quote to print out. If you print this with echo ${pars[i-1]} the out isn't that you expect. It will be only 's/$old/$new/' because -e is an echo option.
With this line _pars[i-1]="-e s/\<$old\>/$new/g" _ i had two problems:
- First, i wrote pars[i-1]="-e 's/$old/$new/g'" but it didn't work. Then, i delete simple-quote pars[i-1]="-e s/\<$old\>/$new/g" and it goes on.
- Second, i want replace only completely words (view problem here
). For this, i wrapped $old variable between "<>" characters: pars[i-1]="-e s/\<$old\>/$new/g"
- create parea label, csector label, type label
- create customer
- create project
- create city
- create periods to users
- add users to project
- add projects to customers
- insert tasks users
Tasks in this story
div class="twikiTopicInfo twikiRevInfo twikiGrayText twikiMoved"<&/div>-->


