📄 buildpkg.sh.in
字号:
else [ "$RCS_D" = yes ] && \installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l [ "$RC1_D" = no ] || \ installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} lfi# If piddir doesn't exist we add it. (Ie. --with-pid-dir=/var/opt/ssh)[ -d $piddir ] || installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR$piddir d 0755 root sys_EOF# local postinstall changes here[ -s "${PKG_POSTINSTALL_LOCAL}" ] && . ${PKG_POSTINSTALL_LOCAL}cat >> postinstall << _EOFinstallf -f ${PKGNAME}# Use chroot to handle PKG_INSTALL_ROOTif [ ! -z "\${PKG_INSTALL_ROOT}" ]then chroot="chroot \${PKG_INSTALL_ROOT}"fi# If this is a test build, we will skip the groupadd/useradd/passwd commandsif [ ! -z "${TEST_DIR}" ]then chroot=echofiif egrep '^[ \t]*UsePrivilegeSeparation[ \t]+no' \${PKG_INSTALL_ROOT}/$sysconfdir/sshd_config >/dev/nullthen echo "UsePrivilegeSeparation disabled in config, not creating PrivSep user" echo "or group."else echo "UsePrivilegeSeparation enabled in config (or defaulting to on)." # user required? if cut -f1 -d: \${PKG_INSTALL_ROOT}/etc/passwd | egrep '^'$SSH_PRIVSEP_USER'\$' >/dev/null then echo "PrivSep user $SSH_PRIVSEP_USER already exists." SSH_PRIVSEP_GROUP=\`grep "^$SSH_PRIVSEP_USER:" \${PKG_INSTALL_ROOT}/etc/passwd | awk -F: '{print \$4}'\` SSH_PRIVSEP_GROUP=\`grep ":\$SSH_PRIVSEP_GROUP:" \${PKG_INSTALL_ROOT}/etc/group | awk -F: '{print \$1}'\` else DO_PASSWD=yes fi [ -z "\$SSH_PRIVSEP_GROUP" ] && SSH_PRIVSEP_GROUP=$SSH_PRIVSEP_USER # group required? if cut -f1 -d: \${PKG_INSTALL_ROOT}/etc/group | egrep '^'\$SSH_PRIVSEP_GROUP'\$' >/dev/null then echo "PrivSep group \$SSH_PRIVSEP_GROUP already exists." else DO_GROUP=yes fi # create group if required [ "\$DO_GROUP" = yes ] && { # Use gid of 67 if possible if cut -f3 -d: \${PKG_INSTALL_ROOT}/etc/group | egrep '^'$SSHDGID'\$' >/dev/null then : else sshdgid="-g $SSHDGID" fi echo "Creating PrivSep group \$SSH_PRIVSEP_GROUP." \$chroot ${PATH_GROUPADD_PROG} \$sshdgid \$SSH_PRIVSEP_GROUP } # Create user if required [ "\$DO_PASSWD" = yes ] && { # Use uid of 67 if possible if cut -f3 -d: \${PKG_INSTALL_ROOT}/etc/passwd | egrep '^'$SSHDGID'\$' >/dev/null then : else sshduid="-u $SSHDUID" fi echo "Creating PrivSep user $SSH_PRIVSEP_USER." \$chroot ${PATH_USERADD_PROG} -c 'SSHD PrivSep User' -s /bin/false -g $SSH_PRIVSEP_USER \$sshduid $SSH_PRIVSEP_USER \$chroot ${PATH_PASSWD_PROG} -l $SSH_PRIVSEP_USER }fi[ "\${POST_INS_START}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} startexit 0_EOF## Build preremove fileecho "Building preremove file..."cat > preremove << _EOF#! ${SCRIPT_SHELL}#${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop_EOF# local preremove changes here[ -s "${PKG_PREREMOVE_LOCAL}" ] && . ${PKG_PREREMOVE_LOCAL}cat >> preremove << _EOFexit 0_EOF## Build postremove fileecho "Building postremove file..."cat > postremove << _EOF#! ${SCRIPT_SHELL}#_EOF# local postremove changes here[ -s "${PKG_POSTREMOVE_LOCAL}" ] && . ${PKG_POSTREMOVE_LOCAL}cat >> postremove << _EOFexit 0_EOF## Build request fileecho "Building request file..."cat > request << _EOFtrap 'exit 3' 15_EOF[ -x /usr/bin/ckyorn ] || cat >> request << _EOFckyorn() {# for some strange reason OpenServer has no ckyorn# We build a striped down version hereDEFAULT=nPROMPT="Yes or No [yes,no,?,quit]"HELP_PROMPT=" Enter y or yes if your answer is yes; n or no if your answer is no."USAGE="usage: ckyorn [options]where options may include: -d default -h help -p prompt"if [ \$# != 0 ]then while getopts d:p:h: c do case \$c in h) HELP_PROMPT="\$OPTARG" ;; d) DEFAULT=\$OPTARG ;; p) PROMPT=\$OPTARG ;; \\?) echo "\$USAGE" 1>&2 exit 1 ;; esac done shift \`expr \$OPTIND - 1\`fiwhile truedo echo "\${PROMPT}\\c " 1>&2 read key [ -z "\$key" ] && key=\$DEFAULT case \$key in [n,N]|[n,N][o,O]|[y,Y]|[y,Y][e,E][s,S]) echo "\${key}\\c" exit 0 ;; \\?) echo \$HELP_PROMPT 1>&2 ;; q|quit) echo "q\\c" 1>&2 exit 3 ;; esacdone}_EOFcat >> request << _EOFUSE_SYM_LINKS=noPRE_INS_STOP=noPOST_INS_START=no# Use symbolic links?ans=\`ckyorn -d n \-p "Do you want symbolic links for the start/stop scripts? ${DEF_MSG}"\` || exit \$?case \$ans in [y,Y]*) USE_SYM_LINKS=yes ;;esac# determine if should restart the daemonif [ -s ${piddir}/sshd.pid -a -f ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} ]then ans=\`ckyorn -d n \-p "Should the running sshd daemon be restarted? ${DEF_MSG}"\` || exit \$? case \$ans in [y,Y]*) PRE_INS_STOP=yes POST_INS_START=yes ;; esacelse# determine if we should start sshd ans=\`ckyorn -d n \-p "Start the sshd daemon after installing this package? ${DEF_MSG}"\` || exit \$? case \$ans in [y,Y]*) POST_INS_START=yes ;; esacfi# make parameters available to installation service,# and so to any other packaging scriptscat >\$1 <<!USE_SYM_LINKS='\$USE_SYM_LINKS'PRE_INS_STOP='\$PRE_INS_STOP'POST_INS_START='\$POST_INS_START'!_EOF# local request changes here[ -s "${PKG_REQUEST_LOCAL}" ] && . ${PKG_REQUEST_LOCAL}cat >> request << _EOFexit 0_EOF## Next Build our prototypeecho "Building prototype file..."cat >mk-proto.awk << _EOF BEGIN { print "i pkginfo"; print "i depend"; \\ print "i preinstall"; print "i postinstall"; \\ print "i preremove"; print "i postremove"; \\ print "i request"; print "i space"; \\ split("$SYSTEM_DIR",sys_files); } { for (dir in sys_files) { if ( \$3 != sys_files[dir] ) { if ( \$1 == "s" ) { \$5=""; \$6=""; } else { \$5="root"; \$6="sys"; } } else { \$4="?"; \$5="?"; \$6="?"; break;} } } { print; }_EOFfind . | egrep -v "prototype|pkginfo|mk-proto.awk" | sort | \ pkgproto $PROTO_ARGS | nawk -f mk-proto.awk > prototype# /usr/local is a symlink on some systems[ "${USR_LOCAL_IS_SYMLINK}" = yes ] && { grep -v "^d none /usr/local ? ? ?$" prototype > prototype.new mv prototype.new prototype}## Step back a directory and now build the package.cd ..# local prototype tweeks here[ -s "${POST_PROTOTYPE_EDITS}" ] && . ${POST_PROTOTYPE_EDITS}echo "Building package.."pkgmk -d ${FAKE_ROOT} -f $FAKE_ROOT/prototype -oecho | pkgtrans -os ${FAKE_ROOT} ${START}/$PKGNAME-$VERSION$REV-$UNAME_S-$ARCH.pkg ;; justpkg.sh)rm -fr ${FAKE_ROOT}/${PKGNAME}grep -v "^PSTAMP=" $FAKE_ROOT/pkginfo > $$tmpmv $$tmp $FAKE_ROOT/pkginfocat >> $FAKE_ROOT/pkginfo << _EOFPSTAMP="${UNAME_S} ${OS_VER} ${ARCH} `date '+%d%b%Y %H:%M'`"_EOFpkgmk -d ${FAKE_ROOT} -f $FAKE_ROOT/prototype -oecho | pkgtrans -os ${FAKE_ROOT} ${START}/$PKGNAME-$VERSION$REV-$UNAME_S-$ARCH.pkg ;;esac[ "${REMOVE_FAKE_ROOT_WHEN_DONE}" = yes ] && rm -rf $FAKE_ROOTexit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -