summaryrefslogtreecommitdiff
path: root/recipes/ipkg/files/is-processing.patch
blob: 45ede41668a5b6f7ba5b184a4f8f1a81cca1bc08 (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
diff -Nur ipkg-0.99.163.orig/ipkg_install.c ipkg-0.99.163/ipkg_install.c
--- ipkg-0.99.163.orig/ipkg_install.c	2006-03-30 21:50:24.000000000 +0800
+++ ipkg-0.99.163/ipkg_install.c	2007-03-15 08:01:20.000000000 +0800
@@ -211,6 +211,7 @@
 	anyone ever wants to make a nice libipkg. */
 
      ipkg_message(conf, IPKG_DEBUG2,"Function: %s calling ipkg_install_pkg \n",__FUNCTION__);
+     new->is_processing = 1;
      return ipkg_install_pkg(conf, new,0);
 }
 
diff -Nur ipkg-0.99.163.orig/libbb/unzip.c ipkg-0.99.163/libbb/unzip.c
--- ipkg-0.99.163.orig/libbb/unzip.c	2006-02-06 16:13:02.000000000 +0800
+++ ipkg-0.99.163/libbb/unzip.c	2007-03-15 08:03:45.000000000 +0800
@@ -1028,13 +1028,15 @@
  */
 extern void gz_close(int gunzip_pid)
 {
-	if (kill(gunzip_pid, SIGTERM) == -1) {
-		error_msg_and_die("***  Couldnt kill old gunzip process *** aborting");
-	}
+	if (kill(gunzip_pid, 0) == 0) {
+		if (kill(gunzip_pid, SIGTERM) == -1) {
+			error_msg_and_die("***  Couldnt kill old gunzip process *** aborting");
+		}
 
-	if (waitpid(gunzip_pid, NULL, 0) == -1) {
-		printf("Couldnt wait ?");
+		if (waitpid(gunzip_pid, NULL, 0) == -1) {
+			printf("Couldnt wait ?");
+		}
 	}
-		free(window);
-		free(crc_table);
+	free(window);
+	free(crc_table);
 }
diff -Nur ipkg-0.99.163.orig/pkg.c ipkg-0.99.163/pkg.c
--- ipkg-0.99.163.orig/pkg.c	2006-04-21 04:29:28.000000000 +0800
+++ ipkg-0.99.163/pkg.c	2007-03-20 15:11:32.845064480 +0800
@@ -33,6 +33,7 @@
 #include "xsystem.h"
 #include "ipkg_conf.h"
 
+
 typedef struct enum_map enum_map_t;
 struct enum_map
 {
@@ -522,6 +523,10 @@
      strncat(buff ,line, strlen(line));
      free(line);
 
+     line = pkg_formatted_field(pkg, "Installed-Size");
+     strncat(buff ,line, strlen(line));
+     free(line);
+     
      return buff;
 }
 
@@ -542,7 +547,6 @@
      }
 
      temp[0]='\0'; 
-
      switch (field[0])
      {
      case 'a':
@@ -690,13 +694,42 @@
      case 'I': {
 	  if (strcasecmp(field, "Installed-Size") == 0) {
 	       /* Installed-Size */
-               temp = (char *)realloc(temp,strlen(pkg->installed_size)+17);
-               if ( temp == NULL ){
-	           fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
-	           return NULL;
-               }
-               temp[0]='\0';
-               snprintf(temp, (strlen(pkg->installed_size)+17), "Installed-Size: %s\n", pkg->installed_size);
+	       if (pkg->installed_size) {
+                  temp = (char *)realloc(temp,strlen(pkg->installed_size)+18);
+                  if ( temp == NULL ){
+	             fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
+	             return NULL;
+                  }
+                  temp[0]='\0';
+                  snprintf(temp, (strlen(pkg->installed_size)+18), "Installed-Size: %s\n", pkg->installed_size);
+	       } else {
+	          /* Caculate installed files size */
+	          str_list_elt_t *iter;
+		  struct stat buf;
+		  int installed_files_length = 0;
+		  if (pkg->installed_files == NULL)
+		     break;
+
+		  if (pkg->is_processing!=1) 
+		     break;
+		  
+	          for (iter = pkg->installed_files->head; iter; iter = iter->next) {
+		     memset(&buf, 0, sizeof(struct stat));
+		     stat(iter->data, &buf);
+		     if (S_ISREG(buf.st_mode))
+		        installed_files_length += buf.st_size;
+	          }
+		  /*printf("installed_files_length:%d\n", installed_files_length);*/
+	          
+		  sprintf_alloc(&pkg->installed_size, "%d", installed_files_length);
+                  temp = (char *)realloc(temp,strlen(pkg->installed_size)+18);
+                  if ( temp == NULL ){
+	             fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
+	             return NULL;
+                  }
+                  temp[0]='\0';
+                  snprintf(temp, (strlen(pkg->installed_size)+18), "Installed-Size: %s\n", pkg->installed_size);
+	       }
 	  } else if (strcasecmp(field, "Installed-Time") == 0 && pkg->installed_time) {
                temp = (char *)realloc(temp,29);
                if ( temp == NULL ){
@@ -720,7 +753,7 @@
 	              return NULL;
                    }
                    temp[0]='\0';
-                   snprintf(temp, (strlen(pkg->maintainer)+14), "maintainer: %s\n", pkg->maintainer);
+                   snprintf(temp, (strlen(pkg->maintainer)+14), "Maintainer: %s\n", pkg->maintainer);
 	       }
 	  } else if (strcasecmp(field, "MD5sum") == 0) {
 	       /* MD5sum */
@@ -871,6 +904,24 @@
                    }
                    temp[0]='\0';
                    snprintf(temp, (strlen(pkg->size)+8), "Size: %s\n", pkg->size);
+	       } else {
+                  if ( pkg->local_filename ) {
+                     struct stat buf;
+		     memset(&buf, 0, sizeof(struct stat));
+		     
+		     if ( stat(pkg->local_filename, &buf) == 0 ) {
+
+		        sprintf_alloc(&pkg->size, "%d", buf.st_size);
+                        temp = (char *)realloc(temp, strlen(pkg->size)+8);
+                        if ( temp == NULL ){
+                           fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
+                           return NULL;
+                        }
+                        temp[0]='\0';
+                        snprintf(temp, (strlen(pkg->size)+8), "Size: %s\n", pkg->size);
+		     }
+                  }
+		       
 	       }
 	  } else if (strcasecmp(field, "Source") == 0) {
 	       /* Source */
@@ -1016,6 +1067,12 @@
      pkg_print_field(pkg, file, "Essential"); /* @@@@ should be removed in future release. */
      pkg_print_field(pkg, file, "Architecture");
      pkg_print_field(pkg, file, "Conffiles");
+     pkg_print_field(pkg, file, "Description");
+     pkg_print_field(pkg, file, "Maintainer");
+     pkg_print_field(pkg, file, "Section");
+     pkg_print_field(pkg, file, "Size");
+     pkg_print_field(pkg, file, "Filename");
+     pkg_print_field(pkg, file, "Installed-Size");
      pkg_print_field(pkg, file, "Installed-Time");
      fputs("\n", file);
 }
diff -Nur ipkg-0.99.163.orig/pkg.h ipkg-0.99.163/pkg.h
--- ipkg-0.99.163.orig/pkg.h	2006-05-30 16:31:08.000000000 +0800
+++ ipkg-0.99.163/pkg.h	2007-03-15 08:01:20.000000000 +0800
@@ -176,6 +176,10 @@
      int arch_priority;
 /* Adding this flag, to "force" ipkg to choose a "provided_by_hand" package, if there are multiple choice */
      int provided_by_hand;
+
+     /* Check whether this pkg is being removed or installed */
+     int is_processing;
+     
 };
 
 pkg_t *pkg_new(void);