View | Details | Raw Unified | Return to bug 10328
Collapse All | Expand All

(-)a/gear-srpmimport (-7 / +97 lines)
Lines 46-51 or: $PROG [options] --stdin Link Here
46
46
47
Options:
47
Options:
48
  --branch=BRANCH           branch name where to import (default is "srpms");
48
  --branch=BRANCH           branch name where to import (default is "srpms");
49
  --comp-branchs            create branchs for spec components (no defoult);
49
  --import-only             do not perform a checkout after importing;
50
  --import-only             do not perform a checkout after importing;
50
  --no-untar                do not unpack source tarballs;
51
  --no-untar                do not unpack source tarballs;
51
  --rules=FILENAME          gear rules filename (default is ".gear-rules");
52
  --rules=FILENAME          gear rules filename (default is ".gear-rules");
Lines 120-126 optimize_rules() Link Here
120
		done >"$tmp"
121
		done >"$tmp"
121
	sed -ne 's/^[^:]\+: \([^ ]\+ .*\|[^ .]\+$\)/&/p' "$rules" >>"$tmp"
122
	sed -ne 's/^[^:]\+: \([^ ]\+ .*\|[^ .]\+$\)/&/p' "$rules" >>"$tmp"
122
	mv "$tmp" "$rules"
123
	mv "$tmp" "$rules"
123
	git-update-index --add ${verbose:+--verbose} -- "$rules"
124
}
124
}
125
125
126
untar()
126
untar()
Lines 194-204 untar() Link Here
194
				printf '%s: %s name=%s base=%s\n' "$method_tar" "$tar_dir" "$tar_name" "$base"
194
				printf '%s: %s name=%s base=%s\n' "$method_tar" "$tar_dir" "$tar_name" "$base"
195
			fi
195
			fi
196
		fi |sed "s/${quoted:-@version@}/@version@/g" >>"$gear_rules"
196
		fi |sed "s/${quoted:-@version@}/@version@/g" >>"$gear_rules"
197
		git-ls-files -z --others --modified -- "$tar_dir" | \
198
			git-update-index --add ${verbose:+--verbose} -z --stdin
199
	else
197
	else
200
		printf '%s: %s\n' "$method_copy" "$f" >>"$gear_rules"
198
		printf '%s: %s\n' "$method_copy" "$f" >>"$gear_rules"
201
		git-update-index --add ${verbose:+--verbose} -- "$f"
202
	fi
199
	fi
203
}
200
}
204
201
Lines 224-229 import() Link Here
224
		sed -e s/alt-linux/altlinux/g)"
221
		sed -e s/alt-linux/altlinux/g)"
225
222
226
	# Use own directory for checkout.
223
	# Use own directory for checkout.
224
	rm -f "$compsfile" "$branchsfile"
227
	rm -rf "$workdir"
225
	rm -rf "$workdir"
228
	mkdir "$workdir"
226
	mkdir "$workdir"
229
	cd "$workdir"
227
	cd "$workdir"
Lines 246-252 import() Link Here
246
			continue
244
			continue
247
		fi
245
		fi
248
		if [ "$f" = "$spec" ]; then
246
		if [ "$f" = "$spec" ]; then
249
			git-update-index --add ${verbose:+--verbose} -- "$f"
250
			continue
247
			continue
251
		fi
248
		fi
252
		if [ "$f" = "$gear_rules" ]; then
249
		if [ "$f" = "$gear_rules" ]; then
Lines 267-279 import() Link Here
267
				;;
264
				;;
268
			*)
265
			*)
269
				printf 'copy: %s\n' "$f" >>"$gear_rules"
266
				printf 'copy: %s\n' "$f" >>"$gear_rules"
270
				git-update-index --add ${verbose:+--verbose} -- "$f"
271
				;;
267
				;;
272
		esac
268
		esac
273
	done
269
	done
274
270
271
	# Set list comps
272
	printf '%s\n%s\n' "$spec" "$gear_rules" > "$compsfile"
273
	awk '{print $2}' "$gear_rules" >> "$compsfile"
274
275
	optimize_rules "$gear_rules"
275
	optimize_rules "$gear_rules"
276
276
277
	# Branches for companents
278
	if [ -n "$comp_branchs" ]; then
279
280
		rm -rf "$compsdir"
281
		for f in $(cat "$compsfile"); do
282
			local comp_name="$f"
283
284
			if [ "$f" = "$spec" ]; then
285
				comp_name="spec"
286
			elif [ "$f" = "$gear_rules" ]; then
287
				comp_name="gear_rules"
288
			fi
289
290
			local branch_comp="$branch_import-$comp_name"
291
292
			# Use own directory for companent.
293
			mkdir "$compsdir"
294
			cd "$compsdir"
295
296
			git-symbolic-ref HEAD "refs/heads/$branch_comp"
297
			rm -f "$index_orig"
298
			cp -al "$workdir/$f" ./
299
300
			if [ -d "$f" ]; then
301
				git-ls-files -z --others --modified -- "$f" | \
302
					git-update-index --add ${verbose:+--verbose} -z --stdin
303
			elif [ -f "$f" ]; then
304
				git-update-index --add ${verbose:+--verbose} -- "$f"
305
			else
306
				msg_info "$f: Non-regular file ignored."
307
				continue
308
			fi
309
310
			local message
311
			message="$(printf '%s\n\n%s\n' "$comp_name for $verrel" "$changelog")"
312
				TZ=UTC faketime -d "1970-01-01 $buildtime seconds" -- \
313
				git-commit -a -m "$message" ${author:+--author "$author"} && \
314
				( verbose "Committed componet $comp_name into $branch_comp branch" ;
315
				TZ=UTC faketime -d "1970-01-01 $buildtime seconds" -- \
316
					git-tag -a -m "$comp_name for $name $verrel" "$verrel-$comp_name" ) ||:
317
			msg_info "Imported $comp_name for $srpm"
318
319
			printf '%s\n' $branch_comp >> $branchsfile
320
321
			cd "$workdir"
322
			rm -rf "$compsdir"
323
		done
324
325
		mkdir "$compsdir"
326
		cd "$compsdir"
327
328
		git-symbolic-ref HEAD "refs/heads/$branch_import"
329
330
		local srpm_new
331
		srpm_new="$(git-rev-parse --verify "$branch_import" 2>/dev/null ||:)"
332
333
		if [ -z "$srpm_new" ]; then
334
			git-checkout -f "$branch_import-spec"
335
			git-checkout -b "$branch_import"
336
		else
337
			git-checkout -f "$branch_import"
338
		fi
339
340
		git-merge --no-commit -s ours compsimport HEAD $(cat "$branchsfile") ||:
341
		msg_info "Merged all componets into $branch_import branch"
342
343
		cd "$workdir"
344
		rm -rf "$compsdir"
345
	fi
346
347
	for f in $(cat "$compsfile"); do
348
		if [ -d "$f" ]; then
349
			git-ls-files -z --others --modified -- "$f" | \
350
				git-update-index --add ${verbose:+--verbose} -z --stdin
351
			continue
352
		fi
353
		if [ -L "$f" -o ! -f "$f" ]; then
354
			msg_info "$f: Non-regular file ignored."
355
			continue
356
		fi
357
		git-update-index --add ${verbose:+--verbose} -- "$f"
358
359
	done
360
277
	local message
361
	local message
278
	message="$(printf '%s\n\n%s\n' "$verrel" "$changelog")"
362
	message="$(printf '%s\n\n%s\n' "$verrel" "$changelog")"
279
	TZ=UTC faketime -d "1970-01-01 $buildtime seconds" -- \
363
	TZ=UTC faketime -d "1970-01-01 $buildtime seconds" -- \
Lines 284-294 import() Link Here
284
	msg_info "Imported $srpm"
368
	msg_info "Imported $srpm"
285
}
369
}
286
370
287
TEMP=`getopt -n $PROG -o h,q,v,V -l branch:,import-only,no-untar,rules:,spec-pattern:,stdin,help,quiet,verbose,version -- "$@"` ||
371
TEMP=`getopt -n $PROG -o h,q,v,V -l branch:,comp-branchs,import-only,no-untar,rules:,spec-pattern:,stdin,help,quiet,verbose,version -- "$@"` ||
288
	show_usage
372
	show_usage
289
eval set -- "$TEMP"
373
eval set -- "$TEMP"
290
374
291
branch_import=srpms
375
branch_import=srpms
376
comp_branchs=
292
import_only=
377
import_only=
293
no_untar=
378
no_untar=
294
read_from_stdin=
379
read_from_stdin=
Lines 299-304 while :; do Link Here
299
			;;
384
			;;
300
		--branch) shift; branch_import="$1"
385
		--branch) shift; branch_import="$1"
301
			;;
386
			;;
387
		--comp-branchs) comp_branchs=1
388
			;;
302
		--import-only) import_only=1
389
		--import-only) import_only=1
303
			;;
390
			;;
304
		--no-untar) no_untar=1
391
		--no-untar) no_untar=1
Lines 350-355 saved_cwd="$(/bin/pwd)" Link Here
350
tmpdir="$(mktemp -dt "$PROG.XXXXXXXX")"
437
tmpdir="$(mktemp -dt "$PROG.XXXXXXXX")"
351
trap exit_handler HUP PIPE INT QUIT TERM EXIT
438
trap exit_handler HUP PIPE INT QUIT TERM EXIT
352
workdir="$tmpdir/work"
439
workdir="$tmpdir/work"
440
compsdir="$tmpdir/compsdir"
441
compsfile="$tmpdir/list"
442
branchsfile="$tmpdir/branchslist"
353
443
354
# Backup index file.
444
# Backup index file.
355
[ ! -f "$index_orig" ] ||
445
[ ! -f "$index_orig" ] ||

Return to bug 10328