]> git.pld-linux.org Git - packages/poldek.git/blob - poldek-hold-fix.patch
- fixed fix (%$#@!)
[packages/poldek.git] / poldek-hold-fix.patch
1 --- pkgscore.c  17 Oct 2002 15:54:53 -0000      1.2
2 +++ pkgscore.c  14 Nov 2002 13:35:19 -0000
3 @@ -30,7 +30,7 @@
4  #include "i18n.h"
5  #include "log.h"
6  #include "pkg.h"
7 -
8 +#include "pkgset.h"
9  
10  static
11  tn_array *read_patterns(const char *fpath, tn_array *patterns, unsigned type)
12 @@ -108,9 +108,39 @@
13  }
14  
15  
16 +
17 +void pkgscore_match_init(struct pkgscore_s *psc, struct pkg *pkg) 
18 +{
19 +    int n = 0;
20 +    
21 +    if (pkg->pkgdir)
22 +        n += n_snprintf(psc->pkgbuf, sizeof(psc->pkgbuf), "%s:", pkg->pkgdir->name);
23 +
24 +    psc->pkgname_off = n;
25 +    
26 +    pkg_snprintf(&psc->pkgbuf[n], sizeof(psc->pkgbuf) - n, pkg);
27 +    psc->pkg = pkg;
28 +}
29 +
30 +    
31 +
32 +int pkgscore_match(struct pkgscore_s *psc, const char *mask)
33 +{
34 +    if (fnmatch(mask, psc->pkg->name, 0) == 0)
35 +        return 1;
36 +
37 +    if (psc->pkgname_off && fnmatch(mask, &psc->pkgbuf[psc->pkgname_off], 0) == 0)
38 +        return 1;
39 +    
40 +    return fnmatch(mask, psc->pkgbuf, 0) == 0;
41 +}
42 +
43 +    
44 +
45  void packages_score(tn_array *pkgs, tn_array *patterns, unsigned scoreflag) 
46  {
47      int i, j;
48 +    
49  
50      n_assert(patterns);
51      if (n_array_size(patterns) == 0) 
52 @@ -120,23 +150,19 @@
53          return;
54  
55      for (i=0; i < n_array_size(pkgs); i++) {
56 -        struct pkg *pkg = n_array_nth(pkgs, i);
57 -        char  pkgbuf[1024];
58 -        int   n = 0;
59 +        struct pkgscore_s  psc;
60 +        struct pkg         *pkg;
61  
62 -        if (pkg->pkgdir)
63 -                n += n_snprintf(pkgbuf, sizeof(pkgbuf), "%s:", pkg->pkgdir->name);
64 -        
65 -        pkg_snprintf(&pkgbuf[n], sizeof(pkgbuf) - n, pkg);
66 +        pkg = n_array_nth(pkgs, i);
67 +        pkgscore_match_init(&psc, pkg);
68          
69 -        for (j=0; j<n_array_size(patterns); j++) {
70 +        for (j=0; j < n_array_size(patterns); j++) {
71              const char *mask = n_array_nth(patterns, j);
72 -            
73 -            if (fnmatch(mask, &pkgbuf[n], 0) == 0 || (n && fnmatch(mask, pkgbuf, 0) == 0)) {
74  
75 +            if (pkgscore_match(&psc, mask)) {
76                  switch (scoreflag) {
77                      case PKG_HELD:
78 -                        msgn(3, "held %s", pkg_snprintf_s(pkg));
79 +                        msgn(1, "held %s", pkg_snprintf_s(pkg));
80                          DBGMSG_F("HELD %s\n", pkg_snprintf_s(pkg));
81                          pkg_score(pkg, PKG_HELD);
82                          break;
83 --- pkgset-install.c    7 Nov 2002 16:43:26 -0000       1.79
84 +++ pkgset-install.c    14 Nov 2002 13:35:19 -0000
85 @@ -1778,15 +1778,20 @@
86          return 1;
87  
88      for (i=0; i < n_array_size(upg->uninst_set->dbpkgs); i++) {
89 -        struct dbpkg *dbpkg = n_array_nth(upg->uninst_set->dbpkgs, i);
90 +        struct dbpkg *dbpkg; 
91 +        struct pkgscore_s psc;
92  
93 +        dbpkg = n_array_nth(upg->uninst_set->dbpkgs, i);
94 +        pkgscore_match_init(&psc, dbpkg->pkg);
95 +        
96          for (j=0; j < n_array_size(upg->inst->hold_patterns); j++) {
97              const char *mask = n_array_nth(upg->inst->hold_patterns, j);
98 -
99 -            if (fnmatch(mask, dbpkg->pkg->name, 0) == 0) {
100 +            
101 +            if (pkgscore_match(&psc, mask)) {
102                  logn(LOGERR, _("%s: refusing to uninstall held package"),
103 -                    pkg_snprintf_s(dbpkg->pkg));
104 +                     pkg_snprintf_s(dbpkg->pkg));
105                  rc = 0;
106 +                break;
107              }
108          }
109      }
110 @@ -2228,6 +2233,9 @@
111      if (inst->flags & INSTS_INSTALL)
112          n_assert((inst->flags & INSTS_UPGRADE) == 0);
113  
114 +
115 +    packages_mark(ps->pkgs, 0, PKG_INTERNALMARK | PKG_INDIRMARK);
116 +
117      unmark_name_dups(ps->pkgs);
118      
119      mem_info(1, "ENTER pkgset_install:");
120 @@ -2241,6 +2249,8 @@
121  
122      if (inst->flags & INSTS_JUSTPRINTS)
123          inst->flags &= ~INSTS_PARTICLE;
124 +
125 +    
126      
127      for (i = 0; i < n_array_size(ps->ordered_pkgs); i++) {
128          struct pkg    *pkg = n_array_nth(ps->ordered_pkgs, i);
129 @@ -2270,8 +2280,15 @@
130          inst->flags &= ~INSTS_PARTICLE;
131      
132      n = 1;
133 -    pkgset_mark(ps, PS_MARK_OFF_ALL);
134 -    
135 +    packages_mark(ps->pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK);
136 +    //pkgset_mark(ps, PS_MARK_OFF_ALL);
137 +#if 0                           /* debug */
138 +    for (i = 0; i < n_array_size(ps->ordered_pkgs); i++) {
139 +        struct pkg *pkg = n_array_nth(ps->ordered_pkgs, i);
140 +        if (pkg_is_marked_i(pkg)) 
141 +            printf("MARKED %s\n", pkg_snprintf_s(pkg));
142 +    }
143 +#endif    
144      for (i = 0; i < n_array_size(ps->ordered_pkgs); i++) {
145          struct pkg *pkg = n_array_nth(ps->ordered_pkgs, i);
146  
147 @@ -2302,7 +2319,8 @@
148              if (!do_install(ps, &upg, iinf))
149                  nerr++;
150              
151 -            pkgset_mark(ps, PS_MARK_OFF_ALL);
152 +            packages_mark(ps->pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK);
153 +            //pkgset_mark(ps, PS_MARK_OFF_ALL);
154              reset_upgrade_s(&upg);
155          }
156      }
157 @@ -2312,6 +2330,7 @@
158          nerr = !do_install(ps, &upg, iinf);
159  
160   l_end:
161 +    
162      destroy_upgrade_s(&upg);
163      mem_info(1, "RETURN pkgset_install:");
164      if (is_particle)
165 --- pkgset.c    24 Oct 2002 16:23:10 -0000      1.54
166 +++ pkgset.c    14 Nov 2002 13:35:19 -0000
167 @@ -725,7 +725,7 @@
168      return nerr == 0;
169  }
170  
171 -
172 +#if 0
173  static void mapfn_mark(struct pkg *pkg, unsigned *flags) 
174  {
175      n_assert(flags);
176 @@ -745,13 +745,42 @@
177      }
178  }
179  
180 -
181  void pkgset_mark(struct pkgset *ps, unsigned flags) 
182  {
183      if (ps->pkgs) 
184          n_array_map_arg(ps->pkgs, (tn_fn_map2) mapfn_mark, &flags);
185      
186  }
187 +#endif
188 +
189 +struct flags_s {
190 +    unsigned flags_on;
191 +    unsigned flags_off;
192 +};
193 +
194 +
195 +static void mapfn_mark2(struct pkg *pkg, struct flags_s *fs) 
196 +{
197 +    n_assert(fs);
198 +
199 +    if (fs->flags_on)
200 +        pkg->flags |= fs->flags_on;
201 +
202 +    if (fs->flags_off)
203 +        pkg->flags &= ~fs->flags_off;
204 +    
205 +}
206 +
207 +void packages_mark(tn_array *pkgs, unsigned flags_on, unsigned flags_off) 
208 +{
209 +    struct flags_s fs;
210 +
211 +    fs.flags_on = flags_on;
212 +    fs.flags_off = flags_off;
213 +    
214 +    n_array_map_arg(pkgs, (tn_fn_map2) mapfn_mark2, &fs);
215 +}
216 +
217  
218  
219  inline static int mark_package(struct pkg *pkg, int nodeps)
220 @@ -900,7 +929,8 @@
221  {
222      int i, nerr = 0, nodeps = 0, npatterns = 0;
223  
224 -    pkgset_mark(ps, PS_MARK_OFF_ALL);
225 +    packages_mark(ps->pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK);
226 +    //pkgset_mark(ps, PS_MARK_OFF_ALL);
227  
228      if (ps->flags & PSMODE_INSTALL_DIST)
229          nodeps = inst->flags & INSTS_NODEPS;
230 @@ -999,7 +1029,8 @@
231          
232          else {
233              if ((inst->flags & INSTS_FORCE) == 0)
234 -                pkgset_mark(ps, PS_MARK_OFF_ALL);
235 +                packages_mark(ps->pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK);
236 +            //pkgset_mark(ps, PS_MARK_OFF_ALL);
237              logn(LOGERR, _("Buggy package set."));
238          }
239      }
240 --- pkgset.h    24 Oct 2002 16:23:10 -0000      1.36
241 +++ pkgset.h    14 Nov 2002 13:35:19 -0000
242 @@ -143,12 +143,14 @@
243  /* uninstall.c */
244  int uninstall_usrset(struct usrpkgset *ups, struct inst_s *inst,
245                       struct install_info *iinf);
246 -
247 +#if 0
248  #define PS_MARK_OFF_ALL      (1 << 0)
249  #define PS_MARK_OFF_DEPS     (1 << 1)
250  #define PS_MARK_ON_INTERNAL  (1 << 2) /* use with one of above PS_MARK_* */
251  
252  void pkgset_mark(struct pkgset *ps, unsigned markflags);
253 +#endif
254 +
255  
256  int pkgset_fetch_pkgs(const char *destdir, tn_array *pkgs, int nosubdirs);
257  
258 @@ -166,7 +168,21 @@
259  
260  int pkgset_rpmprovides(const struct pkgset *ps, const struct capreq *req);
261  
262 +
263 +struct pkgscore_s {
264 +    char        pkgbuf[512];
265 +    int         pkgname_off;
266 +    struct pkg  *pkg;
267 +};
268 +
269 +void pkgscore_match_init(struct pkgscore_s *psc, struct pkg *pkg);
270 +int pkgscore_match(struct pkgscore_s *psc, const char *mask);
271  void packages_score(tn_array *pkgs, tn_array *patterns, unsigned scoreflag);
272 +
273 +void packages_mark(tn_array *pkgs, unsigned flags_on, unsigned flags_off);
274 +
275 +#define packages_unmark_all(pkgs) packages_mark(pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK)
276 +
277  int packages_fetch(tn_array *pkgs, const char *destdir, int nosubdirs);
278  int packages_rpminstall(tn_array *pkgs, struct pkgset *ps, struct inst_s *inst);
279  
280 --- shell/install.c     18 Oct 2002 10:34:41 -0000      1.22
281 +++ shell/install.c     14 Nov 2002 13:35:19 -0000
282 @@ -209,7 +209,7 @@
283          goto l_end;
284      }
285  
286 -    pkgset_mark(cmdarg->sh_s->pkgset, PS_MARK_OFF_ALL);
287 +    packages_unmark_all(cmdarg->sh_s->pkgset->pkgs);
288      
289      for (i=0; i < n_array_size(shpkgs); i++) {
290          struct shpkg *shpkg = n_array_nth(shpkgs, i);
291 --- vfile/vftp/ftp.c    7 Nov 2002 16:43:30 -0000       1.19
292 +++ vfile/vftp/ftp.c    14 Nov 2002 13:35:20 -0000
293 @@ -86,6 +86,7 @@
294  {
295      if (*errmsg == '\0')
296          return NULL;
297 +    
298      return errmsg;
299  }
300  
301 @@ -100,6 +101,14 @@
302      vftp_errno = err_no;
303  }
304  
305 +static int vftp_sigint_reached(void)
306 +{
307 +    int v;
308 +    if ((v = sigint_reached()) && vftp_errno == 0)
309 +        vftp_set_err(EINTR, _("connection cancelled"));
310 +    
311 +    return v;
312 +}
313  
314  
315  static int do_ftp_cmd(int sock, char *fmt, va_list args)
316 @@ -107,7 +116,7 @@
317      char     buf[1024], tmp_fmt[256];
318      int      n;
319  
320 -    if (sigint_reached())
321 +    if (vftp_sigint_reached())
322          return 0;
323  
324      snprintf(tmp_fmt, sizeof(tmp_fmt), "%s\r\n", fmt);
325 @@ -289,7 +298,7 @@
326          FD_SET(sockfd, &fdset);
327          errno = 0;
328          if ((rc = select(sockfd + 1, &fdset, NULL, NULL, &to)) < 0) {
329 -            if (sigint_reached()) {
330 +            if (vftp_sigint_reached()) {
331                  is_err = 1;
332                  errno = EINTR;
333                  break;
334 @@ -367,10 +376,8 @@
335                  break;
336                  
337              case EINTR:
338 -                if (sigint_reached()) {
339 -                    vftp_set_err(vftp_errno, _("connection canceled"));
340 +                if (vftp_sigint_reached()) 
341                      break;
342 -                }
343                  
344              default:
345                  vftp_set_err(vftp_errno, "%s: %m", _("unexpected EOF"));
346 @@ -389,7 +396,7 @@
347      int is_err = 0;
348  
349  
350 -    if (sigint_reached())
351 +    if (vftp_sigint_reached())
352          return 0;
353      
354      ftp_response_init(&resp);
355 @@ -407,7 +414,7 @@
356              if (response_complete(&resp))
357                  break;
358  
359 -            if (sigint_reached()) {
360 +            if (vftp_sigint_reached()) {
361                  is_err = 1;
362                  break;
363              }
364 @@ -518,7 +525,7 @@
365      vftp_errno = 0;
366      
367      do {
368 -        sigint_reached();
369 +        sigint_reset();
370          
371          sockfd = socket(resp->ai_family, resp->ai_socktype, resp->ai_protocol);
372          if (sockfd < 0)
373 @@ -531,6 +538,10 @@
374          if (alarm_reached)
375              vftp_errno = errno = ETIMEDOUT;
376          
377 +        else if (vftp_sigint_reached()) {
378 +            errno = EINTR;
379 +            break;
380 +        }
381          uninstall_alarm();
382          close(sockfd);
383          sockfd = -1;
384 @@ -546,6 +557,7 @@
385          *addr->ai_addr = *resp->ai_addr;
386      }
387  
388 +    uninstall_alarm();
389      freeaddrinfo(res);
390      return sockfd;
391  }
392 @@ -561,7 +573,7 @@
393      if ((sockfd = to_connect(host, portstr, addr)) < 0)
394          return 0;
395      
396 -    if (sigint_reached())
397 +    if (vftp_sigint_reached())
398          return 0;
399      
400      errno = 0;
401 @@ -859,7 +871,7 @@
402         tv.tv_usec = 0;
403          
404          rc = select(in_fd + 1, &fdset, NULL, NULL, &tv);
405 -        if (sigint_reached()) {
406 +        if (vftp_sigint_reached()) {
407              is_err = 1;
408              errno = EINTR;
409              break;
410 @@ -939,13 +951,13 @@
411      if ((total_size = ftpcn_size(cn, path)) < 0)
412          goto l_err;
413  
414 -    if (sigint_reached())
415 +    if (vftp_sigint_reached())
416          goto l_err;
417      
418      if ((sockfd = ftpcn_pasv(cn)) <= 0)
419          goto l_err;
420  
421 -    if (sigint_reached())
422 +    if (vftp_sigint_reached())
423          goto l_err;
424  
425      if (out_fdoff < 0)
426 --- vfile/vhttp/http.c  7 Nov 2002 16:43:31 -0000       1.12
427 +++ vfile/vhttp/http.c  14 Nov 2002 13:35:20 -0000
428 @@ -149,6 +149,16 @@
429      vhttp_errno = err_no;
430  }
431  
432 +static int vhttp_sigint_reached(void)
433 +{
434 +    int v;
435 +    if ((v = sigint_reached()) && vhttp_errno == 0)
436 +        vhttp_set_err(EINTR, _("connection cancelled"));
437 +
438 +    return v;
439 +}
440 +
441 +
442  static char *make_req_line(char *buf, int size, char *fmt, ...) 
443  {
444      va_list  args;
445 @@ -451,7 +461,7 @@
446          FD_SET(sockfd, &fdset);
447          errno = 0;
448          if ((rc = select(sockfd + 1, &fdset, NULL, NULL, &to)) < 0) {
449 -            if (sigint_reached()) {
450 +            if (vhttp_sigint_reached()) {
451                  is_err = 1;
452                  errno = EINTR;
453                  break;
454 @@ -530,11 +540,9 @@
455                  break;
456                  
457              case EINTR:
458 -                if (sigint_reached()) {
459 -                    vhttp_set_err(vhttp_errno, _("connection canceled"));
460 +                if (vhttp_sigint_reached()) 
461                      break;
462 -                }
463 -                
464 +
465              default:
466                  vhttp_set_err(vhttp_errno, "%s: %m", _("unexpected EOF"));
467                  
468 @@ -642,7 +650,7 @@
469      while (1) {
470          int n;
471  
472 -        if (sigint_reached()) {
473 +        if (vhttp_sigint_reached()) {
474              is_err = 1;
475              break;
476          }
477 @@ -790,9 +798,9 @@
478          if (alarm_reached)
479              vhttp_errno = errno = ETIMEDOUT;
480  
481 -        else if (sigint_reached() && errno == EINTR)
482 -            vhttp_errno = EINTR;
483 -        
484 +        else if (vhttp_sigint_reached() && errno == EINTR)
485 +            break;
486 +
487          uninstall_alarm();
488          close(sockfd);
489          sockfd = -1;
490 @@ -801,7 +809,8 @@
491  
492      if (sockfd == -1)
493          vhttp_set_err(errno, _("unable to connect to %s:%s: %m"), host, service);
494 -    
495 +
496 +    uninstall_alarm();
497      freeaddrinfo(res);
498      return sockfd;
499  }
500 @@ -957,7 +966,7 @@
501         tv.tv_usec = 0;
502          
503          rc = select(in_fd + 1, &fdset, NULL, NULL, &tv);
504 -        if (sigint_reached()) {
505 +        if (vhttp_sigint_reached()) {
506              is_err = 1;
507              errno = EINTR;
508              break;
This page took 0.063657 seconds and 3 git commands to generate.