Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on xxx-server and on other Debian QuickServer
# packages.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/xxx-server.e>
#           or at <http://angg.twu.net/e/xxx-server.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######




# «.edrxpage_yada»	(to "edrxpage_yada")
# «.edrxpage_script»	(to "edrxpage_script")
# «.first_doc»  (to "first_doc")




#####
#
# edrxpage as a Debian package, I: using yada
# 2000nov16
#
#####

# «edrxpage_yada»  (to ".edrxpage_yada")
# (to "edrxpage_script")
# (find-es "debiandev" "eev-yada0")
# (find-es "debiandev" "ivox-yada")
# (find-es "locz" "ivox-cgis-yada0")
# (find-fline "~/EEV/debian/")
# (find-fline "~/EEV/debian/packages")

#*
VERSION=$(date +%y%m%d)
rm -Rv /tmp/edrxpage-$VERSION/
mkdir  /tmp/edrxpage-$VERSION/
cd     /tmp/edrxpage-$VERSION/

cp ~/TH/L/a/s/edrx.tgz .
cp ~/eev.el .
cp ~/bin/edrxpage .

cat > README <<'---'
This package contains a copy of my home page and of all the public
stuff in my home directory; run (or inspect) the script
/usr/bin/edrxpage for instructions and pointers to documentation.

Don't change this file by hand, change the script from where it comes
instead:
  (find-es "xxx-server" "edrxpage_yada")
---

cat > copyright <<'---'
2000nov16

The licensing scheme is being discussed with people from the FSF and
will certainly be something between the GPL, the LGPL, the FDL and
public domain.

Please get in touch if these matters are important to you. I'm not
giving high priority to licensing issues now, but I may be wrong. :-)

  Eduardo Ochs
  http://angg.twu.net/
  edrx@inx.com.br
---

mkdir debian

cat > debian/packages <<'---'
Source: edrxpage
Section: devel
Priority: optional
Maintainer: Eduardo Ochs <edrx@inx.com.br>
Standards-Version: 3.0.1
Home-Page: <URL:http://angg.twu.net/>
Description: Edrx's home page and home directory
Copyright: .
 Licensing scheme is being discussed with the FSF.
Major-Changes:
Build: sh
 #./configure --prefix=/usr
 #make
Clean: sh
 #make distclean || true

Package: edrxpage
Architecture: all
Depends: emacsen, tclsh, zsh | zsh30, expect5.24
Description: Edrx's home page and home directory
 See the two manifestos in <http://angg.twu.net/> for the reasons.
 There are copies of them in this package, of course.
Install: sh
 #make install DESTDIR=$ROOT
 # (find-fline "/usr/doc/yada/yada.txt.gz" "yada install")
 # (find-fline "~/EEV/debian/")
 # (find-fline "~/EEV/Makefile")
 #
 yada install -dir  usr/share/emacs/site-lisp/eev
 yada install -into usr/share/emacs/site-lisp/eev eev.el
 yada install -dir  var/lib/edrx
 yada install -into var/lib/edrx edrx.tgz
 yada install -bin -unstripped edrxpage
 yada install -doc  README
 yada install -doc  copyright
---

cp -v README copyright debian/packages ~/EDRXPAGE/

yada yada
debian/yada rebuild rules
debian/rules binary

#*




#####
#
# edrxpage as a Debian package, II: from a tgz and a script
# 2000nov16
#
#####

# «edrxpage_script»  (to ".edrxpage_script")
# (to "edrxpage_yada")
# This blocks depends on lots of things that are created by the
# previous block.
# (find-angg ".zshrc" "makepage_deb")

# (find-fline "~/bin/edrxpage")
#*
makeLedrxtgz
rm -Rv /tmp/ptest/
mkdir  /tmp/ptest/
cd     /tmp/ptest/
cp -v ~/TH/L/a/s/edrx.tgz .
edrxpage make_package	|& tee ~/o

#*

# (code-c-d "ep" "/tmp/ptest/edrxpage-001116/")
# (find-epfile "")
# (find-fline "~/o")
# (find-fline "~/bin/edrxpage")

# Test making the package:
#*
rm -Rv /tmp/testhome/
cat > $EEG <<'---'
  mkdir /tmp/testhome/
  cd    /tmp/testhome/
  cp ~root/bin/edrxpage .
  #./edrxpage
  #./edrxpage download
  cp -v ~root/TH/L/a/s/edrx.tgz .
  ./edrxpage make_package
  ls -lAF
  exit
---
eeg su - beth

dpkg -i /tmp/testhome/edrxpage_*.deb

#*
rm -Rv /tmp/testhome/
cat > $EEG <<'---'
  mkdir /tmp/testhome/
  cd    /tmp/testhome/
  edrxpage
  exit
---
eeg su - beth


#*


  cp ~root/TH/L/a/s/edrx.tgz .




# (find-angg ".zshrc" "find-ess")
# (find-es "apt" "Packages")
# (find-es "apt" "override")
# (find-es "apt" "rebuilding-the-Packages-file")
# (find-es "apt" "Release")
# (find-es "apt" ".disk")
# (find-es "apt" "apt-move")
# (find-es "apt" "missing_upstream_debs1")
# (find-es "apt" "mini-potato")
# (find-es "apt" "mini-potato:override")
# (find-es "apt" "mini-potato:Packages")
# (find-es "apt" "mini-potato:Release")
# (find-es "apt" "mini-potato:.disk")
# (find-es "apt" "mini-potato:disks-i386")
# (find-es "apt" "mini-potato:other_files")
# (find-es "apt" "apt-get_update_upgrade")





#####
#
# Draft of a first doc
# 2000aug08
#
#####

# «first_doc»  (to ".first_doc")
# (find-es "potato" "stop-restart-services")

# Note: this never got ready (though essentially all pieces of it did).
# The idea of what was central moved to:
# (find-es "escripts" "copy_of_edrxs_page")

The Debian QuickServer
======================

Note: the "Quick" in the name is not because it runs exceptionally
quickly (it rather does, but that's secondary) but because it is
extremely quick to install.

Imagine that you need to prepare a dedicated web server for a site. It
needs to have a set of html pages (where some of the pages will be
cgis), plus the database that they use, a mail server to send some
messages to users, ssh and ftp for the site developers, etc.

And you need to be able to set up several clones of the server: one to
replace the main one in case of failure, one for each developer, for
testing... and of course you'll never reach a perfect system, so you
want to be able to distribute changes quickly (and to start with a
system that is as close to perfect as possible, of course).

--end of the blurb--start of the technical details--

The main idea is to prepare a small Debian distribution containing
only the packages that were installed in the machine at which it was
generated (to ensure consistency, and yet small size), and little
else. The most important part of the "little else" is a Debian package
(xxx-server) that contains the pages on the site and lots of notes and
auxiliary scripts; it has an adequate "Dependencies:" field, and so by
installing it we ensure that all the packages that the server needs to
run will be installed. It also has a script -- that must be run by
hand for safety -- that unpacks the developers' home directories, and
thus installing the system from scratch is a snap: ask dselect to
install the "xxx-server" package, and after it has finished run the
script; the steps for fine-tuning apache, apt and other programs are
kept in e-scripts, and also those for remaking the xxx-server .deb
from the installed stuff, and even to make a CD-ROM from the result.

Many Linux distributions can be kept in the same machine, each one in
a different partition; we can boot from any one of them, and they can
even be run at the same time with chroot (we can even configure
/etc/inittab to dedicate some vt logins to each one). As we can't have
two programs listening to the same port at the same time --- and so
it's impossible to keep two http servers at port 80 at the same time,
for example --- it is typical to activate all daemons from one of the
distributions and shut down the daemons from the others; there are
scripts to do that. With that we can switch from a "Debian server" to
a "RedHat server" and back in seconds, for example, which can very
good for checking distro differences and RedHat bugs. :-)

Notes:

  1) at this moment all tests are being done on machines with several
  Debians only -- no RedHats right now.

  2) It is not necessary to reboot the system to install Debian in
  another partition: we can unpack the programs from the boot floppies
  and run them (to be more precise: run dbootstrap) using chroot, and
  after that we can "log in for the first time" in the new system also
  using chroot to do the compulsory dselect stage, all that keeping an
  editor running in other window to take notes; this is how the notes
  at the link below were taken.

  3) ...

Booting is done by Grub. With that we can even have bootable
FreeBSD/OpenBSD/Hurd partitions --- and it is always instructive to
see how OpenBSD configures things.

Several Linux kernels can be installed at the same Debian partition at
the same time. Thanks to the "flavours" trick of make-kpkg they can
store their modules in different directories (/lib/modules/2.2.16 and
/lib/modules/2.2.16-minimal, for example). Each kernel that we compile
using make-kpkg becomes a Debian package, and so it's not necessary to
recompile them at each installation.




TO DO:

* Some cgis like dwww should never be run by outside users; ideally
  Apache would serve two virtual domains with different document roots
  and different configurations, and one of them would only be
  accessible by machines in the local net. I don't know how to do that
  (yet).

* Besides the minimal repository of .debs that comes in the CD we may
  want to keep another one, a partial mirror of the Debian upstream
  repositories; it should be made accessible by http/ftp for local
  machines, and it must have "Packages" files that reflect the fact
  that it is only partial; also we may want to keep some old packages
  in another local repository to let us reproduce old bugs (ok, not
  many people want to do that, but I do sometimes). And it must use as
  many hard links as possible to save space. Status of this to-do item:
  I'm written some horrible e-scripts that sort of do the job but now
  I've thrown them out and I'm learning Python to do something cleaner.

* It should be easier to modify the script that makes the xxx-server
  package to make it include the files from a specific web site (it
  then becomes a "yyy-server").






# (find-angg "IVOX/")
# (find-es "hd" "generate_part_of_fstab")




#####
#
# Processing the .debs list with python
# 2000aug21
#
#####

# Note that this is MUCH slower than using Icon to do the same job.
# (find-es "apt" "missing_upstream_debs1")
#*
cd ~/DEBREP/
cat $SDEBIAN/ls-lR.i \
    $SNUDEBIAN/ls-lR.i \
  | perl -nle ' s/^[ 0-9]+([^ ]+)( ->.*$)?/\1/; print' \
  | grep 'binary-i386.*\.deb$' \
  | grep 'potato.*binary-i386' \
  > upstreamdebs

#*
# (find-es "python" "compiling")

cd ~/DEBREP/
rm -v updebs*
(echo 'updebs = {'
 cat upstreamdebs \
  | perl -nle ' m:^(.*)/([^/_]+)_([^/_]+)\.deb$: &&
      print "  \047$2\047:\t(\047$3\047, \047$1\047),"
    '
 echo '}'
) > updebs.py
laf updebs*

time python /usr/lib/python1.5/compileall.py -l .
python updebs.pyc
laf updebs*

#*





#####
#
# Adding the control files to /debian 
# 2000aug21
#
#####

#*
# «override»
# (find-es "apt" "override")
# Copy the override files:

cd /debian/
function cpzcat () {
  mkdir -p $2
  cp -v $1/$2/$3 $2/$3
  zcat $2/$3 > $2/$(basename $3 .gz)
}
cpzcat $SDEBIAN indices override.potato.contrib.gz
cpzcat $SDEBIAN indices override.potato.gz
cpzcat $SDEBIAN indices override.potato.non-free.gz
cpzcat $SNUDEBIAN indices-non-US override.potato.contrib.gz
cpzcat $SNUDEBIAN indices-non-US override.potato.gz
cpzcat $SNUDEBIAN indices-non-US override.potato.non-free.gz
laf indices indices-non-US

#*
# «Packages»
# (find-es "apt" "Packages")

cd /debian/
function dpkg-scanp () {
  mkdir -p dists/$1/$2/binary-i386/
  (dpkg-scanpackages dists/$1/$2/binary-i386 $3 \
    > dists/$1/$2/binary-i386/Packages \
  ) |& tee /tmp/odsp$4
}
dpkg-scanp potato contrib  indices/override.potato.contrib   c
dpkg-scanp potato main     indices/override.potato           m
dpkg-scanp potato non-free indices/override.potato.non-free  nf
dpkg-scanp potato non-US/contrib  indices-non-US/override.potato.contrib  nuc
dpkg-scanp potato non-US/main     indices-non-US/override.potato          num
dpkg-scanp potato non-US/non-free indices-non-US/override.potato.non-free nunf

dpkg-scanp unstable local/main     /dev/null lm
dpkg-scanp unstable local/non-free /dev/null lnf

# What about Packages-Master-i386?



#*
# Making apt use the repository in /debian/
# (find-fline "/etc/apt/sources.list")
#
# deb file:/debian dists/potato/main/binary-i386/ 
# deb file:/debian dists/potato/contrib/binary-i386/ 
# deb file:/debian dists/potato/non-free/binary-i386/ 
# deb file:/debian dists/potato/non-US/main/binary-i386/ 
# deb file:/debian dists/potato/non-US/contrib/binary-i386/ 
# deb file:/debian dists/potato/non-US/non-free/binary-i386/ 
#
# Or:
#
# deb file:/debian potato main contrib non-free
# deb file:/debian potato/non-US main contrib non-free

apt-get update

#*








# (find-es "apt" "Packages")
# (find-es "apt" "override")
# (find-es "apt" "rebuilding-the-Packages-file")
# (find-es "apt" "Release")
# (find-es "apt" ".disk")
# (find-es "apt" "apt-move")

# (find-es "apt" "missing_upstream_debs1")
# (find-es "apt" "mini-potato")
# (find-es "apt" "mini-potato:override")
# (find-es "apt" "mini-potato:Packages")
# (find-es "apt" "mini-potato:Release")
# (find-es "apt" "mini-potato:.disk")
# (find-es "apt" "mini-potato:disks-i386")
# (find-es "apt" "mini-potato:other_files")
# (find-es "apt" "apt-get_update_upgrade")







#  Local Variables:
#  coding:               utf-8-unix
#  End: