summaryrefslogtreecommitdiff
path: root/epm/epm-3.7.patch
blob: 116aa28f6690ae0a7f36c0e05d1e5ad5335e15ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
*** misc/epm-3.7/bsd.c	Tue Jan 14 18:05:01 2003
--- misc/build/epm-3.7/bsd.c	Mon Nov 20 14:54:51 2006
***************
*** 26,31 ****
--- 26,38 ----
  
  #include "epm.h"
  
+ void cr2semicolon(char *command)
+ {
+   int len, i;
+   len=strlen(command);
+   for (i=0;i<len;i++)
+     if(*(command+i)=='\n') *(command+i)=';';
+ }
  
  /*
   * 'make_bsd()' - Make a FreeBSD software distribution package.
***************
*** 149,156 ****
--- 156,172 ----
  
    for (i = dist->num_depends, d = dist->depends; i > 0; i --, d ++)
    {
+ #ifdef __FreeBSD__
+     if (d->type == DEPEND_REQUIRES) {
+       if (dist->relnumber)
+ 	  fprintf(fp, "@pkgdep %s-%s-%d-%s", d->product, dist->version, dist->relnumber, platname);
+       else
+ 	  fprintf(fp, "@pkgdep %s-%s-%s", d->product, dist->version, platname);
+     }
+ #else
      if (d->type == DEPEND_REQUIRES)
        fprintf(fp, "@pkgdep %s", d->product);
+ #endif
      else
  #ifdef __FreeBSD__
       /*
***************
*** 179,187 ****
--- 195,205 ----
  	        "         by the BSD packager.\n", stderr);
            break;
        case COMMAND_POST_INSTALL :
+       cr2semicolon(c->command);
            fprintf(fp, "@exec %s\n", c->command);
  	  break;
        case COMMAND_PRE_REMOVE :
+       cr2semicolon(c->command);
            fprintf(fp, "@unexec %s\n", c->command);
  	  break;
        case COMMAND_POST_REMOVE :
***************
*** 199,205 ****
        */
  
        fprintf(fp, "@exec /bin/mkdir -p %s\n", file->dst);
!       fprintf(fp, "@exec /bin/chown %s:%s %s\n", file->user, file->group,
                file->dst);
        fprintf(fp, "@exec /bin/chmod %04o %s\n", file->mode, file->dst);
      }
--- 217,223 ----
        */
  
        fprintf(fp, "@exec /bin/mkdir -p %s\n", file->dst);
!       fprintf(fp, "@exec /usr/sbin/chown %s:%s %s\n", file->user, file->group,
                file->dst);
        fprintf(fp, "@exec /bin/chmod %04o %s\n", file->mode, file->dst);
      }
***************
*** 326,337 ****
    if (Verbosity)
      puts("Building FreeBSD pkg binary distribution...");
  
!   if (run_command(NULL, "pkg_create -p / -s %s -c %s -d %s -f %s %s",
                    current, commentname, descrname, plistname, name))
      return (1);
  
!   if (run_command(NULL, "mv %s.tgz %s", name, directory))
!     return (1);
  
   /*
    * Remove temporary files...
--- 344,356 ----
    if (Verbosity)
      puts("Building FreeBSD pkg binary distribution...");
  
!   if (run_command(NULL, "/usr/sbin/pkg_create -p / -s %s -c %s -d %s -f %s %s",
                    current, commentname, descrname, plistname, name))
      return (1);
  
!   if (run_command(NULL, "mv %s.tbz %s", name, directory))
!     if (run_command(NULL, "mv %s.tgz %s", name, directory))
!       return (1);
  
   /*
    * Remove temporary files...
*** misc/epm-3.7/configure	Thu Jul 24 03:20:54 2003
--- misc/build/epm-3.7/configure	Mon Nov 20 15:01:11 2006
***************
*** 1238,1244 ****
--- 1238,1249 ----
  fi
  fi;
  
+ # Check whether --enable-fltk or --disable-fltk was given.
+ if test "${enable_fltk+set}" = set; then
+   enableval="$enable_fltk"
+ fi;
  
+ 
  # Check whether --with-docdir or --without-docdir was given.
  if test "${with_docdir+set}" = set; then
    withval="$with_docdir"
***************
*** 4904,4939 ****
  fi
  
  
! # Extract the first word of "fltk-config", so it can be a program name with args.
! set dummy fltk-config; ac_word=$2
! echo "$as_me:$LINENO: checking for $ac_word" >&5
! echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
! if test "${ac_cv_path_FLTKCONFIG+set}" = set; then
!   echo $ECHO_N "(cached) $ECHO_C" >&6
! else
!   case $FLTKCONFIG in
!   [\\/]* | ?:[\\/]*)
!   ac_cv_path_FLTKCONFIG="$FLTKCONFIG" # Let the user override the test with a path.
!   ;;
!   *)
!   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
! for as_dir in $PATH
! do
!   IFS=$as_save_IFS
!   test -z "$as_dir" && as_dir=.
!   for ac_exec_ext in '' $ac_executable_extensions; do
!   if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
!     ac_cv_path_FLTKCONFIG="$as_dir/$ac_word$ac_exec_ext"
!     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
!     break 2
    fi
! done
! done
! 
!   ;;
! esac
  fi
- FLTKCONFIG=$ac_cv_path_FLTKCONFIG
  
  if test -n "$FLTKCONFIG"; then
    echo "$as_me:$LINENO: result: $FLTKCONFIG" >&5
--- 4909,4946 ----
  fi
  
  
! if eval "test x$enable_fltk = xyes"; then
!   # Extract the first word of "fltk-config", so it can be a program name with args.
!   set dummy fltk-config; ac_word=$2
!   echo "$as_me:$LINENO: checking for $ac_word" >&5
!   echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
!   if test "${ac_cv_path_FLTKCONFIG+set}" = set; then
!     echo $ECHO_N "(cached) $ECHO_C" >&6
!   else
!     case $FLTKCONFIG in
!     [\\/]* | ?:[\\/]*)
!     ac_cv_path_FLTKCONFIG="$FLTKCONFIG" # Let the user override the test with a path.
!     ;;
!     *)
!     as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
!   for as_dir in $PATH
!   do
!     IFS=$as_save_IFS
!     test -z "$as_dir" && as_dir=.
!     for ac_exec_ext in '' $ac_executable_extensions; do
!     if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
!       ac_cv_path_FLTKCONFIG="$as_dir/$ac_word$ac_exec_ext"
!       echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
!       break 2
!     fi
!   done
!   done
!   
!     ;;
!   esac
    fi
!   FLTKCONFIG=$ac_cv_path_FLTKCONFIG
  fi
  
  if test -n "$FLTKCONFIG"; then
    echo "$as_me:$LINENO: result: $FLTKCONFIG" >&5
***************
*** 4950,4957 ****
--- 4957,4966 ----
  	INSTALL_GUIS=""
  	INSTALL_OSX=""
  
+ if eval "test x$enable_fltk = xyes"; then
  	{ echo "$as_me:$LINENO: WARNING: Sorry, setup GUI requires FLTK 1.1.x." >&5
  echo "$as_me: WARNING: Sorry, setup GUI requires FLTK 1.1.x." >&2;}
+ fi
  else
  	CXXFLAGS="`$FLTKCONFIG --cflags` ${CXXFLAGS}"
  	GUIS="setup uninst"
*** misc/epm-3.7/deb.c	Wed Jan 15 15:29:24 2003
--- misc/build/epm-3.7/deb.c	Mon Nov 20 14:54:51 2006
***************
*** 26,31 ****
--- 26,53 ----
  
  #include "epm.h"
  
+ /*
+  * 'add_size()' - Append Installed-Size tag to DEBIAN/control file
+  */
+  
+ int                             /* O - 0 = success, 1 = fail */
+ add_size(FILE       *fpControl, /* Control file stream */
+          const char *directory) /* Directory containing all files to package */
+ {
+     FILE *fp;
+     char command[1024];
+     
+     snprintf(command, sizeof(command), "du -k -s %s", directory);
+     fp = popen(command, "r");
+     if( NULL != fp )
+     {
+         char size[1024];
+         fscanf(fp, "%s .", size);
+         fprintf(fpControl, "Installed-Size: %s\n", size);
+         return pclose(fp);
+     }
+     return 1;
+ }
  
  /*
   * 'make_deb()' - Make a Debian software distribution package.
***************
*** 61,78 ****
    if (Verbosity)
      puts("Creating Debian distribution...");
  
    if (dist->relnumber)
    {
      if (platname[0])
!       snprintf(name, sizeof(name), "%s-%s-%d-%s", prodname, dist->version, dist->relnumber,
                platname);
      else
!       snprintf(name, sizeof(name), "%s-%s-%d", prodname, dist->version, dist->relnumber);
    }
    else if (platname[0])
!     snprintf(name, sizeof(name), "%s-%s-%s", prodname, dist->version, platname);
    else
!     snprintf(name, sizeof(name), "%s-%s", prodname, dist->version);
  
   /*
    * Write the control file for DPKG...
--- 83,111 ----
    if (Verbosity)
      puts("Creating Debian distribution...");
  
+   /*
+    * Use debian default naming scheme
+    */
+ 
+   if (!strcmp(platform->machine, "intel"))
+     platname = "i386";
+   else if (!strcmp(platform->machine, "x86_64"))
+     platname = "amd64";
+   else if (!strcmp(platform->machine, "ppc"))
+     platname = "powerpc";
+ 
    if (dist->relnumber)
    {
      if (platname[0])
!       snprintf(name, sizeof(name), "%s_%s-%d_%s", prodname, dist->version, dist->relnumber,
                platname);
      else
!       snprintf(name, sizeof(name), "%s_%s-%d", prodname, dist->version, dist->relnumber);
    }
    else if (platname[0])
!     snprintf(name, sizeof(name), "%s_%s_%s", prodname, dist->version, platname);
    else
!     snprintf(name, sizeof(name), "%s_%s", prodname, dist->version);
  
   /*
    * Write the control file for DPKG...
***************
*** 108,115 ****
    * (which we change in get_platform to a common name)
    */
  
!   if (strcmp(platform->machine, "intel") == 0)
      fputs("Architecture: i386\n", fp);
    else
      fprintf(fp, "Architecture: %s\n", platform->machine);
  
--- 141,152 ----
    * (which we change in get_platform to a common name)
    */
  
!   if (!strcmp(platform->machine, "intel"))
      fputs("Architecture: i386\n", fp);
+   else if (!strcmp(platform->machine, "x86_64"))
+     fputs("Architecture: amd64\n", fp);
+   else if (!strcmp(platform->machine, "ppc"))
+     fputs("Architecture: powerpc\n", fp);
    else
      fprintf(fp, "Architecture: %s\n", platform->machine);
  
***************
*** 148,156 ****
        putc('\n', fp);
      }
    }
! 
    fclose(fp);
! 
   /*
    * Write the preinst file for DPKG...
    */
--- 185,193 ----
        putc('\n', fp);
      }
    }
!   
    fclose(fp);
!   
   /*
    * Write the preinst file for DPKG...
    */
***************
*** 417,422 ****
--- 454,480 ----
      }
    }
  
+   
+   /* 
+    * Calculate and append Installed-Size to DEBIAN/control
+    */
+    
+   if (Verbosity)
+     puts("Calculating Installed-Size...");
+   
+   snprintf(filename, sizeof(filename), "%s/%s/DEBIAN/control", directory, name);
+   if ((fp = fopen(filename, "a")) == NULL)
+   {
+     fprintf(stderr, "epm: Unable to Installed-Size to file \"%s\" - %s\n", filename,
+             strerror(errno));
+     return (1);
+   }
+ 
+   snprintf(filename, sizeof(filename), "%s/%s", directory, name);  
+   add_size(fp, filename);
+   fclose(fp);
+  
+ 
   /*
    * Build the distribution from the spec file...
    */
*** misc/epm-3.7/dist.c	Thu Aug  7 16:14:40 2003
--- misc/build/epm-3.7/dist.c	Mon Nov 20 14:54:51 2006
***************
*** 394,401 ****
    strcpy(platform->machine, "mips");
  #elif defined(__hpux)
    strcpy(platform->machine, "hppa");
! #elif defined(_AIX) || defined(__APPLE__)
    strcpy(platform->machine, "powerpc");
  #else
    for (temp = platform->machine; *temp != '\0'; temp ++)
      if (*temp == '-' || *temp == '_')
--- 394,406 ----
    strcpy(platform->machine, "mips");
  #elif defined(__hpux)
    strcpy(platform->machine, "hppa");
! #elif defined(_AIX)
    strcpy(platform->machine, "powerpc");
+ #elif defined(__APPLE__)
+   if (strstr(platform->machine, "86") != NULL)
+     strcpy(platform->machine, "intel");
+   else
+     strcpy(platform->machine, "powerpc");  
  #else
    for (temp = platform->machine; *temp != '\0'; temp ++)
      if (*temp == '-' || *temp == '_')
***************
*** 407,413 ****
        *temp = tolower(*temp);
  
    if (strstr(platform->machine, "86") != NULL)
!     strcpy(platform->machine, "intel");
    else if (strncmp(platform->machine, "sun", 3) == 0)
      strcpy(platform->machine, "sparc");
  #endif /* __sgi */
--- 412,423 ----
        *temp = tolower(*temp);
  
    if (strstr(platform->machine, "86") != NULL)
!   {
!     if (strstr(platform->machine, "64") != NULL)
!       strcpy(platform->machine, "x86_64");
!     else
!       strcpy(platform->machine, "intel");
!   }
    else if (strncmp(platform->machine, "sun", 3) == 0)
      strcpy(platform->machine, "sparc");
  #endif /* __sgi */
*** misc/epm-3.7/epm.c	Tue Oct 28 15:48:30 2003
--- misc/build/epm-3.7/epm.c	Mon Nov 20 14:54:51 2006
***************
*** 547,552 ****
--- 547,553 ----
  {
    puts(EPM_VERSION);
    puts("Copyright 1999-2003 by Easy Software Products.");
+   puts("Patched for OpenOffice.org");
    puts("");
    puts("EPM is free software and comes with ABSOLUTELY NO WARRANTY; for details");
    puts("see the GNU General Public License in the file COPYING or at");
*** misc/epm-3.7/file.c	Wed Jul 23 23:41:08 2003
--- misc/build/epm-3.7/file.c	Mon Nov 20 14:54:51 2006
***************
*** 108,114 ****
    fclose(dstfile);
  
    chmod(dst, mode);
-   chown(dst, owner, group);
  
    return (0);
  }
--- 108,113 ----
***************
*** 138,144 ****
        {
  	mkdir(buffer, 0777);
  	chmod(buffer, mode | 0700);
- 	chown(buffer, owner, group);
        }
      }
  
--- 137,142 ----
***************
*** 151,157 ****
    {
      mkdir(buffer, 0777);
      chmod(buffer, mode | 0700);
-     chown(buffer, owner, group);
    }
  
    return (0);
--- 149,154 ----
*** misc/epm-3.7/osx.c	Wed Jul 23 23:41:08 2003
--- misc/build/epm-3.7/osx.c	Mon Nov 20 14:54:51 2006
***************
*** 373,379 ****
    else
      snprintf(filename, sizeof(filename), "%s/%s", current, directory);
  
!   run_command(NULL, "/Developer/Applications/PackageMaker.app/"
                      "Contents/MacOS/PackageMaker -build "
  		    "-p %s/%s.pkg -f %s/Package -r %s/Resources -d %s/%s-desc.plist -i %s/%s-info.plist",
  	      filename, prodname, filename, filename, filename, prodname, filename, prodname);
--- 373,379 ----
    else
      snprintf(filename, sizeof(filename), "%s/%s", current, directory);
  
!   run_command(NULL, "/Developer/Applications/Utilities/PackageMaker.app/"
                      "Contents/MacOS/PackageMaker -build "
  		    "-p %s/%s.pkg -f %s/Package -r %s/Resources -d %s/%s-desc.plist -i %s/%s-info.plist",
  	      filename, prodname, filename, filename, filename, prodname, filename, prodname);
*** misc/epm-3.7/pkg.c	Tue Dec 17 19:57:56 2002
--- misc/build/epm-3.7/pkg.c	Mon Nov 20 14:54:51 2006
***************
*** 429,503 ****
  
    fclose(fp);
  
-  /*
-   * Build the distribution from the prototype file...
-   */
- 
-   if (Verbosity)
-     puts("Building PKG binary distribution...");
- 
-   if (run_command(NULL, "pkgmk -o -f %s/%s.prototype -d %s/%s",
-                   directory, prodname, current, directory))
-     return (1);
- 
-  /*
-   * Tar and compress the distribution...
-   */
- 
-   if (Verbosity)
-     puts("Creating tar.gz file for distribution...");
- 
-   snprintf(filename, sizeof(filename), "%s/%s.tar.gz", directory, name);
- 
-   if ((tarfile = tar_open(filename, 1)) == NULL)
-     return (1);
- 
-   snprintf(filename, sizeof(filename), "%s/%s", directory, prodname);
- 
-   if (tar_directory(tarfile, filename, prodname))
-   {
-     tar_close(tarfile);
-     return (1);
-   }
- 
-   tar_close(tarfile);
- 
-  /*
-   * Make a package stream file...
-   */
- 
-   if (Verbosity)
-     puts("Copying into package stream file...");
- 
-   if (run_command(directory, "pkgtrans -s %s/%s %s.pkg %s",
-                   current, directory, name, prodname))
-     return (1);
- 
-  /*
-   * Remove temporary files...
-   */
- 
-   if (!KeepFiles)
-   {
-     if (Verbosity)
-       puts("Removing temporary distribution files...");
- 
-     snprintf(filename, sizeof(filename), "%s/%s.pkginfo", directory, prodname);
-     unlink(filename);
-     snprintf(filename, sizeof(filename), "%s/%s.depend", directory, prodname);
-     unlink(filename);
-     snprintf(filename, sizeof(filename), "%s/%s.prototype", directory, prodname);
-     unlink(filename);
-     if (preinstall[0])
-       unlink(preinstall);
-     if (postinstall[0])
-       unlink(postinstall);
-     if (preremove[0])
-       unlink(preremove);
-     if (postremove[0])
-       unlink(postremove);
-   }
- 
    return (0);
  }
  
--- 429,434 ----
*** misc/epm-3.7/qprintf.c	Mon Jan 27 22:48:03 2003
--- misc/build/epm-3.7/qprintf.c	Mon Nov 20 14:54:51 2006
***************
*** 181,192 ****
  
              for (i = slen; i > 0; i --, s ++, bytes ++)
  	    {
  	      if (strchr("`~!#$%^&*()[{]}\\|;\'\"<>? ", *s))
  	      {
  	        putc('\\', fp);
  		bytes ++;
  	      }
! 
  	      putc(*s, fp);
  	    }
  
--- 181,199 ----
  
              for (i = slen; i > 0; i --, s ++, bytes ++)
  	    {
+ #if defined(__FreeBSD__)
+ 	      if (strchr("`~!#%^&*()[{]}\\|;\'\"<>? ", *s))
+ 	      {
+ 	        putc('\\', fp);
+ 		bytes ++;
+ 	      }
+ #else
  	      if (strchr("`~!#$%^&*()[{]}\\|;\'\"<>? ", *s))
  	      {
  	        putc('\\', fp);
  		bytes ++;
  	      }
! #endif
  	      putc(*s, fp);
  	    }
  
*** misc/epm-3.7/rpm.c	Wed Oct  1 21:27:15 2003
--- misc/build/epm-3.7/rpm.c	Mon Nov 20 14:54:51 2006
***************
*** 38,44 ****
           dist_t         *dist,		/* I - Distribution information */
  	 struct utsname *platform)	/* I - Platform information */
  {
!   int		i;			/* Looping var */
    FILE		*fp;			/* Spec file */
    char		name[1024];		/* Full product name */
    char		specname[1024];		/* Spec filename */
--- 38,44 ----
           dist_t         *dist,		/* I - Distribution information */
  	 struct utsname *platform)	/* I - Platform information */
  {
!   int		i,n;			/* Looping vars */
    FILE		*fp;			/* Spec file */
    char		name[1024];		/* Full product name */
    char		specname[1024];		/* Spec filename */
***************
*** 160,165 ****
--- 160,167 ----
        fprintf(fp, "Requires: %s", dname);
      else if (d->type == DEPEND_PROVIDES)
        fprintf(fp, "Provides: %s", dname);
+     else if (d->type == DEPEND_REPLACES)
+       fprintf(fp, "Obsoletes: %s", dname);
      else
        fprintf(fp, "Conflicts: %s", dname);
  
***************
*** 186,200 ****
    for (i = 0; i < dist->num_descriptions; i ++)
      fprintf(fp, "%s\n", dist->descriptions[i]);
  
!   fputs("%pre\n", fp);
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
      if (c->type == COMMAND_PRE_INSTALL)
        fprintf(fp, "%s\n", c->command);
  
!   fputs("%post\n", fp);
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
      if (c->type == COMMAND_POST_INSTALL)
        fprintf(fp, "%s\n", c->command);
  
    for (i = dist->num_files, file = dist->files; i > 0; i --, file ++)
      if (tolower(file->type) == 'i')
--- 188,220 ----
    for (i = 0; i < dist->num_descriptions; i ++)
      fprintf(fp, "%s\n", dist->descriptions[i]);
  
!   /*
!    * %pre
!    */
!   n = 0;
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
+   {
      if (c->type == COMMAND_PRE_INSTALL)
+     {
+       if (1 == ++n)  /* Only write %pre if there is at least one command */
+         fputs("%pre\n", fp);
        fprintf(fp, "%s\n", c->command);
+     }
+   }
  
!   /*
!    * %post
!    */
!   n = 0;
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
+   {
      if (c->type == COMMAND_POST_INSTALL)
+     {
+       if (1 == ++n)  /* Only write %post if there is at least one command */
+         fputs("%post\n", fp);
        fprintf(fp, "%s\n", c->command);
+     }
+   }
  
    for (i = dist->num_files, file = dist->files; i > 0; i --, file ++)
      if (tolower(file->type) == 'i')
***************
*** 202,207 ****
--- 222,229 ----
  
    if (i)
    {
+     if (1 == ++n)  /* If not previously done so, write %post here */
+       fputs("%post\n", fp);
      fputs("if test \"x$1\" = x1; then\n", fp);
      fputs("	echo Setting up init scripts...\n", fp);
  
***************
*** 259,265 ****
      fputs("fi\n", fp);
    }
  
!   fputs("%preun\n", fp);
    for (i = dist->num_files, file = dist->files; i > 0; i --, file ++)
      if (tolower(file->type) == 'i')
        break;
--- 281,290 ----
      fputs("fi\n", fp);
    }
  
!   /*
!    * %preun
!    */
!   n = 0;
    for (i = dist->num_files, file = dist->files; i > 0; i --, file ++)
      if (tolower(file->type) == 'i')
        break;
***************
*** 266,271 ****
--- 291,297 ----
  
    if (i)
    {
+     fputs("%preun\n", fp); ++n; /* Need to write %preun here */
      fputs("if test \"x$1\" = x0; then\n", fp);
      fputs("	echo Cleaning up init scripts...\n", fp);
  
***************
*** 315,327 ****
    }
  
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
      if (c->type == COMMAND_PRE_REMOVE)
        fprintf(fp, "%s\n", c->command);
  
!   fputs("%postun\n", fp);
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
      if (c->type == COMMAND_POST_REMOVE)
        fprintf(fp, "%s\n", c->command);
  
    fputs("%files\n", fp);
    for (i = dist->num_files, file = dist->files; i > 0; i --, file ++)
--- 341,369 ----
    }
  
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
+   {
      if (c->type == COMMAND_PRE_REMOVE)
+     {
+       if (1 == ++n)  /* Only write %preun if not previously done so */
+         fputs("%preun\n", fp);
+ 	    
        fprintf(fp, "%s\n", c->command);
+     }
+   }
  
!   /*
!    * %post
!    */
!   n = 0;
    for (i = dist->num_commands, c = dist->commands; i > 0; i --, c ++)
+   {
      if (c->type == COMMAND_POST_REMOVE)
+     {
+       if (1 == ++n)  /* Only write %post if there is at least one command */
+         fputs("%postun\n", fp);
        fprintf(fp, "%s\n", c->command);
+     }
+   }
  
    fputs("%files\n", fp);
    for (i = dist->num_files, file = dist->files; i > 0; i --, file ++)
***************
*** 415,467 ****
      }
    }
  
-  /*
-   * Build the distribution from the spec file...
-   */
- 
-   if (Verbosity)
-     puts("Building RPM binary distribution...");
- 
-   if (strcmp(platform->machine, "intel") == 0)
-   {
-     if (run_command(NULL, EPM_RPMBUILD " %s -bb " EPM_RPMARCH "i386 %s",
-                     Verbosity == 0 ? "--quiet" : "", specname))
-       return (1);
-   }
-   else if (run_command(NULL, EPM_RPMBUILD " %s -bb " EPM_RPMARCH "%s %s",
-                        Verbosity == 0 ? "--quiet" : "", platform->machine,
- 		       specname))
-     return (1);
- 
-  /*
-   * Move the RPM to the local directory and rename the RPM using the
-   * product name specified by the user...
-   */
- 
-   if (strcmp(platform->machine, "intel") == 0)
-     run_command(NULL, "/bin/mv %s/RPMS/i386/%s-%s-%d.i386.rpm %s/%s.rpm",
-         	rpmdir, prodname, dist->version, dist->relnumber,
- 		directory, name);
-   else
-     run_command(NULL, "/bin/mv %s/RPMS/%s/%s-%s-%d.%s.rpm %s/%s.rpm",
-         	rpmdir, platform->machine, prodname, dist->version,
- 		dist->relnumber, platform->machine, directory, name);
- 
-  /*
-   * Remove temporary files...
-   */
- 
-   if (!KeepFiles)
-   {
-     if (Verbosity)
-       puts("Removing temporary distribution files...");
- 
-     run_command(NULL, "/bin/rm -rf %s/RPMS", directory);
-     run_command(NULL, "/bin/rm -rf %s/buildroot", directory);
- 
-     unlink(specname);
-   }
- 
    return (0);
  }
  
--- 457,462 ----