diff --git a/.gitignore b/.gitignore index d61c9d5..0258812 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ unix2dos-2.2.src.tar.gz -unix2dos-4.1.1.tar.gz -unix2dos-4.1.2.tar.gz diff --git a/dead.package b/dead.package deleted file mode 100644 index 7e28d01..0000000 --- a/dead.package +++ /dev/null @@ -1 +0,0 @@ -Obsoleted by dos2unix-5.1, which merges unix2dos. diff --git a/sources b/sources new file mode 100644 index 0000000..3a9992b --- /dev/null +++ b/sources @@ -0,0 +1 @@ +e4488c241fa9067a48a7534a21d4babb unix2dos-2.2.src.tar.gz diff --git a/unix2dos-2.2-manpage.patch b/unix2dos-2.2-manpage.patch new file mode 100644 index 0000000..f6ae1b8 --- /dev/null +++ b/unix2dos-2.2-manpage.patch @@ -0,0 +1,32 @@ +--- unix2dos-2.2/unix2dos.1.man Thu Jan 17 17:25:08 2002 ++++ unix2dos-2.2/unix2dos.1 Thu Jan 17 17:25:35 2002 +@@ -16,7 +16,7 @@ + .SH DESCRIPTION + + .PP +-This manual page documents dos2unix, the program that converts text ++This manual page documents unix2dos, the program that converts text + files in UNIX format to DOS format. + + .SH OPTIONS +@@ -40,7 +40,7 @@ + + .TP + .B \-c --convmode convmode +-Sets conversion mode. Simulates dos2unix under SunOS. ++Sets conversion mode. Simulates unix2dos under SunOS. + + .TP + .B \-o --oldfile file ... +@@ -71,9 +71,9 @@ + Convert and replace a.txt in ASCII conversion mode. + Convert and replace b.txt in ISO conversion mode. + .IP +-.B dos2unix a.txt -c iso b.txt ++.B unix2dos a.txt -c iso b.txt + .IP +-.B dos2unix -c ascii a.txt -c iso b.txt ++.B unix2dos -c ascii a.txt -c iso b.txt + + .LP + Convert and replace a.txt while keeping original date stamp. diff --git a/unix2dos-2.2-mode.patch b/unix2dos-2.2-mode.patch new file mode 100644 index 0000000..4f35ed2 --- /dev/null +++ b/unix2dos-2.2-mode.patch @@ -0,0 +1,28 @@ +--- unix2dos-2.2/unix2dos.c.mode 2004-10-11 14:20:07.194483616 +0100 ++++ unix2dos-2.2/unix2dos.c 2004-10-11 14:20:30.752966221 +0100 +@@ -292,11 +292,14 @@ + char TempPath[16]; + struct stat StatBuf; + struct utimbuf UTimeBuf; ++ mode_t mode = S_IRUSR | S_IWUSR; + int fd; + + /* retrieve ipInFN file date stamp */ +- if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf)) ++ if (stat(ipInFN, &StatBuf)) + RetVal = -1; ++ else ++ mode = StatBuf.st_mode; + + strcpy (TempPath, "./u2dtmpXXXXXX"); + if((fd=mkstemp (TempPath)) < 0) { +@@ -304,6 +307,9 @@ + RetVal = -1; + } + ++ if (!RetVal && fchmod (fd, mode) && fchmod (fd, S_IRUSR | S_IWUSR)) ++ RetVal = -1; ++ + #ifdef DEBUG + fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath); + #endif diff --git a/unix2dos-2.2-segfault.patch b/unix2dos-2.2-segfault.patch new file mode 100644 index 0000000..a92f57c --- /dev/null +++ b/unix2dos-2.2-segfault.patch @@ -0,0 +1,94 @@ +--- unix2dos-2.2/unix2dos.c.segf Thu Jan 17 17:09:49 2002 ++++ unix2dos-2.2/unix2dos.c Thu Jan 17 17:12:47 2002 +@@ -131,9 +131,9 @@ + * RetVal: NULL if failure + * file stream otherwise + */ +-FILE* OpenOutFile(char *ipFN) ++FILE* OpenOutFile(int fd) + { +- return (fopen(ipFN, W_CNTRL)); ++ return (fdopen(fd, W_CNTRL)); + } + + +@@ -207,14 +207,17 @@ + char TempPath[16]; + struct stat StatBuf; + struct utimbuf UTimeBuf; ++ int fd; + + /* retrieve ipInFN file date stamp */ + if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf)) + RetVal = -1; + +- strcpy (TempPath, "./u2dtmp"); +- strcat (TempPath, "XXXXXX"); +- mkstemp (TempPath); ++ strcpy (TempPath, "./u2dtmpXXXXXX"); ++ if((fd=mkstemp (TempPath)) < 0) { ++ perror("Can't open output temp file"); ++ RetVal = -1; ++ } + + #ifdef DEBUG + fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath); +@@ -225,7 +228,7 @@ + RetVal = -1; + + /* can open out file? */ +- if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL)) ++ if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL)) + { + fclose (InF); + RetVal = -1; +@@ -243,6 +246,9 @@ + if ((TempF) && (fclose(TempF) == EOF)) + RetVal = -1; + ++ if(fd>=0) ++ close(fd); ++ + if ((!RetVal) && (ipFlag->KeepDate)) + { + UTimeBuf.actime = StatBuf.st_atime; +@@ -286,14 +292,17 @@ + char TempPath[16]; + struct stat StatBuf; + struct utimbuf UTimeBuf; ++ int fd; + + /* retrieve ipInFN file date stamp */ + if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf)) + RetVal = -1; + +- strcpy (TempPath, "./u2dtmp"); +- strcat (TempPath, "XXXXXX"); +- mkstemp (TempPath); ++ strcpy (TempPath, "./u2dtmpXXXXXX"); ++ if((fd=mkstemp (TempPath)) < 0) { ++ perror("Can't open output temp file"); ++ RetVal = -1; ++ } + + #ifdef DEBUG + fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath); +@@ -304,7 +313,7 @@ + RetVal = -1; + + /* can open out file? */ +- if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL)) ++ if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL)) + { + fclose (InF); + RetVal = -1; +@@ -322,6 +331,9 @@ + if ((TempF) && (fclose(TempF) == EOF)) + RetVal = -1; + ++ if(fd>=0) ++ close(fd); ++ + if ((!RetVal) && (ipFlag->KeepDate)) + { + UTimeBuf.actime = StatBuf.st_atime; diff --git a/unix2dos-2.2-tmppath.patch b/unix2dos-2.2-tmppath.patch new file mode 100644 index 0000000..53938da --- /dev/null +++ b/unix2dos-2.2-tmppath.patch @@ -0,0 +1,144 @@ +--- unix2dos-2.2/unix2dos.c.tmppath 2004-10-20 16:10:06.941343976 +0200 ++++ unix2dos-2.2/unix2dos.c 2004-10-20 16:17:52.199613968 +0200 +@@ -57,7 +57,10 @@ + + #ifdef __MSDOS__ + # include ++#else ++# include + #endif __MSDOS ++#include + #include + #include + #include +@@ -195,6 +198,40 @@ + } + + ++static int MakeTempFileFrom(const char *OutFN, char **fname_ret) ++{ ++ char *cpy = strdup(OutFN); ++ char *dir = NULL; ++ size_t fname_len = 0; ++ char *fname_str = NULL; ++ int fd = -1; ++ ++ *fname_ret = NULL; ++ ++ if (!cpy) ++ goto make_failed; ++ ++ dir = dirname(cpy); ++ ++ fname_len = strlen(dir) + strlen("/u2dtmpXXXXXX") + sizeof (char); ++ if (!(fname_str = malloc(fname_len))) ++ goto make_failed; ++ sprintf(fname_str, "%s%s", dir, "/u2dtmpXXXXXX"); ++ *fname_ret = fname_str; ++ ++ free(cpy); ++ ++ if ((fd = mkstemp(fname_str)) == -1) ++ goto make_failed; ++ ++ return (fd); ++ ++ make_failed: ++ free(*fname_ret); ++ *fname_ret = NULL; ++ return (-1); ++} ++ + /* convert file ipInFN to DOS format text and write to file ipOutFN + * RetVal: 0 if success + * -1 otherwise +@@ -204,7 +241,7 @@ + int RetVal = 0; + FILE *InF = NULL; + FILE *TempF = NULL; +- char TempPath[16]; ++ char *TempPath; + struct stat StatBuf; + struct utimbuf UTimeBuf; + int fd; +@@ -214,7 +251,6 @@ + RetVal = -1; + +- strcpy (TempPath, "./u2dtmpXXXXXX"); +- if((fd=mkstemp (TempPath)) < 0) { ++ if((fd = MakeTempFileFrom (ipOutFN, &TempPath)) < 0) { + perror("Can't open output temp file"); + RetVal = -1; + } +@@ -231,6 +267,7 @@ + if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL)) + { + fclose (InF); ++ InF = NULL; + RetVal = -1; + } + +@@ -265,9 +302,6 @@ + /* can rename temp file to out file? */ + if (!RetVal) + { +- if (stat(ipOutFN, &StatBuf) == 0) +- unlink(ipOutFN); +- + if ((rename(TempPath, ipOutFN) == -1) && (!ipFlag->Quiet)) + { + fprintf(stderr, "unix2dos: problems renaming '%s' to '%s'\n", TempPath, ipOutFN); +@@ -275,6 +309,7 @@ + RetVal = -1; + } + } ++ free(TempPath); + + return RetVal; + } +@@ -289,7 +324,7 @@ + int RetVal = 0; + FILE *InF = NULL; + FILE *TempF = NULL; +- char TempPath[16]; ++ char *TempPath; + struct stat StatBuf; + struct utimbuf UTimeBuf; + mode_t mode = S_IRUSR | S_IWUSR; +@@ -301,8 +336,7 @@ + else + mode = StatBuf.st_mode; + +- strcpy (TempPath, "./u2dtmpXXXXXX"); +- if((fd=mkstemp (TempPath)) < 0) { ++ if((fd = MakeTempFileFrom(ipInFN, &TempPath)) < 0) { + perror("Can't open output temp file"); + RetVal = -1; + } +@@ -322,6 +356,7 @@ + if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL)) + { + fclose (InF); ++ InF = NULL; + RetVal = -1; + } + +@@ -349,10 +384,6 @@ + RetVal = -1; + } + +- /* can delete in file? */ +- if ((!RetVal) && (unlink(ipInFN) == -1)) +- RetVal = -1; +- + /* any error? */ + if ((RetVal) && (unlink(TempPath))) + RetVal = -1; +@@ -367,6 +398,7 @@ + } + RetVal = -1; + } ++ free(TempPath); + return RetVal; + } + diff --git a/unix2dos-mkstemp.patch b/unix2dos-mkstemp.patch new file mode 100644 index 0000000..034e0a0 --- /dev/null +++ b/unix2dos-mkstemp.patch @@ -0,0 +1,20 @@ +--- unix2dos-2.2/unix2dos.c.orig Fri Nov 17 13:29:24 2000 ++++ unix2dos-2.2/unix2dos.c Fri Nov 17 13:30:16 2000 +@@ -214,7 +214,7 @@ + + strcpy (TempPath, "./u2dtmp"); + strcat (TempPath, "XXXXXX"); +- mktemp (TempPath); ++ mkstemp (TempPath); + + #ifdef DEBUG + fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath); +@@ -293,7 +293,7 @@ + + strcpy (TempPath, "./u2dtmp"); + strcat (TempPath, "XXXXXX"); +- mktemp (TempPath); ++ mkstemp (TempPath); + + #ifdef DEBUG + fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath); diff --git a/unix2dos.spec b/unix2dos.spec new file mode 100644 index 0000000..eff91c2 --- /dev/null +++ b/unix2dos.spec @@ -0,0 +1,148 @@ +Summary: UNIX to DOS text file format converter +Name: unix2dos +Version: 2.2 +Release: 28%{?dist} +License: Distributable +Group: Applications/Text +Source: unix2dos-2.2.src.tar.gz +Patch0: unix2dos-mkstemp.patch +Patch1: unix2dos-2.2-segfault.patch +Patch2: unix2dos-2.2-manpage.patch +Patch3: unix2dos-2.2-mode.patch +Patch4: unix2dos-2.2-tmppath.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%prep +%setup -q -c +%patch -p1 -b .sec +%patch1 -p1 -b .segf +%patch2 -p1 -b .man +%patch3 -p1 -b .mode +%patch4 -p1 -b .tmppath +perl -pi -e "s/^#endif.*/#endif/g;s/^#else.*/#else/g" *.[ch] + +%description +A utility that converts plain text files in UNIX format to DOS format. + +%build +gcc $RPM_OPT_FLAGS -o unix2dos unix2dos.c + +%install +rm -rf ${RPM_BUILD_ROOT} +mkdir -p $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1} +install -p -m755 unix2dos $RPM_BUILD_ROOT%{_bindir} +install -p -m444 unix2dos.1 $RPM_BUILD_ROOT%{_mandir}/man1 + +%clean +rm -rf ${RPM_BUILD_ROOT} + +%files +%defattr(-,root,root,0755) +%doc COPYRIGHT +%{_bindir}/unix2dos +%{_mandir}/*/* + + +%changelog +* Wed Feb 7 2007 Tim Waugh 2.2-28 +- Fixed license tag (bug #226514). + +* Tue Feb 6 2007 Tim Waugh 2.2-27 +- Preserve timestamps on install (bug #226514). +- Fixed summary (bug #226514). +- Fixed build root (bug #226514). +- Don't explicitly require perl for build (bug #226514). +- Added dist to release tag (bug #226514). +- Don't build with '-Wall' since RPM_OPT_FLAGS already includes it + (bug #226514). +- Fixed macros in changelog (bug #226514). + +* Wed Jul 12 2006 Jesse Keating - 2.2-26.2.2 +- rebuild + +* Fri Feb 10 2006 Jesse Keating - 2.2-26.2.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 2.2-26.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Wed Apr 13 2005 Tim Waugh +- Merge last fix into tmppath patch, which introduced the original problem. + +* Tue Apr 12 2005 Tim Waugh 2.2-26 +- Removed inappropriate strcpy (bug #153079). Patch from Neil Horman. + +* Thu Mar 3 2005 Mike A. Harris 2.2-25 +- Rebuild with gcc 4 for FC4 + +* Wed Oct 20 2004 Miloslav Trmac 2.2-24 +- Don't just delete the original file when destination and current directory + are on different filesystems + +* Mon Oct 11 2004 Tim Waugh 2.2-23 +- Apply H J Lu's patch to preserve file mode (bug #91332). + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Fri Feb 13 2004 Elliot Lee +- rebuilt + +* Wed Jun 04 2003 Elliot Lee +- rebuilt + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Mon Oct 7 2002 Mike A. Harris 2.2-18 +- All-arch rebuild + +* Fri Jun 21 2002 Tim Powers +- automated rebuild + +* Thu May 23 2002 Tim Powers +- automated rebuild + +* Tue Mar 5 2002 Bernhard Rosenkraenzer 2.2-15 +- rebuild + +* Thu Jan 17 2002 Bernhard Rosenkraenzer 2.2-14 +- Fix up the mkstemp patch, don't segfault with lacking write permissions + (#57700) +- Fix up man page (part 2 of #57700) +- Fix compiler warnings + +* Wed Jan 09 2002 Tim Powers +- automated rebuild + +* Sun Jun 24 2001 Elliot Lee +- Bump release + rebuild. + +* Fri Nov 17 2000 Tim Powers +- patched to use mkstemp, not much had to be done. + +* Thu Nov 16 2000 Tim Powers +- minor spec file cleanups +- built for 7.1 +- use predefined RPM macros whenever possible +- use RPM_OPT_FLAGS when building + +* Tue Jul 07 1999 Peter Soos +- Added Hungarian "Summary:" and "%%description" +- Corrected the file and directory attributes to rebuild the package + under RedHat Linux 6.0 + +* Thu Jul 09 1998 Arkadiusz Mikkkkkkiewicz +- Recompiled under RedHat Linux 5.1 +- Small changes in %%build and %%files +- Added "Vendor:" +- Added Polish "Summary:" and "%%description" + +* Thu Jun 18 1998 Peter Soos +- Corrected the spec file for rpm 2.5 + +* Fri Dec 5 1997 Peter Soos +- Recompiled under RedHat Linux 5.0