rpms/piggyback/devel import.log, NONE, 1.1 piggyback-man.patch, NONE, 1.1 piggyback-startendcheck.patch, NONE, 1.1 piggyback.c, NONE, 1.1 piggyback.spec, NONE, 1.1 piggyback64.c, NONE, 1.1

Tom Callaway spot at fedoraproject.org
Sun Sep 28 21:41:54 UTC 2008


Author: spot

Update of /cvs/extras/rpms/piggyback/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv25823/devel

Added Files:
	import.log piggyback-man.patch piggyback-startendcheck.patch 
	piggyback.c piggyback.spec piggyback64.c 
Log Message:

initial commit



--- NEW FILE import.log ---
piggyback-2_6_26-2_fc10:HEAD:piggyback-2.6.26-2.fc10.src.rpm:1222637903

piggyback-man.patch:

--- NEW FILE piggyback-man.patch ---
--- piggyback-2.6.16/piggyback.1
+++ piggyback-2.6.16/piggyback.1
@@ -0,0 +1,50 @@
+.\" -*- nroff -*-
+.\" 
+.TH PIGGYBACK 1 "March 1998" "piggyback"
+.SH NAME
+piggyback \- add initial ramdisk to a tftpboot kernel image
+.SH SYNOPSIS
+.B piggyback
+.I vmlinux
+.I System.map
+.I ramdisk
+.P
+.B piggyback64
+.I vmlinux
+.I System.map
+.I ramdisk
+.SH DESCRIPTION
+.BI piggyback
+is a simple utility to make a single-image install kernel with initial
+ramdisk for Sparc tftpbooting without need to set up nfs.
+.P
+.BI piggyback64
+is the same for Ultra-Sparc workstations (those using a 64 bit kernel).
+.PP
+.SH OPTIONS
+.TP
+.I vmlinux
+the kernel on which the ramdisk will be appended.  It must be an
+.B a.out
+kernel (use elftoaout for it), as PROM looks for
+.B a.out
+image only.
+.TP
+.I System.map
+the kernel map.
+.TP
+.I ramdisk
+the initial ramdisk image to append to the kernel image.  It could be
+compressed as well.
+.SH AUTHOR
+.B piggyback
+has been written by Jakub Jelinek <jj at ultra.linux.cz>.
+.SH AVAILABILITY
+.B piggyback
+and
+.B piggyback64
+are available in kernel-source-2.2.x package, under arch/sparc/boot and
+arch/sparc64/boot.
+.SH SEE ALSO
+.BR elftoaout (1),
+.BR tilo (1)
--- piggyback-2.6.16/piggyback64.1
+++ piggyback-2.6.16/piggyback64.1
@@ -0,0 +1,3 @@
+.\" -*- nroff -*-
+.\" 
+.so man1/piggyback.1

piggyback-startendcheck.patch:

--- NEW FILE piggyback-startendcheck.patch ---
--- piggyback-2.6.16/piggyback64.c.BAD	2006-04-12 17:49:52.000000000 -0400
+++ piggyback-2.6.16/piggyback64.c	2006-04-12 17:53:28.000000000 -0400
@@ -56,6 +56,10 @@
 		end = strtoul (buffer + 8, NULL, 16);
 	}
 	fclose (map);
+	if (!start || !end) {
+		fprintf (stderr, "Could not determine start and end from System.map\n");
+		exit(1);
+	}
 	if ((image = open(argv[1],O_RDWR)) < 0) die(argv[1]);
 	if (read(image,buffer,512) != 512) die(argv[1]);
 	if (!memcmp (buffer, "\177ELF", 4)) {


--- NEW FILE piggyback.c ---
/*
   Simple utility to make a single-image install kernel with initial ramdisk
   for Sparc tftpbooting without need to set up nfs.

   Copyright (C) 1996 Jakub Jelinek (jj at sunsite.mff.cuni.cz)
   Pete Zaitcev <zaitcev at yahoo.com> endian fixes for cross-compiles, 2000.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
   
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

/*
 * Note: run this on an a.out kernel (use elftoaout for it),
 * as PROM looks for a.out image only.
 */

unsigned short ld2(char *p)
{
	return (p[0] << 8) | p[1];
}

unsigned int ld4(char *p)
{
	return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}

void st4(char *p, unsigned int x)
{
	p[0] = x >> 24;
	p[1] = x >> 16;
	p[2] = x >> 8;
	p[3] = x;
}

void usage(void)
{
	/* fs_img.gz is an image of initial ramdisk. */
	fprintf(stderr, "Usage: piggyback vmlinux.aout System.map fs_img.gz\n");
	fprintf(stderr, "\tKernel image will be modified in place.\n");
	exit(1);
}

void die(char *str)
{
	perror (str);
	exit(1);
}

int main(int argc,char **argv)
{
	static char aout_magic[] = { 0x01, 0x03, 0x01, 0x07 };
	unsigned char buffer[1024], *q, *r;
	unsigned int i, j, k, start, end, offset;
	FILE *map;
	struct stat s;
	int image, tail;

	if (argc != 4) usage();
	start = end = 0;
	if (stat (argv[3], &s) < 0) die (argv[3]);
	map = fopen (argv[2], "r");
	if (!map) die(argv[2]);
	while (fgets (buffer, 1024, map)) {
		if (!strcmp (buffer + 8, " T start\n") || !strcmp (buffer + 16, " T start\n"))
			start = strtoul (buffer, NULL, 16);
		else if (!strcmp (buffer + 8, " A end\n") || !strcmp (buffer + 16, " A end\n"))
			end = strtoul (buffer, NULL, 16);
	}
	fclose (map);
	if (!start || !end) {
		fprintf (stderr, "Could not determine start and end from System.map\n");
		exit(1);
	}
	if ((image = open(argv[1],O_RDWR)) < 0) die(argv[1]);
	if (read(image,buffer,512) != 512) die(argv[1]);
	if (memcmp (buffer, "\177ELF", 4) == 0) {
		q = buffer + ld4(buffer + 28);
		i = ld4(q + 4) + ld4(buffer + 24) - ld4(q + 8);
		if (lseek(image,i,0) < 0) die("lseek");
		if (read(image,buffer,512) != 512) die(argv[1]);
		j = 0;
	} else if (memcmp(buffer, aout_magic, 4) == 0) {
		i = j = 32;
	} else {
		fprintf (stderr, "Not ELF nor a.out. Don't blame me.\n");
		exit(1);
	}
	k = i;
	i += (ld2(buffer + j + 2)<<2) - 512;
	if (lseek(image,i,0) < 0) die("lseek");
	if (read(image,buffer,1024) != 1024) die(argv[1]);
	for (q = buffer, r = q + 512; q < r; q += 4) {
		if (*q == 'H' && q[1] == 'd' && q[2] == 'r' && q[3] == 'S')
			break;
	}
	if (q == r) {
		fprintf (stderr, "Couldn't find headers signature in the kernel.\n");
		exit(1);
	}
	offset = i + (q - buffer) + 10;
	if (lseek(image, offset, 0) < 0) die ("lseek");

	st4(buffer, 0);
	st4(buffer + 4, 0x01000000);
	st4(buffer + 8, (end + 32 + 4095) & ~4095);
	st4(buffer + 12, s.st_size);

	if (write(image,buffer+2,14) != 14) die (argv[1]);
	if (lseek(image, k - start + ((end + 32 + 4095) & ~4095), 0) < 0) die ("lseek");
	if ((tail = open(argv[3],O_RDONLY)) < 0) die(argv[3]);
	while ((i = read (tail,buffer,1024)) > 0)
		if (write(image,buffer,i) != i) die (argv[1]);
	if (close(image) < 0) die("close");
	if (close(tail) < 0) die("close");
    	return 0;
}


--- NEW FILE piggyback.spec ---
Summary: Utility for making net-bootable sparc kernel image files
Name: piggyback
Version: 2.6.26
Release: 2%{?dist}
ExclusiveArch: sparcv9
License: GPLv2+
Group: System Environment/Kernel
URL: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git
# Downloaded Sun Sep 28, 2008
Source0: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=arch/sparc/boot/piggyback.c
# From: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=arch/sparc64/boot/piggyback.c
Source1: piggyback64.c
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Patch0: piggyback-startendcheck.patch
Patch1: piggyback-man.patch

%description
The piggyback utilities are designed to attach an initial ramdisk to an a.out 
format kernel image. Syntax: piggyback kernel.aout System.map initrd.img

%prep
%setup -q -T -c %{name}-%{version}
cp %{SOURCE0} %{SOURCE1} . 
%patch0 -p1
%patch1 -p1

%build
gcc $RPM_OPT_FLAGS -o piggyback piggyback.c
gcc $RPM_OPT_FLAGS -o piggyback64 piggyback64.c

%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_bindir}
install -m 0755 piggyback $RPM_BUILD_ROOT%{_bindir}/piggyback
install -m 0755 piggyback64 $RPM_BUILD_ROOT%{_bindir}/piggyback64
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
install -m 0644 piggyback.1 $RPM_BUILD_ROOT/%{_mandir}/man1/
install -m 0644 piggyback64.1 $RPM_BUILD_ROOT/%{_mandir}/man1/

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{_bindir}/piggyback
%{_bindir}/piggyback64
%{_mandir}/man1/piggyback*

%changelog
* Sun Sep 28 2008 Tom "spot" Callaway <tcallawa at redhat.com> 2.6.26-2
- don't strip the binaries

* Sun Sep 28 2008 Tom "spot" Callaway <tcallawa at redhat.com> 2.6.26-1
- initial package for Fedora, update to 2.6.26 source

* Sun Dec 24 2006 Tom "spot" Callaway <tcallawa at redhat.com>
- rebuild for aurora3

* Wed Apr 12 2006 Tom "spot" Callaway <tcallawa at redhat.com>
- initial package from 2.6.16 kernel source


--- NEW FILE piggyback64.c ---
/*
   Simple utility to make a single-image install kernel with initial ramdisk
   for Sparc64 tftpbooting without need to set up nfs.
   
   Copyright (C) 1997 Jakub Jelinek (jj at sunsite.mff.cuni.cz)
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
   
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

/* Note: run this on an a.out kernel (use elftoaout for it), as PROM looks for a.out image onlly
   usage: piggyback vmlinux System.map tail, where tail is gzipped fs of the initial ramdisk */

void die(char *str)
{
	perror (str);
	exit(1);
}

int main(int argc,char **argv)
{
	char buffer [1024], *q, *r;
	unsigned int i, j, k, start, end, offset;
	FILE *map;
	struct stat s;
	int image, tail;
	
	if (stat (argv[3], &s) < 0) die (argv[3]);
	map = fopen (argv[2], "r");
	if (!map) die(argv[2]);
	while (fgets (buffer, 1024, map)) {
		if (!strcmp (buffer + 19, "_start\n"))
		start = strtoul (buffer + 8, NULL, 16);
		else if (!strcmp (buffer + 19, "_end\n"))
		end = strtoul (buffer + 8, NULL, 16);
	}
	fclose (map);
	if ((image = open(argv[1],O_RDWR)) < 0) die(argv[1]);
	if (read(image,buffer,512) != 512) die(argv[1]);
	if (!memcmp (buffer, "\177ELF", 4)) {
		unsigned int *p = (unsigned int *)(buffer + *(unsigned int *)(buffer + 28));
		
		i = p[1] + *(unsigned int *)(buffer + 24) - p[2];
		if (lseek(image,i,0) < 0) die("lseek");
		if (read(image,buffer,512) != 512) die(argv[1]);
		j = 0;
	} else if (*(unsigned int *)buffer == 0x01030107) {
		i = j = 32;
	} else {
		fprintf (stderr, "Not ELF nor a.out. Don't blame me.\n");
		exit(1);
	}
	k = i;
	if (j == 32 && buffer[40] == 'H' && buffer[41] == 'd' && buffer[42] == 'r' && buffer[43] == 'S') {
		offset = 40 + 10;
	} else {
		i += ((*(unsigned short *)(buffer + j + 2))<<2) - 512;
		if (lseek(image,i,0) < 0) die("lseek");
		if (read(image,buffer,1024) != 1024) die(argv[1]);
		for (q = buffer, r = q + 512; q < r; q += 4) {
			if (*q == 'H' && q[1] == 'd' && q[2] == 'r' && q[3] == 'S')
				break;
		}
		if (q == r) {
			fprintf (stderr, "Couldn't find headers signature in the kernel.\n");
			exit(1);
		}
		offset = i + (q - buffer) + 10;
	}
	if (lseek(image, offset, 0) < 0) die ("lseek");
	*(unsigned *)buffer = 0;
	*(unsigned *)(buffer + 4) = 0x01000000;
	*(unsigned *)(buffer + 8) = ((end + 32 + 8191) & ~8191);
	*(unsigned *)(buffer + 12) = s.st_size;
	if (write(image,buffer+2,14) != 14) die (argv[1]);
	if (lseek(image, 4, 0) < 0) die ("lseek");
	*(unsigned *)buffer = ((end + 32 + 8191) & ~8191) - (start & ~0x3fffffUL) + s.st_size;
	*(unsigned *)(buffer + 4) = 0;
	*(unsigned *)(buffer + 8) = 0;
	if (write(image,buffer,12) != 12) die (argv[1]);
	if (lseek(image, k - start + ((end + 32 + 8191) & ~8191), 0) < 0) die ("lseek");
	if ((tail = open(argv[3],O_RDONLY)) < 0) die(argv[3]);
	while ((i = read (tail,buffer,1024)) > 0)
		if (write(image,buffer,i) != i) die (argv[1]);
	if (close(image) < 0) die("close");
	if (close(tail) < 0) die("close");
    	return 0;
}




More information about the fedora-extras-commits mailing list