⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patchfns.in

📁 linux下各种patch的管理工具
💻 IN
📖 第 1 页 / 共 2 页
字号:
		return 1	fi}find_patch(){	local name="$1"	if [ -e "$SERIES" ]	then		local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/}		local bre=$(quote_bre "$patch")		set -- $(sed -e "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\)\([ "$'\t'"]\|$\)/!d" \			       -e 's/[ '$'\t''].*//' $SERIES)		if [ $# -eq 1 ]		then			echo $1			return 0		else			# We may have an exact match, which overrides			# extension expansion			while [ $# -gt 0 ]			do				if [ $1 = "$patch" ]				then					echo $1					return 0				fi				shift			done		fi	fi	# Finding the first patch will error when the series is empty	if [ -n "$(find_first_patch)" ]	then		printf $"Patch %s is not in series\n" "$name" >&2	fi	return 1}find_patch_in_series(){	local name="$1"	if [ -n "$name" ]	then		find_patch "$name"	else		find_top_patch	fi}find_applied_patch(){	local name="$1"	if [ -n "$name" ]	then		local patch		patch=$(find_patch "$name") || return 1	        if ! is_applied "$patch"	        then	                printf $"Patch %s is not applied\n" \			       "$(print_patch $patch)" >&2	                return 1	        fi		echo "$patch"	else		find_top_patch	fi}find_unapplied_patch(){	local name="$1"	if [ -n "$name" ]	then		local patch		patch=$(find_patch "$name") || return 1	        if is_applied "$patch"	        then			printf $"Patch %s is currently applied\n" \				"$(print_patch $patch)" >&2               		return 1	        fi		echo "$patch"	else		local start		if start=$(top_patch)		then			patch_after "$start"		else			find_first_patch || return 1		fi		if [ $? -ne 0 ]		then			printf $"File series fully applied, ends at patch %s\n" \				"$(print_patch $start)" >&2			return 1		fi	fi}find_patch_file(){	local name="$1"	if [ -r "$name" ]	then		echo "$name"		return	fi	local patch	patch=$(find_patch_in_series "$name" 2>/dev/null)	if [ -z "$patch" ]	then		printf $"Patch %s does not exist\n" "$name" >&2		return 1	fi	echo $(patch_file_name "$patch")}file_in_patch(){	local file=$1 patch=$2	[ -f "$QUILT_PC/$patch/$file" ]}files_in_patch(){	local patch="$1"	local path="$QUILT_PC/$patch"	if [ -d "$path" ]	then		local files		files=( $(find "$path" -type f \			       -a ! -path "$path/.timestamp") ) \		|| return 1		printf "%s\n" "${files[@]#$path/}"	fi}filenames_in_patch(){	local patch=$1	local patch_file=$(patch_file_name $patch)	if [ -e "$patch_file" ]	then		local strip=$(patch_strip_level $patch)		[ "$strip" = ab ] && strip=1		awk '		($1 == "+++" || $1 == "---" || $1 == "***") && \		$3 != "----" && $3 != "****" \			{ sub(/\t.*/, "")			  sub(/^... /, "")			  for (n=0 ; n<'"$strip"'; n++)			      sub(/^([^\/]+\/)/, "")			  print $0 }' $patch_file	fi}files_in_patch_ordered(){	local patch=$1	(   files_in_patch $patch | sort	    echo "-"	    filenames_in_patch $patch	) | awk '	$1 == "-" { out=1 ; next }	!out	{ files[$0]=1		  new_files[++n]=$0 }	out	{ if ($0 in files && !($0 in printed)) {		    print $0		    printed[$0]=1		  }		}	END	{		  for (i=1; i<=n; i++)		    if (!(new_files[i] in printed))		      print new_files[i]		}	'}diff_file(){	local file=$1 old_file=$2 new_file=$3	local index old_hdr old_date new_hdr new_date line	: ${opt_strip_level:=1}	if [ $opt_strip_level = ab ]	then		old_hdr=a/$file		new_hdr=b/$file	elif [ $opt_strip_level -eq 0 ]	then		old_hdr=$file.orig		new_hdr=$file	else		local dir=$(basename $PWD)		old_hdr=$dir.orig/$file		new_hdr=$dir/$file	fi	index=$new_hdr		if ! [ -s "$old_file" ]	then		old_file=/dev/null		old_hdr=/dev/null		[ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \		|| old_date=$'\t'"1970-01-01 00:00:00.000000000 +0000"	else		[ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \		|| old_date=$'\t'$(date +'%Y-%m-%d %H:%M:%S.%N %z' \					-r "$old_file")	fi	if ! [ -s "$new_file" ]	then		[ $opt_strip_level = 0 ] \		&& old_hdr=$new_hdr		new_file=/dev/null		new_hdr=/dev/null		[ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \		|| new_date=$'\t'"1970-01-01 00:00:00.000000000 +0000"	else		[ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \		|| new_date=$'\t'$(date +'%Y-%m-%d %H:%M:%S.%N %z' \					-r "$new_file")	fi	diff $QUILT_DIFF_OPTS $old_file $new_file \	     --label "$old_hdr$old_date" --label "$new_hdr$new_date" \	| if read line	then		if [ -z "$QUILT_NO_DIFF_INDEX" ]		then			echo "Index: $index"			echo "==================================================================="		fi		echo "$line"		cat	fi}cat_file(){	local filename		for filename in "$@"	do		if [ -e "$filename" ]		then			case "$filename" in			*.gz|*.tgz)				gzip -cd "$filename" ;;			*.bz2)				bzip2 -cd "$filename" ;;			*)				cat "$filename" ;;			esac		fi	done}cat_to_new_file(){	local filename="$1"	[ -e "$filename" ] && rm -f "$filename"	case "$filename" in	*.gz)		gzip -c ;;	*.bz2)		bzip2 -c ;;	*)		cat ;;	esac \	> "$filename"}patch_header(){	awk '	/^(---|\*\*\*|Index:)[ \t][^ \t]|^diff -/ \		{ exit }		{ print }	'}patch_body(){	awk '	!body && /^(---|\*\*\*|Index:)[ \t][^ \t]|^diff -/ \		{ body=1 }	body	{ print }	'}strip_diffstat(){	awk '	/#? .* \| / \		{ eat = eat $0 "\n"		  next }	/^#? .* files? changed(, .* insertions?\(\+\))?(, .* deletions?\(-\))?/ \		{ eat = ""		  next }		{ print eat $0		  eat = "" }	'}in_array(){	local a=$1	while [ $# -gt 1 ]	do		shift		[ "$a" = "$1" ] && return 0	done	return 1}gen_tempfile(){	local name	if [ "$1" = -d ]	then		mktemp -d ${2:-${TMPDIR:-/tmp}/${0// /_}}.XXXXXX	else		mktemp ${1:-${TMPDIR:-/tmp}/${0// /_}}.XXXXXX	fi}first_modified_by(){	local file=$1 patch	local -a patches	if [ $# -eq 0 ]	then		patches=( $(applied_patches) )	else		shift		patches=( "$@" )	fi	for patch in ${patches[@]}	do		if [ -f "$QUILT_PC/$patch/$file" ]		then			echo $patch			return 0		fi	done	return 1}create_db() {	if ! [ -e $QUILT_PC ]	then		mkdir -p $QUILT_PC		echo $DB_VERSION > $QUILT_PC/.version	fi}version_check() {	[ -e $QUILT_PC ] || return 0	if [ -e $QUILT_PC/.version ]	then		version="$(< $QUILT_PC/.version)"		if [ "$version" -gt $DB_VERSION ]		then			printf $"The quilt meta-data in this tree has version %s, but this version of quilt can only handle meta-data formats up to and including version %s. Please pop all the patches using the version of quilt used to push them before downgrading.\n" "$version" "$DB_VERSION" >&2			exit 1		elif [ "$version" = $DB_VERSION ]		then			return 0		fi	fi	return 1}print_patch() {	echo -n "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1"}setup_colors(){	local C=diff_hdr=32:diff_add=36:diff_mod=35:diff_rem=35:diff_hunk=33:diff_ctx=35:diff_cctx=33:patch_offs=33:patch_fuzz=35:patch_fail=31:patch_applied=32:clear=00	[ -n "$QUILT_COLORS" ] && C="$C:$QUILT_COLORS"	C=${C//=/=\'$'\e'[}	C=color_${C//:/m\'; color_}m\'	eval $C}quilt_command(){	local command=$1	shift	QUILT_COMMAND="" bash $BASH_OPTS -c "${SUBDIR:+cd $SUBDIR;} . $QUILT_DIR/$command" "quilt $command" "$@"}## If the working directory does not contain a $QUILT_PATCHES directory,# quilt searches for its base directory up the directory tree. If no# $QUILT_PATCHES directory exists, the quilt operations that create# patches will create $QUILT_PATCHES in the current working directory.## When quilt is invoked from a directory below the base directory, it# changes into the base directory, and sets $SUBDIR to the relative# path from the base directory to the directory in which it was# invoked. (e.g., if quilt is invoked in /usr/src/linux/drivers/net# and the base direcory is /usr/src/linux, $SUBDIR is set to# drivers/net/.unset SUBDIR SUBDIR_DOWNif ! [ -d "$QUILT_PATCHES" ]then    basedir=$PWD    while [ -n "$basedir" ]    do	basedir=${basedir%/*}	down=$down../	if [ -d "$basedir/$QUILT_PATCHES" ]	then	    SUBDIR="${PWD#$basedir/}/"	    SUBDIR_DOWN=$down	    if ! cd $basedir/	    then		echo "Cannot change into parent directory $basedir/" >&2		exit 1	    fi	    break	fi    done    unset basedir downfiif [ -n "$QUILT_SERIES" ]then	SERIES=$QUILT_SERIESelif [ -e $QUILT_PC/series ]then	SERIES=$QUILT_PC/serieselif [ -e series ]then	SERIES=serieselse	SERIES=$QUILT_PATCHES/seriesfiDB="$QUILT_PC/applied-patches"if [ -z "$skip_version_check" ] && ! version_checkthen	printf $"The working tree was created by an older version of quilt. Please run 'quilt upgrade'.\n" >&2	exit 1fi### Local Variables:### mode: shell-script### End:# vim:filetype=sh

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -