~ubuntu-branches/ubuntu/raring/reprepro/raring

« back to all changes in this revision

Viewing changes to needbuild.c

  • Committer: Bazaar Package Importer
  • Author(s): Bernhard R. Link
  • Date: 2011-05-05 16:34:23 UTC
  • mfrom: (21.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110505163423-x49kbdijyoubai4x
Tags: 4.6.0-1
* new release
- general cleanup
- new FilterSrcList
* increase Standards-Version, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
   For each source package check:
39
39
        - if tracking is enabled and there is a .log or .changes file
40
40
          for the given arch -> SKIP
41
 
        - if there is a binary package for the given architecture -> SKIP
 
41
        - if there is a binary package for the given architecture -> SKIP
42
42
        - if the package's Architecture field excludes this arch -> SKIP
43
43
        - if the package's Binary field only lists existing ones
44
44
          (i.e. architecture all) -> SKIP
51
51
        int i;
52
52
 
53
53
        memset(found_binary, 0, sizeof(bool)*binary->count);
54
 
        for( i = 0 ; i < tp->filekeys.count ; i++ ) {
 
54
        for (i = 0 ; i < tp->filekeys.count ; i++) {
55
55
                enum filetype ft = tp->filetypes[i];
56
56
                const char *fk = tp->filekeys.values[i];
57
57
 
58
 
                if( ft == ft_XTRA_DATA )
 
58
                if (ft == ft_XTRA_DATA)
59
59
                        continue;
60
 
                if( ft == ft_ALL_BINARY ) {
 
60
                if (ft == ft_ALL_BINARY) {
61
61
                        int j;
62
62
 
63
63
                        /* determine which binary files are arch all
64
64
                           packages: */
65
 
                        for( j = 0 ; j < binary->count ; j++ ) {
 
65
                        for (j = 0 ; j < binary->count ; j++) {
66
66
                                const char *b = binary->values[j];
67
67
                                size_t l = strlen(b);
68
68
 
69
 
                                if( strncmp(fk, b, l) == 0 &&
70
 
                                                fk[l] == '_' )
 
69
                                if (strncmp(fk, b, l) == 0 &&
 
70
                                                fk[l] == '_')
71
71
                                        found_binary[j] = true;
72
72
                        }
73
73
                        continue;
74
74
                }
75
 
                if( ft == ft_ARCH_BINARY ) {
 
75
                if (ft == ft_ARCH_BINARY) {
76
76
                        const char *a = strrchr(fk, '_');
77
77
 
78
 
                        if( a == NULL )
 
78
                        if (a == NULL)
79
79
                                continue;
80
80
                        a++;
81
 
                        if( strncmp(a, archstring, archstringlen) != 0 ||
82
 
                                        a[archstringlen] != '.' )
 
81
                        if (strncmp(a, archstring, archstringlen) != 0 ||
 
82
                                        a[archstringlen] != '.')
83
83
                                continue;
84
84
                        /* found an .deb with this architecture,
85
85
                           so nothing is to be done */
86
86
                        return RET_NOTHING;
87
87
                }
88
 
                if( ft == ft_LOG || ft == ft_CHANGES ) {
 
88
                if (ft == ft_LOG || ft == ft_CHANGES) {
89
89
                        const char *a = strrchr(fk, '_');
90
90
                        const char *e;
91
91
 
92
 
                        if( a == NULL )
 
92
                        if (a == NULL)
93
93
                                continue;
94
94
                        a++;
95
 
                        while( (e = strchr(a, '+')) != NULL ) {
96
 
                                if( (size_t)(e-a) != archstringlen ) {
 
95
                        while ((e = strchr(a, '+')) != NULL) {
 
96
                                if ((size_t)(e-a) != archstringlen) {
97
97
                                        a = e+1;
98
98
                                        continue;
99
99
                                }
100
 
                                if( memcmp(a, archstring, archstringlen) != 0 ){
 
100
                                if (memcmp(a, archstring, archstringlen) != 0){
101
101
                                        a = e+1;
102
102
                                        continue;
103
103
                                }
105
105
                                        return RET_NOTHING;
106
106
                        }
107
107
                        e = strchr(a, '.');
108
 
                        if( e == NULL )
 
108
                        if (e == NULL)
109
109
                                continue;
110
 
                        if( (size_t)(e-a) != archstringlen ) {
 
110
                        if ((size_t)(e-a) != archstringlen) {
111
111
                                a = e+1;
112
112
                                continue;
113
113
                        }
114
 
                        if( memcmp(a, archstring, archstringlen) != 0 ){
 
114
                        if (memcmp(a, archstring, archstringlen) != 0){
115
115
                                a = e+1;
116
116
                                continue;
117
117
                        }
121
121
        }
122
122
        /* nothing for this architecture was found, check if is has any binary
123
123
           packages that are lacking: */
124
 
        for( i = 0 ; i < binary->count ; i++ ) {
125
 
                if( !found_binary[i] ) {
 
124
        for (i = 0 ; i < binary->count ; i++) {
 
125
                if (!found_binary[i]) {
126
126
                        printf("%s %s %s\n",
127
127
                                        sourcename, sourceversion,
128
128
                                        dscfilename);
138
138
        /*@null@*/ const char *glob;
139
139
};
140
140
 
141
 
static retvalue check_source_needs_build(UNUSED(struct database *database), struct distribution *distribution, struct target *target, const char *sourcename, const char *control, void *data) {
 
141
static retvalue check_source_needs_build(struct distribution *distribution, struct target *target, const char *sourcename, const char *control, void *data) {
142
142
        struct needbuild_data *d = data;
143
143
        char *sourceversion;
144
144
        struct strlist binary, architectures, filekeys;
146
146
        int i;
147
147
        retvalue r;
148
148
 
149
 
        if( d->glob != NULL && !globmatch(sourcename, d->glob) )
 
149
        if (d->glob != NULL && !globmatch(sourcename, d->glob))
150
150
                return RET_NOTHING;
151
151
 
152
152
        r = target->getversion(control, &sourceversion);
153
 
        if( !RET_IS_OK(r) )
 
153
        if (!RET_IS_OK(r))
154
154
                return r;
155
155
        r = chunk_getwordlist(control, "Architecture", &architectures);
156
 
        if( RET_IS_OK(r) ) {
 
156
        if (RET_IS_OK(r)) {
157
157
                bool skip = true;
158
158
 
159
 
                for( i = 0 ; i < architectures.count ; i++ ) {
 
159
                for (i = 0 ; i < architectures.count ; i++) {
160
160
                        const char *a = architectures.values[i];
161
 
                        if( strcmp(a, "any") == 0 ) {
 
161
                        if (strcmp(a, "any") == 0) {
162
162
                                skip = false;
163
163
                                break;
164
164
                        }
165
 
                        if( strcmp(a, atoms_architectures[
166
 
                                                d->architecture]) == 0 ) {
 
165
                        if (strcmp(a, atoms_architectures[
 
166
                                                d->architecture]) == 0) {
167
167
                                skip = false;
168
168
                                break;
169
169
                        }
170
170
                }
171
171
                strlist_done(&architectures);
172
 
                if( skip ) {
 
172
                if (skip) {
173
173
                        free(sourceversion);
174
174
                        return RET_NOTHING;
175
175
                }
176
176
        }
177
177
        r = chunk_getwordlist(control, "Binary", &binary);
178
 
        if( !RET_IS_OK(r) ) {
 
178
        if (!RET_IS_OK(r)) {
179
179
                free(sourceversion);
180
180
                return r;
181
181
        }
182
182
        r = target->getfilekeys(control, &filekeys);
183
 
        if( !RET_IS_OK(r) ) {
 
183
        if (!RET_IS_OK(r)) {
184
184
                strlist_done(&binary);
185
185
                free(sourceversion);
186
186
                return r;
187
187
        }
188
 
        for( i = 0 ; i < filekeys.count ; i++ ) {
189
 
                if( endswith(filekeys.values[i], ".dsc") ) {
 
188
        for (i = 0 ; i < filekeys.count ; i++) {
 
189
                if (endswith(filekeys.values[i], ".dsc")) {
190
190
                        dscfilename = filekeys.values[i];
191
191
                        break;
192
192
                }
193
193
        }
194
 
        if( dscfilename == NULL ) {
 
194
        if (dscfilename == NULL) {
195
195
                fprintf(stderr,
196
196
"Warning: source package '%s' in '%s' without dsc file!\n",
197
197
                                sourcename, target->identifier);
201
201
                return RET_NOTHING;
202
202
        }
203
203
 
204
 
        if( d->tracks != NULL ) {
 
204
        if (d->tracks != NULL) {
205
205
                struct trackedpackage *tp;
206
206
 
207
207
                r = tracking_get(d->tracks, sourcename, sourceversion, &tp);
208
 
                if( RET_WAS_ERROR(r) ) {
 
208
                if (RET_WAS_ERROR(r)) {
209
209
                        free(sourceversion);
210
210
                        strlist_done(&binary);
211
211
                        strlist_done(&filekeys);
212
212
                        return r;
213
213
                }
214
 
                if( RET_IS_OK(r) ) {
 
214
                if (RET_IS_OK(r)) {
215
215
                        r = tracked_source_needs_build(
216
216
                                        d->architecture, sourcename,
217
217
                                        sourceversion, dscfilename,
222
222
                        strlist_done(&filekeys);
223
223
                        return r;
224
224
                }
225
 
                fprintf(stderr, "Warning: %s's tracking data of %s (%s) is out of date. Run retrack to repair!\n", distribution->codename, sourcename, sourceversion);
 
225
                fprintf(stderr,
 
226
"Warning: %s's tracking data of %s (%s) is out of date. Run retrack to repair!\n",
 
227
                                distribution->codename,
 
228
                                sourcename, sourceversion);
226
229
        }
227
230
        // TODO: implement without tracking
228
231
        free(sourceversion);
232
235
}
233
236
 
234
237
 
235
 
retvalue find_needs_build(struct database *database, struct distribution *distribution, architecture_t architecture, const struct atomlist *onlycomponents, const char *glob) {
 
238
retvalue find_needs_build(struct distribution *distribution, architecture_t architecture, const struct atomlist *onlycomponents, const char *glob) {
236
239
        retvalue result, r;
237
240
        struct needbuild_data d;
238
241
 
239
242
        d.architecture = architecture;
240
243
        d.glob = glob;
241
244
 
242
 
        if( distribution->tracking == dt_NONE ) {
 
245
        if (distribution->tracking == dt_NONE) {
243
246
                fprintf(stderr,
244
247
"ERROR: '%s' has no source package Tracking enabled and\n"
245
248
"build-needing is currently only implemented for distributions where\n"
250
253
                return RET_ERROR;
251
254
        }
252
255
 
253
 
        if( distribution->tracking != dt_NONE ) {
254
 
                r = tracking_initialize(&d.tracks, database, distribution, true);
255
 
                if( RET_WAS_ERROR(r) )
 
256
        if (distribution->tracking != dt_NONE) {
 
257
                r = tracking_initialize(&d.tracks, distribution, true);
 
258
                if (RET_WAS_ERROR(r))
256
259
                        return r;
257
 
                if( r == RET_NOTHING )
 
260
                if (r == RET_NOTHING)
258
261
                        d.tracks = NULL;
259
262
        } else
260
263
                        d.tracks = NULL;
261
264
 
262
 
        result = distribution_foreach_package_c(distribution, database,
 
265
        result = distribution_foreach_package_c(distribution,
263
266
                        onlycomponents, architecture_source, pt_dsc,
264
267
                        check_source_needs_build, &d);
265
268