etc/protocols - sync with NetBSD-8
[minix.git] / releasetools / release.functions
blob4fa6d39ddd8c7ba4141d97e7a36ae9f2f92559dd
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                         echo Matches:
49                         echo $pkgname
50                         exit 1
51                 else    echo Getting $pkgname
52                         fetch -r ${PACKAGEURL}/${pkgname}.tgz
53                 fi
54                 echo -n "."
55         done
56         )
57         echo done
60 cd_root_changes()
62 cat >$CDFILES/boot.cfg <<END_BOOT_CFG
63 banner=Welcome to the MINIX 3 installation CD
64 banner================================================================================
65 banner=
66 menu=Regular MINIX 3:multiboot /kernel bootcd=1 cdproberoot=1 rootdevname=ram
67 menu=Regular MINIX 3 (with AHCI):multiboot /kernel bootcd=1 cdproberoot=1 rootdevname=ram ahci=yes
68 menu=Edit menu option:edit
69 menu=Drop to boot prompt:prompt
70 clear=1
71 timeout=10
72 default=1
73 load=/mod01_ds
74 load=/mod02_rs
75 load=/mod03_pm
76 load=/mod04_sched
77 load=/mod05_vfs
78 load=/mod06_memory
79 load=/mod07_tty
80 load=/mod08_mib
81 load=/mod09_vm
82 load=/mod10_pfs
83 load=/mod11_mfs
84 load=/mod12_init
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 # This space intentionally left blank - leave to appease bootloader!
99 # This space intentionally left blank - leave to appease bootloader!
100 # This space intentionally left blank - leave to appease bootloader!
101 # This space intentionally left blank - leave to appease bootloader!
102 # This space intentionally left blank - leave to appease bootloader!
103 END_BOOT_CFG
106 copy_local_packages()
108         if [ -d $PACKAGEDIR -a -f $PACKAGELIST -a $PACKAGES -ne 0 ]
109         then
110                 index=pkg_summary
111                 indexpath=$PACKAGEDIR/.index
112         
113                 if [ ! -d $indexpath ]
114                 then    mkdir $indexpath
115                 fi
116                 if [ ! -d $indexpath ]
117                 then    echo "Couldn't create $indexpath."
118                         exit 1
119                 fi
120         
121                 echo "" >$PACKAGEDIR/All/$index
122         
123                 echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE"
124                 for pkgprefix in `cat $PACKAGELIST`
125                 do      realfn="`echo $PACKAGEDIR/All/${pkgprefix}*.tgz`"
126                         if [ -f "$realfn" ]
127                        then
128                           # Copy package and create package's index
129                           (
130                               p="`basename $realfn`"
131                               cd $PACKAGEDIR/All
132                               cp $p $RELEASEPACKAGE/
133         
134                               indexname=$indexpath/$p.$index
135                               pkg_info -X $p >$indexname
136         
137                               if [ ! -f $indexname ]
138                               then      echo Missing $indexname.
139                                   exit 1
140                               fi
141         
142                               if [ "`wc -l <$indexname`" -lt 3 ]
143                               then      $indexname is too short.
144                                   rm $indexname
145                                   exit 1
146                               fi
147         
148                               cat $indexname >>$PACKAGEDIR/All/$index
149                           )
150                        else
151                           echo "Can't find $pkgprefix Missing."
152                        fi
153                 done
154         
155                 bzip2 -f $PACKAGEDIR/All/$index
156                 cp $PACKAGEDIR/All/$index.bz2 $RELEASEPACKAGE/
157         fi
160 fitfs()
162         path="$1"
163         ramdisk="$2"
164         extra_inodes="$3"
165         extra_zones="$4"
166         mbsdefault="$5"
168         # Determine number of inodes
169         inodes=`find $path | egrep -v ^$path/usr | wc -l`
170         inodes="`expr $inodes + $extra_inodes`"
172         # Determine number of data zones
173         zonekbs=`du -ks $path | cut -d' ' -f1`
174         zonekbsignore=0
175         [ ! -d $path/usr ] || zonekbsignore=`du -ks $path/usr | cut -d" " -f1`
176         zones="`expr \( $zonekbs - $zonekbsignore \) / \( $BS / 1024 \) + $extra_zones`"
178         # Determine file system size
179         BSBITS="`expr $BS \* 8`"
180         imap_blocks="`expr \( $inodes + $BSBITS - 1 \) / $BSBITS`"
181         inode_blocks="`expr \( $inodes \* 64 + $BS - 1 \) / $BS`"
182         zmap_blocks="`expr \( $zones + $BSBITS - 1 \) / $BSBITS`"
183         blocks="`expr 1 + 1 + $imap_blocks + $zmap_blocks + $inode_blocks + $zones`"
184         kbs="`expr $blocks \* \( $BS / 1024 \)`"
186         # Apply default if higher
187         if [ -n "$mbsdefault" ]
188         then
189                 kbsdefault="`expr $mbsdefault \* 1024`"
190                 if [ "$kbs" -lt "$kbsdefault" ]
191                 then kbs=$kbsdefault
192                 else echo "warning: ${mbsdefault}mb is too small, using ${kbs}kb"
193                 fi
194         fi
196         # Create a filesystem on the target ramdisk
197         ramdisk $kbs $ramdisk
198         mkfs.mfs -B $BS -i $inodes $ramdisk