unstack, sort: cleanup and improvement
[minix.git] / releasetools / release.functions
blob2719f0af346bdba674bad00657ec09e8097e6e9d
2 make_hdimage()
4         dd if=$TMPDISKUSR of=usrimage bs=$BS count=$USRBLOCKS
6         rootsize=`stat -f %z rootimage`
7         usrsize=`stat -f %z usrimage`
9         rootsects=`expr $rootsize / 512`
10         usrsects=`expr $usrsize / 512`
12         # installboot -m needs at least 1KB 
13         dd < /dev/zero >tmpimage count=2
14         partition -fm tmpimage 2 81:$rootsects* 0:0 81:$usrsects
15         installboot_nbsd -m tmpimage /usr/mdec/mbr
16         dd < tmpimage > subpart count=1
18         primsects=`expr 1 + $rootsects + $usrsects`
19         cyl=`expr '(' $primsects ')' / $secs + 1`
20         padsects=`expr $cyl \* $secs - 1 - $primsects`
22         { dd < /dev/zero count=1
23                 cat subpart
24                 cat rootimage
25                 cat usrimage
26                 dd < /dev/zero count=$padsects
27         } > hdimage
28         partition -m hdimage 81:`expr $primsects + $padsects`*
29         installboot_nbsd -m hdimage /usr/mdec/mbr
32 retrieve()
34         dir=$1
35         list=`pwd`/$2
36         URLS=""
37         echo "Retrieving packages form $PACKAGEURL"
38         (
39         cd $dir || exit 1
40         SUMMARY=pkg_summary
41         rm -f pkg_summary* || true
42         fetch $PACKAGEURL/$SUMMARY.bz2
43         bzip2 -d $SUMMARY.bz2
44         cat $list | while read name
45         do      pkgname="`fgrep PKGNAME=${name} $SUMMARY | sed 's/PKGNAME=//g'`"
46                 if [ `echo $pkgname | wc -w` -ne 1 ]
47                 then    echo " *** Could not resolve $name (not found or too many matches: $pkgname) ***"
48                 else    echo Getting $pkgname
49                         fetch -r ${PACKAGEURL}/${pkgname}.tgz
50                 fi
51                 echo -n "."
52         done
53         )
54         echo done
57 cd_root_changes()
59 cat >$CDFILES/boot.cfg <<END_BOOT_CFG
60 banner=Welcome to the MINIX 3 installation CD
61 banner================================================================================
62 banner=
63 menu=Regular MINIX 3:multiboot /kernel bootcd=1 cdproberoot=1 rootdevname=ram disable=inet
64 menu=Drop to boot prompt:prompt
65 clear=1
66 timeout=10
67 default=1
68 load=/mod01_ds
69 load=/mod02_rs
70 load=/mod03_pm
71 load=/mod04_sched
72 load=/mod05_vfs
73 load=/mod06_memory
74 load=/mod07_log
75 load=/mod08_tty
76 load=/mod09_mfs
77 load=/mod10_vm
78 load=/mod11_pfs
79 load=/mod12_init
80 # This space intentionally left blank - leave to appease bootloader!
81 # This space intentionally left blank - leave to appease bootloader!
82 # This space intentionally left blank - leave to appease bootloader!
83 # This space intentionally left blank - leave to appease bootloader!
84 # This space intentionally left blank - leave to appease bootloader!
85 # This space intentionally left blank - leave to appease bootloader!
86 # This space intentionally left blank - leave to appease bootloader!
87 # This space intentionally left blank - leave to appease bootloader!
88 # This space intentionally left blank - leave to appease bootloader!
89 # This space intentionally left blank - leave to appease bootloader!
90 # This space intentionally left blank - leave to appease bootloader!
91 # This space intentionally left blank - leave to appease bootloader!
92 # This space intentionally left blank - leave to appease bootloader!
93 # This space intentionally left blank - leave to appease bootloader!
94 # This space intentionally left blank - leave to appease bootloader!
95 # This space intentionally left blank - leave to appease bootloader!
96 # This space intentionally left blank - leave to appease bootloader!
97 # This space intentionally left blank - leave to appease bootloader!
98 END_BOOT_CFG
102 hdemu_root_changes()
104         $RELEASEDIR/usr/sbin/installboot_nbsd $TMPDISKROOT \
105                 $RELEASEDIR/usr/mdec/bootxx_minixfs3
107 cat >$RELEASEMNTDIR/boot.cfg <<END_BOOT_CFG
108 menu=Regular MINIX 3:load_mods /boot/minix_default/mod*;multiboot /boot/minix_default/kernel bootcd=2 disable=inet bios_wini=yes bios_remap_first=1 ramimagedev=c0d7p0s0
109 menu=Drop to boot prompt:prompt
110 clear=1
111 timeout=10
112 default=1
113 END_BOOT_CFG
116 usb_root_changes()
118         $RELEASEDIR/usr/sbin/installboot_nbsd $TMPDISKROOT \
119                 $RELEASEDIR/usr/mdec/bootxx_minixfs3
120         echo \
121 cat >$RELEASEMNTDIR/boot.cfg <<END_BOOT_CFG
122 menu=Regular MINIX 3:load_mods /boot/minix_default/mod*;multiboot /boot/minix_default/kernel bios_wini=yes bios_remap_first=1 rootdevname=c0d7p0s0
123 menu=Drop to boot prompt:prompt
124 clear=1
125 timeout=10
126 default=1
127 END_BOOT_CFG
130 copy_local_packages()
132         if [ -d $PACKAGEDIR -a -f $PACKAGELIST -a $PACKAGES -ne 0 ]
133         then
134                 index=pkg_summary
135                 indexpath=$PACKAGEDIR/.index
136         
137                 if [ ! -d $indexpath ]
138                 then    mkdir $indexpath
139                 fi
140                 if [ ! -d $indexpath ]
141                 then    echo "Couldn't create $indexpath."
142                         exit 1
143                 fi
144         
145                 echo "" >$PACKAGEDIR/All/$index
146         
147                 echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE"
148                 for pkgprefix in `cat $PACKAGELIST`
149                 do      realfn="`echo $PACKAGEDIR/All/${pkgprefix}*.tgz`"
150                         if [ -f "$realfn" ]
151                        then
152                           # Copy package and create package's index
153                           (
154                               p="`basename $realfn`"
155                               cd $PACKAGEDIR/All
156                               cp $p $RELEASEPACKAGE/
157         
158                               indexname=$indexpath/$p.$index
159                               pkg_info -X $p >$indexname
160         
161                               if [ ! -f $indexname ]
162                               then      echo Missing $indexname.
163                                   exit 1
164                               fi
165         
166                               if [ "`wc -l $indexname`" -lt 3 ]
167                               then      $indexname is too short.
168                                   rm $indexname
169                                   exit 1
170                               fi
171         
172                               cat $indexname >>$PACKAGEDIR/All/$index
173                           )
174                        else
175                           echo "Can't find $pkgprefix Missing."
176                        fi
177                 done
178         
179                 bzip2 -f $PACKAGEDIR/All/$index
180                 cp $PACKAGEDIR/All/$index.bz2 $RELEASEPACKAGE/
181         fi
184 fitfs()
186         path="$1"
187         ramdisk="$2"
188         extra_inodes="$3"
189         extra_zones="$4"
190         mbsdefault="$5"
192         # Determine number of inodes
193         inodes=`find $path | egrep -v ^$path/usr | wc -l`
194         inodes="`expr $inodes + $extra_inodes`"
196         # Determine number of data zones
197         zonekbs=`du -ks $path | cut -d' ' -f1`
198         zonekbsignore=0
199         [ ! -d $path/usr ] || zonekbsignore=`du -ks $path/usr | cut -d" " -f1`
200         zones="`expr \( $zonekbs - $zonekbsignore \) / \( $BS / 1024 \) + $extra_zones`"
202         # Determine file system size
203         BSBITS="`expr $BS \* 8`"
204         imap_blocks="`expr \( $inodes + $BSBITS - 1 \) / $BSBITS`"
205         inode_blocks="`expr \( $inodes \* 64 + $BS - 1 \) / $BS`"
206         zmap_blocks="`expr \( $zones + $BSBITS - 1 \) / $BSBITS`"
207         blocks="`expr 1 + 1 + $imap_blocks + $zmap_blocks + $inode_blocks + $zones`"
208         kbs="`expr $blocks \* \( $BS / 1024 \)`"
210         # Apply default if higher
211         if [ -n "$mbsdefault" ]
212         then
213                 kbsdefault="`expr $mbsdefault \* 1024`"
214                 if [ "$kbs" -lt "$kbsdefault" ]
215                 then kbs=$kbsdefault
216                 else echo "warning: ${mbsdefault}mb is too small, using ${kbs}kb"
217                 fi
218         fi
220         # Create a filesystem on the target ramdisk
221         ramdisk $kbs $ramdisk
222         mkfs.mfs -B $BS -i $inodes $ramdisk